@emerson-eps/color-tables 0.2.9 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component/ColorSelector/ColorSelectorAccordion.js +2 -2
- package/dist/component/ColorSelector/ColorSelectorAccordion.js.map +1 -1
- package/dist/component/ColorSelector/ColorSelectorComponent.d.ts +0 -3
- package/dist/component/ColorSelector/ColorSelectorComponent.js +1 -11
- package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
- package/dist/component/ColorSelector/ColorSelectorWrapper.d.ts +0 -1
- package/dist/component/ColorSelector/ColorSelectorWrapper.js +13 -12
- package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -1
- package/dist/component/Legend/ColorLegend.d.ts +2 -2
- package/dist/component/Legend/ColorLegend.js +12 -5
- package/dist/component/Legend/ColorLegend.js.map +1 -1
- package/dist/component/Legend/ContinuousLegend.d.ts +1 -1
- package/dist/component/Legend/ContinuousLegend.js +18 -4
- package/dist/component/Legend/ContinuousLegend.js.map +1 -1
- package/dist/component/Legend/DiscreteLegend.d.ts +1 -2
- package/dist/component/Legend/DiscreteLegend.js +28 -27
- package/dist/component/Legend/DiscreteLegend.js.map +1 -1
- package/dist/component/{ColorTableTypes.d.ts → Utils/ColorTableTypes.d.ts} +0 -0
- package/dist/component/{ColorTableTypes.js → Utils/ColorTableTypes.js} +0 -0
- package/dist/component/Utils/ColorTableTypes.js.map +1 -0
- package/dist/component/Utils/continousLegend.d.ts +2 -2
- package/dist/component/Utils/continousLegend.js.map +1 -1
- package/dist/component/Utils/discreteLegend.js +21 -77
- package/dist/component/Utils/discreteLegend.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/stories/ColorLegends/SingleComponent/Single.stories.d.ts +1 -1
- package/dist/stories/ColorLegends/SingleComponent/Single.stories.js +2 -2
- package/dist/stories/ColorLegends/SingleComponent/Single.stories.js.map +1 -1
- package/package.json +1 -1
- package/src/component/ColorSelector/ColorSelectorAccordion.tsx +2 -2
- package/src/component/ColorSelector/ColorSelectorComponent.tsx +1 -18
- package/src/component/ColorSelector/ColorSelectorWrapper.tsx +49 -48
- package/src/component/Legend/ColorLegend.tsx +22 -7
- package/src/component/Legend/ContinuousLegend.tsx +18 -5
- package/src/component/Legend/DiscreteLegend.tsx +32 -60
- package/src/component/{ColorTableTypes.ts → Utils/ColorTableTypes.ts} +0 -0
- package/src/component/Utils/continousLegend.ts +3 -3
- package/src/component/Utils/discreteLegend.ts +11 -82
- package/src/index.ts +12 -9
- package/src/stories/ColorLegends/SingleComponent/Single.stories.jsx +2 -2
- package/tsconfig.json +2 -2
- package/dist/component/ColorTableTypes.js.map +0 -1
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
// eslint-disable-next-line
|
|
2
2
|
export default function discreteLegendUtil(itemColor, isSelectorLegend, horizontal) {
|
|
3
|
-
// var cellWidth = 22;
|
|
4
|
-
// var cellHeight = 22;
|
|
5
|
-
// if (isSelectorLegend) {
|
|
6
|
-
// cellWidth = 25;
|
|
7
|
-
// cellHeight = 22;
|
|
8
|
-
// }
|
|
9
3
|
var legendValues = [];
|
|
10
4
|
// eslint-disable-next-line
|
|
11
5
|
function legend(g) {
|
|
@@ -30,105 +24,55 @@ export default function discreteLegendUtil(itemColor, isSelectorLegend, horizont
|
|
|
30
24
|
if (horizontal && !isSelectorLegend) {
|
|
31
25
|
g.selectAll("rect")
|
|
32
26
|
.attr("x", function (d, i) {
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
// temporary workaround to ignore typescript error (d value as unused)
|
|
28
|
+
if (i)
|
|
29
|
+
return i;
|
|
30
|
+
else if (d)
|
|
31
|
+
return null;
|
|
35
32
|
})
|
|
36
33
|
.attr("y", 0);
|
|
37
34
|
}
|
|
38
35
|
else if (!horizontal && !isSelectorLegend) {
|
|
39
36
|
g.selectAll("rect")
|
|
40
37
|
.attr("y", function (d, i) {
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
if (i)
|
|
39
|
+
return i;
|
|
40
|
+
else if (d)
|
|
41
|
+
return null;
|
|
43
42
|
})
|
|
44
43
|
.attr("x", 0);
|
|
45
44
|
}
|
|
46
45
|
else if (horizontal == true && isSelectorLegend) {
|
|
47
46
|
g.selectAll("rect")
|
|
48
47
|
.attr("x", function (d, i) {
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
if (i)
|
|
49
|
+
return i;
|
|
50
|
+
else if (d)
|
|
51
|
+
return null;
|
|
51
52
|
})
|
|
52
53
|
.attr("y", 0);
|
|
53
54
|
}
|
|
54
55
|
else if (horizontal == false && isSelectorLegend) {
|
|
55
56
|
g.selectAll("rect")
|
|
56
57
|
.attr("y", function (d, i) {
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
if (i)
|
|
59
|
+
return i;
|
|
60
|
+
else if (d)
|
|
61
|
+
return null;
|
|
59
62
|
})
|
|
60
63
|
.attr("x", 0);
|
|
61
64
|
}
|
|
62
65
|
else {
|
|
63
66
|
g.selectAll("rect")
|
|
64
67
|
.attr("x", function (d, i) {
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
if (i)
|
|
69
|
+
return i;
|
|
70
|
+
else if (d)
|
|
71
|
+
return null;
|
|
67
72
|
})
|
|
68
73
|
.attr("y", 0);
|
|
69
74
|
}
|
|
70
|
-
// Display the labels for legend
|
|
71
|
-
// g.selectAll("g")
|
|
72
|
-
// .style("background", "grey")
|
|
73
|
-
// .append("text")
|
|
74
|
-
// .attr("class", "breakLabels")
|
|
75
|
-
// .style("font-size", "0.4")
|
|
76
|
-
// //.attr("x", cellWidth + cellPadding)
|
|
77
|
-
// //.attr("y", 5 + cellHeight / 2)
|
|
78
|
-
// .attr("x", function (d: any, i: any) {
|
|
79
|
-
// //console.log(d)
|
|
80
|
-
// return i + "." + 25
|
|
81
|
-
// })
|
|
82
|
-
// .attr("y", 1.5)
|
|
83
|
-
// .text(function (d: any, i: any) {
|
|
84
|
-
// //console.log(d)
|
|
85
|
-
// return i;
|
|
86
|
-
// })
|
|
87
|
-
//}
|
|
88
|
-
// styling for main legend
|
|
89
|
-
// else {
|
|
90
|
-
// itemColor.forEach((item, index) => {
|
|
91
|
-
// legendValues[index].color = item.color;
|
|
92
|
-
// });
|
|
93
|
-
// g.selectAll("g.legendCells")
|
|
94
|
-
// .append("text")
|
|
95
|
-
// .attr("class", "breakLabels")
|
|
96
|
-
// .style("fill", "#6F6F6F")
|
|
97
|
-
// .attr("x", cellWidth + cellPadding)
|
|
98
|
-
// .attr("y", 5 + cellHeight / 2)
|
|
99
|
-
// .text(function (d: Record<string, unknown>, i:any) {
|
|
100
|
-
// return d['label'];
|
|
101
|
-
// });
|
|
102
|
-
// g.selectAll("g.legendCells")
|
|
103
|
-
// .style("cursor", "pointer")
|
|
104
|
-
// .append("rect")
|
|
105
|
-
// .attr("height", cellHeight)
|
|
106
|
-
// .attr("width", cellWidth)
|
|
107
|
-
// .style("fill", function (d: Record<string, unknown>) {
|
|
108
|
-
// //console.log('d', d)
|
|
109
|
-
// return d["color"];
|
|
110
|
-
// })
|
|
111
|
-
// // Alighment of cell in straight line
|
|
112
|
-
// g.selectAll("g.legendCells").attr(
|
|
113
|
-
// "transform",
|
|
114
|
-
// function (_d: Record<string, unknown>, i: number) {
|
|
115
|
-
// return (
|
|
116
|
-
// "translate(0," + i * (cellHeight + cellPadding) + ")"
|
|
117
|
-
// //"translate(0," + i + ")"
|
|
118
|
-
// );
|
|
119
|
-
// }
|
|
120
|
-
// );
|
|
121
|
-
// }
|
|
122
75
|
}
|
|
123
|
-
// display the discrete legend
|
|
124
|
-
// if (!isSelectorLegend) {
|
|
125
|
-
// // console.log('itemcolor', itemColor)
|
|
126
|
-
// g.selectAll("g.legendCells")
|
|
127
|
-
// .data(legendValues)
|
|
128
|
-
// .enter()
|
|
129
|
-
// .append("g")
|
|
130
|
-
// .attr("class", "legendCells")
|
|
131
|
-
// }
|
|
132
76
|
drawLegend();
|
|
133
77
|
}
|
|
134
78
|
// eslint-disable-next-line
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discreteLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/discreteLegend.ts"],"names":[],"mappings":"AAIA,2BAA2B;AAC3B,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,SAAsB,EAAE,gBAA0B,EAAE,UAAgB;IAC3G,
|
|
1
|
+
{"version":3,"file":"discreteLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/discreteLegend.ts"],"names":[],"mappings":"AAIA,2BAA2B;AAC3B,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,SAAsB,EAAE,gBAA0B,EAAE,UAAgB;IAC3G,IAAM,YAAY,GAAgB,EAAE,CAAC;IAErC,2BAA2B;IAC3B,SAAS,MAAM,CAAC,CAAM;QAClB,SAAS,UAAU;YACf,yBAAyB;YACzB,oCAAoC;YACpC,yBAAyB;YACzB,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC;iBACvB,IAAI,CAAC,SAAS,CAAC;iBACf,KAAK,EAAE;iBACP,MAAM,CAAC,GAAG,CAAC;iBACX,MAAM,CAAC,MAAM,CAAC;iBACd,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC;iBAC1B,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;iBAC1B,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YACpC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;iBACd,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;iBACjB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;iBAChB,KAAK,CAAC,MAAM,EAAE,UAAU,CAA0B;gBAC/C,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;YACP,IAAI,UAAU,IAAI,CAAC,gBAAgB,EAAE;gBACjC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;qBACd,IAAI,CAAC,GAAG,EAAE,UAAU,CAAS,EAAE,CAAS;oBACzC,sEAAsE;oBAClE,IAAI,CAAC;wBAAE,OAAO,CAAC,CAAC;yBACX,IAAI,CAAC;wBAAE,OAAO,IAAI,CAAC;gBAC5B,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACrB;iBAAM,IAAI,CAAC,UAAU,IAAI,CAAC,gBAAgB,EAAE;gBACzC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;qBACd,IAAI,CAAC,GAAG,EAAE,UAAU,CAAS,EAAE,CAAS;oBACrC,IAAI,CAAC;wBAAE,OAAO,CAAC,CAAC;yBACX,IAAI,CAAC;wBAAE,OAAO,IAAI,CAAC;gBAC5B,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACrB;iBAAM,IAAI,UAAU,IAAI,IAAI,IAAI,gBAAgB,EAAE;gBAC/C,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;qBACd,IAAI,CAAC,GAAG,EAAE,UAAU,CAAS,EAAE,CAAS;oBACrC,IAAI,CAAC;wBAAE,OAAO,CAAC,CAAC;yBACX,IAAI,CAAC;wBAAE,OAAO,IAAI,CAAC;gBAC5B,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACrB;iBAAM,IAAI,UAAU,IAAI,KAAK,IAAI,gBAAgB,EAAE;gBAChD,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;qBACd,IAAI,CAAC,GAAG,EAAE,UAAU,CAAS,EAAE,CAAS;oBACrC,IAAI,CAAC;wBAAE,OAAO,CAAC,CAAC;yBACX,IAAI,CAAC;wBAAE,OAAO,IAAI,CAAC;gBAC5B,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACrB;iBAAM;gBACH,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;qBACd,IAAI,CAAC,GAAG,EAAE,UAAU,CAAS,EAAE,CAAS;oBACrC,IAAI,CAAC;wBAAE,OAAO,CAAC,CAAC;yBACX,IAAI,CAAC;wBAAE,OAAO,IAAI,CAAC;gBAC5B,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACrB;QACL,CAAC;QAED,UAAU,EAAE,CAAC;IACjB,CAAC;IACD,2BAA2B;IAC3B,MAAM,CAAC,UAAU,GAAG,UAAU,QAAa;QACvC,2BAA2B;QAC3B,IAAI,KAAK,GAAQ,EAAE,CAAC;QACpB,KAAK,GAAG,QAAQ,CAAC;QAEjB,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAO;YACpC,IAAM,UAAU,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;YACnD,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ContinuousLegend } from './component/Legend/ContinuousLegend';
|
|
2
|
-
import { colorsArray, rgbValues, RGBToHex } from './component/Utils/continousLegend';
|
|
3
|
-
import { colorTableData, DiscreteColorLegend } from './component/Legend/DiscreteLegend';
|
|
4
|
-
import { colorTablesObj, colorTablesArray } from './component/ColorTableTypes';
|
|
5
1
|
import { ColorSelectorAccordion } from './component/ColorSelector/ColorSelectorAccordion';
|
|
6
2
|
import { ColorSelectorComponent } from './component/ColorSelector/ColorSelectorComponent';
|
|
7
3
|
import { ColorSelectorWrapper } from './component/ColorSelector/ColorSelectorWrapper';
|
|
4
|
+
import { ContinuousLegend } from './component/Legend/ContinuousLegend';
|
|
5
|
+
import { DiscreteColorLegend } from './component/Legend/DiscreteLegend';
|
|
6
|
+
import { ColorLegend } from './component/Legend/ColorLegend';
|
|
7
|
+
import { colorsArray, rgbValues, RGBToHex } from './component/Utils/continousLegend';
|
|
8
|
+
import { d3ColorScales } from './component/Utils/d3ColorScale';
|
|
9
|
+
import { colorTablesObj, colorTablesArray } from './component/Utils/ColorTableTypes';
|
|
8
10
|
import * as colorTables from './component/color-tables.json';
|
|
9
|
-
export {
|
|
11
|
+
export { ColorSelectorAccordion, ColorSelectorComponent, ColorSelectorWrapper, ContinuousLegend, DiscreteColorLegend, ColorLegend, colorsArray, rgbValues, RGBToHex, d3ColorScales, colorTablesObj, colorTablesArray, colorTables, };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ContinuousLegend } from './component/Legend/ContinuousLegend';
|
|
2
|
-
import { colorsArray, rgbValues, RGBToHex } from './component/Utils/continousLegend';
|
|
3
|
-
import { colorTableData, DiscreteColorLegend } from './component/Legend/DiscreteLegend';
|
|
4
1
|
import { ColorSelectorAccordion } from './component/ColorSelector/ColorSelectorAccordion';
|
|
5
2
|
import { ColorSelectorComponent } from './component/ColorSelector/ColorSelectorComponent';
|
|
6
3
|
import { ColorSelectorWrapper } from './component/ColorSelector/ColorSelectorWrapper';
|
|
4
|
+
import { ContinuousLegend } from './component/Legend/ContinuousLegend';
|
|
5
|
+
import { DiscreteColorLegend } from './component/Legend/DiscreteLegend';
|
|
6
|
+
import { ColorLegend } from './component/Legend/ColorLegend';
|
|
7
|
+
import { colorsArray, rgbValues, RGBToHex } from './component/Utils/continousLegend';
|
|
8
|
+
import { d3ColorScales } from './component/Utils/d3ColorScale';
|
|
7
9
|
import * as colorTables from './component/color-tables.json';
|
|
8
|
-
export {
|
|
10
|
+
export { ColorSelectorAccordion, ColorSelectorComponent, ColorSelectorWrapper, ContinuousLegend, DiscreteColorLegend, ColorLegend, colorsArray, rgbValues, RGBToHex, d3ColorScales, colorTables, };
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,aAAa,EAGb,WAAW,GACd,CAAC"}
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import React from "react";
|
|
13
13
|
import colorTables from "../../../component/color-tables.json";
|
|
14
|
-
import ColorLegend from "../../../component/Legend/ColorLegend";
|
|
14
|
+
import { ColorLegend } from "../../../component/Legend/ColorLegend";
|
|
15
15
|
export default {
|
|
16
16
|
component: ColorLegend,
|
|
17
17
|
title: "Legends/SingleComponent",
|
|
@@ -22,7 +22,7 @@ var max = 0.35;
|
|
|
22
22
|
var dataObjectName = "Legend";
|
|
23
23
|
var position = [16, 10];
|
|
24
24
|
var horizontal = true;
|
|
25
|
-
var colorName = "
|
|
25
|
+
var colorName = "Pastel1";
|
|
26
26
|
// prop for discrete data
|
|
27
27
|
var discreteData = {
|
|
28
28
|
"Above_BCU": [[], 0],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Single.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/SingleComponent/Single.stories.jsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAC/D,OAAO,WAAW,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"Single.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/SingleComponent/Single.stories.jsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAC,WAAW,EAAC,MAAM,uCAAuC,CAAC;AAElE,eAAe;IACX,SAAS,EAAE,WAAW;IACtB,KAAK,EAAE,yBAAyB;CACnC,CAAC;AAEF,4BAA4B;AAC5B,IAAM,GAAG,GAAG,CAAC,CAAC;AACd,IAAM,GAAG,GAAG,IAAI,CAAC;AACjB,IAAM,cAAc,GAAG,QAAQ,CAAC;AAChC,IAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,IAAM,UAAU,GAAG,IAAI,CAAC;AACxB,IAAM,SAAS,GAAG,SAAS,CAAC;AAE5B,yBAAyB;AACzB,IAAM,YAAY,GAAG;IACjB,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACd,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACd,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACd,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;CACpB,CAAC;AAEF,IAAM,QAAQ,GAAG,UAAC,IAAI;IAClB,OAAO,oBAAC,WAAW,eAAK,IAAI,EAAI,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpD,kBAAkB,CAAC,IAAI,GAAG;IACtB,GAAG,KAAA;IACH,GAAG,KAAA;IACH,cAAc,gBAAA;IACd,QAAQ,UAAA;IACR,UAAU,YAAA;IACV,SAAS,WAAA;IACT,WAAW,aAAA;IACX,YAAY,cAAA;CACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@ export const ColorSelectorAccordion = (props: any) => {
|
|
|
22
22
|
Geologic Color Scale
|
|
23
23
|
</Accordion.Header>
|
|
24
24
|
<Accordion.Panel>
|
|
25
|
-
<ColorSelectorWrapper useColorTableColors={true}
|
|
25
|
+
<ColorSelectorWrapper useColorTableColors={true} colorScaleObject={props}/>
|
|
26
26
|
</Accordion.Panel>
|
|
27
27
|
</Accordion.Item>
|
|
28
28
|
</Accordion>
|
|
@@ -32,7 +32,7 @@ export const ColorSelectorAccordion = (props: any) => {
|
|
|
32
32
|
D3 Color Scale
|
|
33
33
|
</Accordion.Header>
|
|
34
34
|
<Accordion.Panel>
|
|
35
|
-
<ColorSelectorWrapper
|
|
35
|
+
<ColorSelectorWrapper useColorTableColors={false} colorScaleObject={props}/>
|
|
36
36
|
</Accordion.Panel>
|
|
37
37
|
</Accordion.Item>
|
|
38
38
|
</Accordion>
|
|
@@ -4,7 +4,6 @@ import { RGBToHex } from "../Utils/continousLegend";
|
|
|
4
4
|
import {d3ColorScales} from "../Utils/d3ColorScale";
|
|
5
5
|
import { select, range} from "d3";
|
|
6
6
|
import * as d3 from "d3";
|
|
7
|
-
import { colorTablesArray, colorTablesObj } from "../ColorTableTypes";
|
|
8
7
|
import discreteLegendUtil from "../Utils/discreteLegend";
|
|
9
8
|
import { color } from "d3-color";
|
|
10
9
|
|
|
@@ -17,7 +16,6 @@ declare type legendProps = {
|
|
|
17
16
|
useDiscColorTable?: boolean;
|
|
18
17
|
valueIndex?: any;
|
|
19
18
|
colorScaleData: any;
|
|
20
|
-
getColorMapname?: any | null;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
declare type ItemColor = {
|
|
@@ -26,7 +24,6 @@ declare type ItemColor = {
|
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
export const ColorSelectorComponent: React.FC<legendProps> = ({
|
|
29
|
-
// position,
|
|
30
27
|
colorsObject,
|
|
31
28
|
legendColor,
|
|
32
29
|
legendColorName,
|
|
@@ -34,7 +31,6 @@ export const ColorSelectorComponent: React.FC<legendProps> = ({
|
|
|
34
31
|
useDiscColorTable,
|
|
35
32
|
valueIndex,
|
|
36
33
|
colorScaleData,
|
|
37
|
-
// getColorMapname,
|
|
38
34
|
}: legendProps) => {
|
|
39
35
|
|
|
40
36
|
const divRef = useRef<HTMLDivElement>(null);
|
|
@@ -159,7 +155,6 @@ export const ColorSelectorComponent: React.FC<legendProps> = ({
|
|
|
159
155
|
.attr("y", 15)
|
|
160
156
|
.style("font-size", "smaller")
|
|
161
157
|
.style("font-weight", "900")
|
|
162
|
-
// .attr("textLength","5em")
|
|
163
158
|
.text(colorsObject.name);
|
|
164
159
|
|
|
165
160
|
// draw the rectangle and fill with gradient
|
|
@@ -314,16 +309,4 @@ export const ColorSelectorComponent: React.FC<legendProps> = ({
|
|
|
314
309
|
ref={divRef} onClick={handleChange}></div>
|
|
315
310
|
</div>
|
|
316
311
|
);
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
// Based on name return the colors array from color.tables.json file
|
|
320
|
-
export function colorTableData(
|
|
321
|
-
colorName: string,
|
|
322
|
-
colorTables: colorTablesArray
|
|
323
|
-
): [number, number, number, number][] {
|
|
324
|
-
const colorTableData = colorTables.filter(
|
|
325
|
-
(value: colorTablesObj) =>
|
|
326
|
-
value.name.toLowerCase() == colorName.toLowerCase()
|
|
327
|
-
);
|
|
328
|
-
return colorTableData.length > 0 ? colorTableData[0].colors : [];
|
|
329
|
-
}
|
|
312
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
const colorTables = require("../color-tables.json");
|
|
3
3
|
import {d3ColorScales} from "../Utils/d3ColorScale";
|
|
4
4
|
import {ColorSelectorComponent} from "./ColorSelectorComponent";
|
|
5
5
|
|
|
@@ -11,7 +11,6 @@ const discreteD3ColorData: any = [];
|
|
|
11
11
|
|
|
12
12
|
declare type legendProps = {
|
|
13
13
|
useColorTableColors: boolean,
|
|
14
|
-
useD3Colors: boolean,
|
|
15
14
|
colorScaleObject: any
|
|
16
15
|
}
|
|
17
16
|
|
|
@@ -53,59 +52,61 @@ d3discreteData.forEach((element: any) => {
|
|
|
53
52
|
|
|
54
53
|
export const ColorSelectorWrapper: React.FC<legendProps> = ({
|
|
55
54
|
useColorTableColors,
|
|
56
|
-
useD3Colors,
|
|
57
55
|
colorScaleObject,
|
|
58
56
|
}: legendProps) => {
|
|
59
57
|
let continuousLegend;
|
|
60
58
|
let discreteLegend;
|
|
59
|
+
|
|
60
|
+
// return continuous and discrete legend which uses d3 data
|
|
61
|
+
if (useColorTableColors) {
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
continuousLegend = continuosD3ColorData.map((val: any, key: any) => {
|
|
64
|
+
return <ColorSelectorComponent
|
|
65
|
+
position={position + key}
|
|
66
|
+
legendColor={val.color}
|
|
67
|
+
legendColorName={val.name}
|
|
68
|
+
useContColorTable={false}
|
|
69
|
+
valueIndex={key + "0"}
|
|
70
|
+
colorScaleData={colorScaleObject.colorScaleObject}
|
|
71
|
+
/>
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
discreteLegend = d3discreteData.map((val: any, key: any) => {
|
|
75
|
+
return <ColorSelectorComponent
|
|
76
|
+
position={position + key}
|
|
77
|
+
colorsObject={val.colors}
|
|
78
|
+
legendColorName={val.name}
|
|
79
|
+
useDiscColorTable={false}
|
|
80
|
+
colorScaleData={colorScaleObject.colorScaleObject}
|
|
81
|
+
/>
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// return continuous and discrete legend which uses colortable data
|
|
86
|
+
else if (!useColorTableColors) {
|
|
87
|
+
continuousLegend = continuosColorData.map((value: any, key: any) => {
|
|
88
|
+
return <div>
|
|
89
|
+
<ColorSelectorComponent
|
|
90
|
+
position={position + key}
|
|
91
|
+
colorsObject={value}
|
|
92
|
+
useContColorTable={true}
|
|
93
|
+
valueIndex={key}
|
|
94
|
+
colorScaleData={colorScaleObject.colorScaleObject}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
discreteLegend = discreteColorData.map((val: any, key: any) => {
|
|
100
|
+
return <ColorSelectorComponent
|
|
101
|
+
position={position + key}
|
|
102
|
+
colorsObject={discreteColorData[key]}
|
|
103
|
+
legendColorName={val.name}
|
|
104
|
+
useDiscColorTable={true}
|
|
71
105
|
colorScaleData={colorScaleObject.colorScaleObject}
|
|
72
106
|
/>
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
discreteLegend = discreteColorData.map((val: any, key: any) => {
|
|
77
|
-
return <ColorSelectorComponent
|
|
78
|
-
position={position + key}
|
|
79
|
-
colorsObject={discreteColorData[key]}
|
|
80
|
-
legendColorName={val.name}
|
|
81
|
-
useDiscColorTable={true}
|
|
82
|
-
colorScaleData={colorScaleObject.colorScaleObject}
|
|
83
|
-
/>
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
// return continuous and discrete legend which uses d3 data
|
|
87
|
-
if (useD3Colors) {
|
|
88
|
-
continuousLegend = continuosD3ColorData.map((val: any, key: any) => {
|
|
89
|
-
return <ColorSelectorComponent
|
|
90
|
-
position={position + key}
|
|
91
|
-
legendColor={val.color}
|
|
92
|
-
legendColorName={val.name}
|
|
93
|
-
useContColorTable={false}
|
|
94
|
-
valueIndex={key + "0"}
|
|
95
|
-
colorScaleData={colorScaleObject.colorScaleObject}
|
|
96
|
-
/>
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
discreteLegend = d3discreteData.map((val: any, key: any) => {
|
|
100
|
-
return <ColorSelectorComponent
|
|
101
|
-
position={position + key}
|
|
102
|
-
colorsObject={val.colors}
|
|
103
|
-
legendColorName={val.name}
|
|
104
|
-
useDiscColorTable={false}
|
|
105
|
-
colorScaleData={colorScaleObject.colorScaleObject}
|
|
106
|
-
/>
|
|
107
|
-
});
|
|
108
|
-
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//}
|
|
109
110
|
|
|
110
111
|
return (
|
|
111
112
|
<div className="legendWrapper"
|
|
@@ -3,6 +3,7 @@ import { DiscreteColorLegend } from "./DiscreteLegend";
|
|
|
3
3
|
import { ContinuousLegend } from "./ContinuousLegend";
|
|
4
4
|
import {useCallback} from "react";
|
|
5
5
|
import { ColorSelectorAccordion } from "../ColorSelector/ColorSelectorAccordion";
|
|
6
|
+
import {d3ColorScales} from "../Utils/d3ColorScale";
|
|
6
7
|
|
|
7
8
|
declare type ColorLegendProps = {
|
|
8
9
|
colorTables: any;
|
|
@@ -17,7 +18,7 @@ declare type ColorLegendProps = {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
// Todo: Adapt it for other layers too
|
|
20
|
-
const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
21
|
+
export const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
21
22
|
position,
|
|
22
23
|
horizontal,
|
|
23
24
|
colorTables,
|
|
@@ -35,7 +36,23 @@ const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
|
35
36
|
}, []);
|
|
36
37
|
|
|
37
38
|
const [updateLegend, setUpdateLegendColor] = React.useState([] as any);
|
|
38
|
-
|
|
39
|
+
|
|
40
|
+
const isColortableColors = colorTables.find(
|
|
41
|
+
(value: any) => {
|
|
42
|
+
return value?.name == colorName
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const isD3Colors = d3ColorScales.find(
|
|
47
|
+
(value: any) => {
|
|
48
|
+
return value?.name == colorName
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const [isCont, setIsCont] = React.useState(
|
|
53
|
+
(isColortableColors || isD3Colors) &&
|
|
54
|
+
(isColortableColors?.discrete == false || isD3Colors?.discrete == false) ? true : false
|
|
55
|
+
);
|
|
39
56
|
|
|
40
57
|
// Get new colorscale from colorselector and update legend
|
|
41
58
|
const colorScaleObject = React.useCallback((data: any, value: any) => {
|
|
@@ -54,7 +71,7 @@ const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
|
54
71
|
return (
|
|
55
72
|
<div>
|
|
56
73
|
<div onClick={handleClick}>
|
|
57
|
-
{isCont && (
|
|
74
|
+
{isCont == true && (
|
|
58
75
|
<ContinuousLegend
|
|
59
76
|
min={min}
|
|
60
77
|
max={max}
|
|
@@ -66,7 +83,7 @@ const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
|
66
83
|
updateLegend={updateLegend}
|
|
67
84
|
/>
|
|
68
85
|
)}
|
|
69
|
-
{
|
|
86
|
+
{isCont == false && (
|
|
70
87
|
<DiscreteColorLegend
|
|
71
88
|
discreteData={discreteData}
|
|
72
89
|
dataObjectName={dataObjectName}
|
|
@@ -86,6 +103,4 @@ const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
|
86
103
|
</div>
|
|
87
104
|
|
|
88
105
|
);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export default ColorLegend;
|
|
106
|
+
};
|
|
@@ -2,7 +2,10 @@ import * as React from "react";
|
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import { RGBToHex, colorsArray } from "../Utils/continousLegend";
|
|
4
4
|
import { select, scaleLinear, scaleSequential, axisBottom, axisRight } from "d3";
|
|
5
|
-
import { colorTablesArray } from "../ColorTableTypes";
|
|
5
|
+
import { colorTablesArray } from "../Utils/ColorTableTypes";
|
|
6
|
+
import {d3ColorScales} from "../Utils/d3ColorScale";
|
|
7
|
+
import { color } from "d3-color";
|
|
8
|
+
import { range } from "d3";
|
|
6
9
|
|
|
7
10
|
declare type legendProps = {
|
|
8
11
|
min: number;
|
|
@@ -56,11 +59,11 @@ export const ContinuousLegend: React.FC<legendProps> = ({
|
|
|
56
59
|
let legendColors = typeof colorTables === "string" ?
|
|
57
60
|
colorsArray(colorName, dataSet)
|
|
58
61
|
:
|
|
59
|
-
colorsArray(colorName, colorTables);
|
|
62
|
+
colorsArray(colorName, colorTables);
|
|
60
63
|
|
|
61
64
|
// Update color of legend based on color selector scales
|
|
62
65
|
// data is passed on click upon color scales
|
|
63
|
-
if (updateLegend) {
|
|
66
|
+
if (updateLegend && Object.keys(updateLegend).length > 0) {
|
|
64
67
|
// legend using color table data
|
|
65
68
|
if (updateLegend.color) {
|
|
66
69
|
legendColors = updateLegend.color;
|
|
@@ -70,9 +73,19 @@ export const ContinuousLegend: React.FC<legendProps> = ({
|
|
|
70
73
|
legendColors = updateLegend.arrayData;
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
|
-
// main continuous legend
|
|
76
|
+
// main continuous legend for colortable colors
|
|
77
|
+
if (legendColors.length > 0) {
|
|
78
|
+
legendColors = legendColors
|
|
79
|
+
}
|
|
80
|
+
// main continuous legend for d3 colors
|
|
74
81
|
else {
|
|
75
|
-
|
|
82
|
+
const arrayData: any = []
|
|
83
|
+
const d3ColorArrays = colorsArray(colorName, d3ColorScales)
|
|
84
|
+
const data = range(10).map((d) => ({color: d3ColorArrays(d / 10)}));
|
|
85
|
+
data.forEach((colorsObject: any, index: number) => {
|
|
86
|
+
arrayData.push([0 + "." + index, color(colorsObject.color)?.rgb().r, color(colorsObject.color)?.rgb().g, color(colorsObject.color)?.rgb().b])
|
|
87
|
+
});
|
|
88
|
+
legendColors = arrayData
|
|
76
89
|
}
|
|
77
90
|
|
|
78
91
|
legendColors.forEach((value: [number, number, number, number]) => {
|