@emerson-eps/color-tables 0.2.3 → 0.2.4
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.d.ts +2 -0
- package/dist/component/ColorSelector/{ColorTableSelectorWrapper.js → ColorSelectorAccordion.js} +12 -7
- package/dist/component/ColorSelector/ColorSelectorAccordion.js.map +1 -0
- package/dist/component/ColorSelector/ColorSelectorComponent.d.ts +12 -3
- package/dist/component/ColorSelector/ColorSelectorComponent.js +254 -51
- package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
- package/dist/component/ColorSelector/ColorSelectorWrapper.d.ts +8 -0
- package/dist/component/ColorSelector/ColorSelectorWrapper.js +64 -0
- package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -0
- package/dist/component/Legend/ColorLegend.d.ts +13 -0
- package/dist/component/Legend/ColorLegend.js +26 -0
- package/dist/component/Legend/ColorLegend.js.map +1 -0
- package/dist/component/Legend/ContinuousLegend.d.ts +1 -0
- package/dist/component/Legend/ContinuousLegend.js +147 -75
- package/dist/component/Legend/ContinuousLegend.js.map +1 -1
- package/dist/component/Legend/DiscreteLegend.d.ts +2 -0
- package/dist/component/Legend/DiscreteLegend.js +118 -62
- package/dist/component/Legend/DiscreteLegend.js.map +1 -1
- package/dist/component/Utils/discreteLegend.d.ts +1 -1
- package/dist/component/Utils/discreteLegend.js +70 -50
- package/dist/component/Utils/discreteLegend.js.map +1 -1
- package/dist/component/color-tables.json +4 -4
- package/dist/stories/ColorLegends/ColorSelector/Selector.stories.d.ts +2 -2
- package/dist/stories/ColorLegends/ColorSelector/Selector.stories.js +3 -3
- package/dist/stories/ColorLegends/ColorSelector/Selector.stories.js.map +1 -1
- package/dist/stories/ColorLegends/DiscreteLegends/Facies.stories.js +11 -11
- package/dist/stories/ColorLegends/DiscreteLegends/Facies.stories.js.map +1 -1
- package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.js +1 -1
- package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.js.map +1 -1
- package/dist/stories/ColorLegends/LegendWithSelector/DiscreteLegendWithSelector.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/LegendWithSelector/DiscreteLegendWithSelector.stories.js +41 -0
- package/dist/stories/ColorLegends/LegendWithSelector/DiscreteLegendWithSelector.stories.js.map +1 -0
- package/dist/stories/ColorLegends/LegendWithSelector/LegendWithSelector.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/LegendWithSelector/LegendWithSelector.stories.js +27 -0
- package/dist/stories/ColorLegends/LegendWithSelector/LegendWithSelector.stories.js.map +1 -0
- package/dist/stories/ColorLegends/SingleComponent/Single.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/SingleComponent/Single.stories.js +47 -0
- package/dist/stories/ColorLegends/SingleComponent/Single.stories.js.map +1 -0
- package/package.json +1 -1
- package/src/component/ColorSelector/{ColorTableSelectorWrapper.tsx → ColorSelectorAccordion.tsx} +11 -6
- package/src/component/ColorSelector/ColorSelectorComponent.tsx +308 -93
- package/src/component/ColorSelector/ColorSelectorWrapper.tsx +118 -0
- package/src/component/Legend/ColorLegend.tsx +81 -0
- package/src/component/Legend/ContinuousLegend.tsx +160 -79
- package/src/component/Legend/DiscreteLegend.tsx +127 -61
- package/src/component/Utils/continousLegend.ts +1 -1
- package/src/component/Utils/discreteLegend.ts +77 -52
- package/src/component/color-tables.json +4 -4
- package/src/stories/ColorLegends/ColorSelector/Selector.stories.jsx +3 -3
- package/src/stories/ColorLegends/DiscreteLegends/Facies.stories.jsx +39 -39
- package/src/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.jsx +1 -1
- package/src/stories/ColorLegends/LegendWithSelector/DiscreteLegendWithSelector.stories.jsx +44 -0
- package/src/stories/ColorLegends/LegendWithSelector/LegendWithSelector.stories.jsx +30 -0
- package/src/stories/ColorLegends/SingleComponent/Single.stories.jsx +51 -0
- package/dist/component/ColorSelector/ColorTableSelectorWrapper.d.ts +0 -2
- package/dist/component/ColorSelector/ColorTableSelectorWrapper.js.map +0 -1
- package/dist/component/ColorSelector/legendComponent.d.ts +0 -14
- package/dist/component/ColorSelector/legendComponent.js +0 -228
- package/dist/component/ColorSelector/legendComponent.js.map +0 -1
- package/src/component/ColorSelector/legendComponent.tsx +0 -289
package/dist/component/ColorSelector/{ColorTableSelectorWrapper.js → ColorSelectorAccordion.js}
RENAMED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Accordion } from "@equinor/eds-core-react";
|
|
3
|
-
import {
|
|
4
|
-
export const
|
|
5
|
-
return (React.createElement("div", { style: { width: "
|
|
3
|
+
import { ColorSelectorWrapper } from "./ColorSelectorWrapper";
|
|
4
|
+
export const ColorSelectorAccordion = (props) => {
|
|
5
|
+
return (React.createElement("div", { className: "Container", style: { width: "316px",
|
|
6
|
+
position: "absolute",
|
|
7
|
+
zIndex: 1,
|
|
8
|
+
top: 150,
|
|
9
|
+
right: 5,
|
|
10
|
+
} },
|
|
6
11
|
React.createElement(Accordion, null,
|
|
7
|
-
React.createElement(Accordion.Item,
|
|
12
|
+
React.createElement(Accordion.Item, { isExpanded: true },
|
|
8
13
|
React.createElement(Accordion.Header, null, "Color Scales"),
|
|
9
14
|
React.createElement(Accordion.Panel, null,
|
|
10
15
|
React.createElement(Accordion, null,
|
|
11
16
|
React.createElement(Accordion.Item, null,
|
|
12
17
|
React.createElement(Accordion.Header, null, "Geologic Color Scale"),
|
|
13
18
|
React.createElement(Accordion.Panel, null,
|
|
14
|
-
React.createElement(
|
|
19
|
+
React.createElement(ColorSelectorWrapper, { useColorTableColors: true, useD3Colors: false, colorScaleObject: props })))),
|
|
15
20
|
React.createElement(Accordion, null,
|
|
16
21
|
React.createElement(Accordion.Item, null,
|
|
17
22
|
React.createElement(Accordion.Header, null, "D3 Color Scale"),
|
|
18
23
|
React.createElement(Accordion.Panel, null,
|
|
19
|
-
React.createElement(
|
|
24
|
+
React.createElement(ColorSelectorWrapper, { useD3Colors: true, useColorTableColors: false, colorScaleObject: props })))),
|
|
20
25
|
React.createElement(Accordion, null,
|
|
21
26
|
React.createElement(Accordion.Item, null,
|
|
22
27
|
React.createElement(Accordion.Header, null, "Custom Color Scale"),
|
|
23
28
|
React.createElement(Accordion.Panel, null, "Custom Content"))))))));
|
|
24
29
|
};
|
|
25
|
-
//# sourceMappingURL=
|
|
30
|
+
//# sourceMappingURL=ColorSelectorAccordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSelectorAccordion.js","sourceRoot":"","sources":["../../../src/component/ColorSelector/ColorSelectorAccordion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAG,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAU,EAAE,EAAE;IACjD,OAAO,CACH,6BAAK,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO;YACjD,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,CAAC;YACT,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,CAAC;SACP;QACG,oBAAC,SAAS;YACN,oBAAC,SAAS,CAAC,IAAI,IAAC,UAAU;gBACtB,oBAAC,SAAS,CAAC,MAAM,uBAEE;gBACnB,oBAAC,SAAS,CAAC,KAAK;oBACZ,oBAAC,SAAS;wBACN,oBAAC,SAAS,CAAC,IAAI;4BACX,oBAAC,SAAS,CAAC,MAAM,+BAEE;4BACnB,oBAAC,SAAS,CAAC,KAAK;gCACZ,oBAAC,oBAAoB,IAAC,mBAAmB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,GAAG,CACjF,CACL,CACT;oBACZ,oBAAC,SAAS;wBACN,oBAAC,SAAS,CAAC,IAAI;4BACX,oBAAC,SAAS,CAAC,MAAM,yBAEE;4BACnB,oBAAC,SAAS,CAAC,KAAK;gCACZ,oBAAC,oBAAoB,IAAC,WAAW,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,GAAG,CACjF,CACL,CACT;oBACZ,oBAAC,SAAS;wBACN,oBAAC,SAAS,CAAC,IAAI;4BACX,oBAAC,SAAS,CAAC,MAAM,6BAEE;4BACnB,oBAAC,SAAS,CAAC,KAAK,yBAEE,CACL,CACT,CACE,CACL,CACT,CACV,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { colorTablesArray } from "../ColorTableTypes";
|
|
2
3
|
interface legendProps {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
position: number[];
|
|
5
|
+
colorsObject?: any;
|
|
6
|
+
legendColor?: any;
|
|
7
|
+
legendColorName?: string | undefined;
|
|
8
|
+
useContColorTable?: boolean;
|
|
9
|
+
useDiscColorTable?: boolean;
|
|
10
|
+
valueIndex?: any;
|
|
11
|
+
colorScaleData: any;
|
|
12
|
+
getColorMapname?: any | null;
|
|
5
13
|
}
|
|
6
|
-
export declare const
|
|
14
|
+
export declare const ColorSelectorComponent: React.FC<legendProps>;
|
|
15
|
+
export declare function colorTableData(colorName: string, colorTables: colorTablesArray): [number, number, number, number][];
|
|
7
16
|
export {};
|
|
@@ -1,62 +1,265 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { RGBToHex } from "../Utils/continousLegend";
|
|
3
4
|
import { d3ColorScales } from "../Utils/d3ColorScale";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
5
|
+
import { select, range } from "d3";
|
|
6
|
+
import * as d3 from "d3";
|
|
7
|
+
import discreteLegendUtil from "../Utils/discreteLegend";
|
|
8
|
+
import { color } from "d3-color";
|
|
9
|
+
export const ColorSelectorComponent = ({
|
|
10
|
+
// position,
|
|
11
|
+
colorsObject, legendColor, legendColorName, useContColorTable, useDiscColorTable, valueIndex, colorScaleData,
|
|
12
|
+
// getColorMapname,
|
|
13
|
+
}) => {
|
|
14
|
+
const divRef = useRef(null);
|
|
15
|
+
// create an array of steps based on the color scale
|
|
16
|
+
// returns an array of evenly-spaced numbers. Returns the integers from zero to the specified end minus one.
|
|
17
|
+
// d3.range(start, stop, step)
|
|
18
|
+
if (legendColor) {
|
|
19
|
+
var data = range(10).map(d => ({ color: legendColor(d / 10), value: d }));
|
|
20
|
+
// get the array's min and max value
|
|
21
|
+
var extent = d3.extent(data, d => d.value);
|
|
22
|
+
}
|
|
23
|
+
const handleChange = React.useCallback(() => {
|
|
24
|
+
// continous legend with colortable colors
|
|
25
|
+
if (colorsObject && Object.keys(colorsObject).length > 0 && useContColorTable) {
|
|
26
|
+
colorScaleData(colorsObject, true);
|
|
27
|
+
}
|
|
28
|
+
// continous legend with d3 colors
|
|
29
|
+
else if (data && !useContColorTable) {
|
|
30
|
+
let arrayData = [];
|
|
31
|
+
data.forEach((colorsObject) => {
|
|
32
|
+
var _a, _b, _c;
|
|
33
|
+
arrayData.push([0 + "." + colorsObject.value, (_a = color(colorsObject.color)) === null || _a === void 0 ? void 0 : _a.rgb().r, (_b = color(colorsObject.color)) === null || _b === void 0 ? void 0 : _b.rgb().g, (_c = color(colorsObject.color)) === null || _c === void 0 ? void 0 : _c.rgb().b]);
|
|
34
|
+
});
|
|
35
|
+
colorScaleData(arrayData, true);
|
|
36
|
+
}
|
|
37
|
+
// discrete legend with colortable colors
|
|
38
|
+
else if (colorsObject && Object.keys(colorsObject).length > 0 && useDiscColorTable) {
|
|
39
|
+
colorScaleData(colorsObject, false);
|
|
40
|
+
}
|
|
41
|
+
// discrete legend with d3 colors
|
|
42
|
+
else {
|
|
43
|
+
colorScaleData({ colorsObject, legendColorName }, false);
|
|
44
|
+
}
|
|
45
|
+
}, []);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
// continuous legend using color table colors
|
|
48
|
+
if (useContColorTable == true && divRef.current) {
|
|
49
|
+
contColortableLegend();
|
|
50
|
+
return function cleanup() {
|
|
51
|
+
select(divRef.current).select("svg").remove();
|
|
52
|
+
select(divRef.current).select("div").remove();
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// discrete legend using color table colors
|
|
56
|
+
if (useDiscColorTable == true && divRef.current) {
|
|
57
|
+
discColorTableLegend();
|
|
58
|
+
return function cleanup() {
|
|
59
|
+
select(divRef.current).select("div").remove();
|
|
60
|
+
select(divRef.current).select("svg").remove();
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// discrete legend using d3 colors
|
|
64
|
+
if (useDiscColorTable == false && divRef.current) {
|
|
65
|
+
discD3legend();
|
|
66
|
+
return function cleanup() {
|
|
67
|
+
select(divRef.current).select("div").remove();
|
|
68
|
+
select(divRef.current).select("svg").remove();
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// continuous legend using d3 colors
|
|
72
|
+
else if (useContColorTable == false && divRef.current) {
|
|
73
|
+
contD3Legend();
|
|
74
|
+
return function cleanup() {
|
|
75
|
+
select(divRef.current).select("svg").remove();
|
|
76
|
+
select(divRef.current).select("div").remove();
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}, [useContColorTable]);
|
|
80
|
+
// continuous legend using color table colors (using linear gradiend)
|
|
81
|
+
function contColortableLegend() {
|
|
82
|
+
const itemColor = [];
|
|
83
|
+
colorsObject.color.forEach((value) => {
|
|
84
|
+
// return the color and offset needed to draw the legend
|
|
85
|
+
itemColor.push({
|
|
86
|
+
offset: RGBToHex(value).offset,
|
|
87
|
+
color: RGBToHex(value).color,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
// append a defs (for definition) element to your SVG
|
|
91
|
+
const svgLegend = select(divRef.current)
|
|
92
|
+
.append("svg")
|
|
93
|
+
.style("height", "30px");
|
|
94
|
+
const defs = svgLegend.append("defs");
|
|
95
|
+
let currentIndex = "linear-gradient-" + valueIndex;
|
|
96
|
+
// append a linearGradient element to the defs and give it a unique id
|
|
97
|
+
const linearGradient = defs
|
|
98
|
+
.append("linearGradient")
|
|
99
|
+
.attr("id", currentIndex)
|
|
100
|
+
.attr("x1", "0%")
|
|
101
|
+
.attr("x2", "100%") //since it's a horizontal linear gradient
|
|
102
|
+
.attr("y1", "0%")
|
|
103
|
+
.attr("y2", "0%");
|
|
104
|
+
// append multiple color stops by using D3's data/enter step
|
|
105
|
+
linearGradient
|
|
106
|
+
.selectAll("stop")
|
|
107
|
+
.data(itemColor)
|
|
108
|
+
.enter()
|
|
109
|
+
.append("stop")
|
|
110
|
+
.attr("offset", function (data) {
|
|
111
|
+
return data.offset + "%";
|
|
112
|
+
})
|
|
113
|
+
.attr("stop-color", function (data) {
|
|
114
|
+
return data.color;
|
|
45
115
|
});
|
|
46
|
-
|
|
47
|
-
|
|
116
|
+
// append title
|
|
117
|
+
svgLegend
|
|
118
|
+
.append("text")
|
|
119
|
+
.attr("id", "legendTitle")
|
|
120
|
+
.attr("x", 0)
|
|
121
|
+
.attr("y", 15)
|
|
122
|
+
.style("font-size", "smaller")
|
|
123
|
+
.style("font-weight", "900")
|
|
124
|
+
// .attr("textLength","5em")
|
|
125
|
+
.text(colorsObject.name);
|
|
126
|
+
// draw the rectangle and fill with gradient
|
|
127
|
+
svgLegend
|
|
128
|
+
.append("rect")
|
|
129
|
+
.attr("x", 85)
|
|
130
|
+
.attr("y", 5)
|
|
131
|
+
.attr("width", "110")
|
|
132
|
+
.attr("height", 20)
|
|
133
|
+
.style("fill", "url(#" + currentIndex + ")");
|
|
134
|
+
}
|
|
135
|
+
// continuous legend using d3 colors (using linear gradiend)
|
|
136
|
+
function contD3Legend() {
|
|
137
|
+
const itemColor = [];
|
|
138
|
+
d3ColorScales.forEach((value) => {
|
|
139
|
+
// return the color and offset needed to draw the legend
|
|
140
|
+
itemColor.push(value.colors);
|
|
48
141
|
});
|
|
142
|
+
// append a defs (for definition) element to your SVG
|
|
143
|
+
const svgLegend = select(divRef.current)
|
|
144
|
+
.append("svg")
|
|
145
|
+
.style("height", "50px");
|
|
146
|
+
const defs = svgLegend.append("defs");
|
|
147
|
+
let currentIndex = "linear-gradient-" + valueIndex;
|
|
148
|
+
// append a linearGradient element to the defs and give it a unique id
|
|
149
|
+
const linearGradient = defs
|
|
150
|
+
.append("linearGradient")
|
|
151
|
+
.attr("id", currentIndex)
|
|
152
|
+
.attr("x1", "0%")
|
|
153
|
+
.attr("x2", "100%") //since it's a horizontal linear gradient
|
|
154
|
+
.attr("y1", "0%")
|
|
155
|
+
.attr("y2", "0%");
|
|
156
|
+
// append multiple color stops by using D3's data/enter step
|
|
157
|
+
linearGradient.selectAll("stop")
|
|
158
|
+
.data(data)
|
|
159
|
+
.enter().append("stop")
|
|
160
|
+
.attr("offset", d => ((d.value - extent[0]) / (extent[1] - extent[0]) * 100) + "%")
|
|
161
|
+
.attr("stop-color", d => d.color);
|
|
162
|
+
// append title
|
|
163
|
+
svgLegend
|
|
164
|
+
.append("text")
|
|
165
|
+
.attr("id", "legendTitle")
|
|
166
|
+
.attr("x", 0)
|
|
167
|
+
.attr("y", 15)
|
|
168
|
+
.style("font-size", "smaller")
|
|
169
|
+
.style("font-weight", "900")
|
|
170
|
+
.text(legendColorName ? legendColorName : '');
|
|
171
|
+
// draw the rectangle and fill with gradient
|
|
172
|
+
svgLegend
|
|
173
|
+
.append("rect")
|
|
174
|
+
.attr("x", 85)
|
|
175
|
+
.attr("y", 5)
|
|
176
|
+
.attr("width", "110")
|
|
177
|
+
.attr("height", 20)
|
|
178
|
+
.style("fill", "url(#" + currentIndex + ")");
|
|
49
179
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
180
|
+
// discrete legend using color table colors
|
|
181
|
+
function discColorTableLegend() {
|
|
182
|
+
const itemColor = [];
|
|
183
|
+
const itemName = [];
|
|
184
|
+
colorsObject.color.forEach((element, key) => {
|
|
185
|
+
itemColor.push({ color: RGBToHex(element) });
|
|
186
|
+
itemName.push(key);
|
|
53
187
|
});
|
|
54
|
-
|
|
55
|
-
|
|
188
|
+
function RGBToHex(rgb) {
|
|
189
|
+
let r = rgb[1].toString(16), g = rgb[2].toString(16), b = rgb[3].toString(16);
|
|
190
|
+
if (r.length == 1)
|
|
191
|
+
r = "0" + r;
|
|
192
|
+
if (g.length == 1)
|
|
193
|
+
g = "0" + g;
|
|
194
|
+
if (b.length == 1)
|
|
195
|
+
b = "0" + b;
|
|
196
|
+
return "#" + r + g + b;
|
|
197
|
+
}
|
|
198
|
+
//const ordinalValues = scaleOrdinal().domain(itemName);
|
|
199
|
+
let count = itemName.length;
|
|
200
|
+
const colorLegend = discreteLegendUtil(itemColor, true);
|
|
201
|
+
//const calcLegendHeight = 22 * itemColor.length + 4 * itemColor.length;
|
|
202
|
+
const selectedLegend = select(divRef.current);
|
|
203
|
+
// colorname as label for the legend (ex: facies)
|
|
204
|
+
selectedLegend
|
|
205
|
+
.append("label")
|
|
206
|
+
.text(legendColorName ? legendColorName : '')
|
|
207
|
+
.attr("y", 7)
|
|
208
|
+
.style("float", "left")
|
|
209
|
+
.style("width", "15px")
|
|
210
|
+
.style("margin", "10px 0px")
|
|
211
|
+
.style("white-space", "nowrap")
|
|
212
|
+
.style("font-size", "smaller")
|
|
213
|
+
.style("font-weight", "900");
|
|
214
|
+
selectedLegend
|
|
215
|
+
.append("svg")
|
|
216
|
+
.style("margin-top", "13px")
|
|
217
|
+
.style("margin-left", "70px")
|
|
218
|
+
.attr("viewBox", `0 0 ${count} 1`)
|
|
219
|
+
.attr("preserveAspectRatio", "none")
|
|
220
|
+
.style("width", "109px")
|
|
221
|
+
.style("height", "20px")
|
|
222
|
+
.call(colorLegend);
|
|
223
|
+
}
|
|
224
|
+
// discrete legend using d3 colors
|
|
225
|
+
function discD3legend() {
|
|
226
|
+
const itemName = [];
|
|
227
|
+
const itemColor = [];
|
|
228
|
+
colorsObject.forEach((element, key) => {
|
|
229
|
+
itemColor.push({ color: element });
|
|
230
|
+
itemName.push(key);
|
|
56
231
|
});
|
|
232
|
+
//const ordinalValues = scaleOrdinal(colorsObject).domain(itemName);
|
|
233
|
+
let count = itemName.length;
|
|
234
|
+
const discreteLegend = discreteLegendUtil(itemColor, true);
|
|
235
|
+
select("svg").append("g").attr("transform", "translate(50,70)").attr("class", "legend").call(discreteLegend);
|
|
236
|
+
const selectedLegend = select(divRef.current);
|
|
237
|
+
selectedLegend
|
|
238
|
+
.append("text")
|
|
239
|
+
.text(legendColorName ? legendColorName : '')
|
|
240
|
+
.attr("y", 7)
|
|
241
|
+
.style("float", "left")
|
|
242
|
+
.style("width", "15px")
|
|
243
|
+
.style("margin", "10px 0px")
|
|
244
|
+
.style("font-size", "smaller")
|
|
245
|
+
.style("font-weight", "900");
|
|
246
|
+
selectedLegend
|
|
247
|
+
.append("svg")
|
|
248
|
+
.style("margin-top", "13px")
|
|
249
|
+
.style("margin-left", "70px")
|
|
250
|
+
.style("background", "grey")
|
|
251
|
+
.attr("viewBox", `0 0 ${count} 1`)
|
|
252
|
+
.attr("preserveAspectRatio", "none")
|
|
253
|
+
.style("width", "109px")
|
|
254
|
+
.style("height", "20px")
|
|
255
|
+
.call(discreteLegend);
|
|
57
256
|
}
|
|
58
257
|
return (React.createElement("div", null,
|
|
59
|
-
|
|
60
|
-
discreteLegend));
|
|
258
|
+
React.createElement("div", { id: "legend", style: { height: 30 }, ref: divRef, onClick: handleChange })));
|
|
61
259
|
};
|
|
260
|
+
// Based on name return the colors array from color.tables.json file
|
|
261
|
+
export function colorTableData(colorName, colorTables) {
|
|
262
|
+
const colorTableData = colorTables.filter((value) => value.name.toLowerCase() == colorName.toLowerCase());
|
|
263
|
+
return colorTableData.length > 0 ? colorTableData[0].colors : [];
|
|
264
|
+
}
|
|
62
265
|
//# sourceMappingURL=ColorSelectorComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorSelectorComponent.js","sourceRoot":"","sources":["../../../src/component/ColorSelector/ColorSelectorComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"ColorSelectorComponent.js","sourceRoot":"","sources":["../../../src/component/ColorSelector/ColorSelectorComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAC,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAmBjC,MAAM,CAAC,MAAM,sBAAsB,GAA0B,CAAC;AAC1D,YAAY;AACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,iBAAiB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AAQ,EAAE,UAAU,CAAC;aAC3B,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC;aAC7B,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACjC,cAAc;aACT,MAAM,CAAC,KAAK,CAAC;aACb,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC;aAC3B,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC;aAC5B,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC;aAC3B,IAAI,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;aACjC,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC;aAEnC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;aACvB,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;aACvB,IAAI,CAAC,cAAc,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CACH;QACI,6BAAK,EAAE,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAC,MAAM,EAAE,EAAE,EAAC,EAChC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAQ,CAC5C,CACT,CAAC;AACN,CAAC,CAAC;AAEF,oEAAoE;AACpE,MAAM,UAAU,cAAc,CAC1B,SAAiB,EACjB,WAA6B;IAE7B,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CACrC,CAAC,KAAqB,EAAE,EAAE,CACtB,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC,WAAW,EAAE,CAC1D,CAAC;IACF,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as colorTables from "../color-tables.json";
|
|
3
|
+
import { d3ColorScales } from "../Utils/d3ColorScale";
|
|
4
|
+
import { ColorSelectorComponent } from "./ColorSelectorComponent";
|
|
5
|
+
const position = [16, 206];
|
|
6
|
+
const continuosColorData = [];
|
|
7
|
+
const continuosD3ColorData = [];
|
|
8
|
+
const discreteColorData = [];
|
|
9
|
+
const discreteD3ColorData = [];
|
|
10
|
+
// Continuous legend using color table data
|
|
11
|
+
var colorTableContinuousData = colorTables.filter((element) => {
|
|
12
|
+
return element.discrete == false;
|
|
13
|
+
});
|
|
14
|
+
colorTableContinuousData.forEach((element) => {
|
|
15
|
+
continuosColorData.push({ color: element.colors, name: element.name });
|
|
16
|
+
});
|
|
17
|
+
// Continuous legend using d3 data
|
|
18
|
+
var d3continuousData = d3ColorScales.filter((element) => {
|
|
19
|
+
return element.discrete == false;
|
|
20
|
+
});
|
|
21
|
+
d3continuousData.forEach((element) => {
|
|
22
|
+
continuosD3ColorData.push({ color: element.colors, name: element.name });
|
|
23
|
+
});
|
|
24
|
+
// Discrete legend using color table data
|
|
25
|
+
var discreteData = colorTables.filter((element) => {
|
|
26
|
+
return element.discrete == true;
|
|
27
|
+
});
|
|
28
|
+
discreteData.forEach((element) => {
|
|
29
|
+
discreteColorData.push({ color: element.colors, name: element.name });
|
|
30
|
+
});
|
|
31
|
+
// Discrete legend using d3 data
|
|
32
|
+
var d3discreteData = d3ColorScales.filter((element) => {
|
|
33
|
+
return element.discrete == true;
|
|
34
|
+
});
|
|
35
|
+
d3discreteData.forEach((element) => {
|
|
36
|
+
discreteD3ColorData.push({ color: element.colors, name: element.name });
|
|
37
|
+
});
|
|
38
|
+
export const ColorSelectorWrapper = ({ useColorTableColors, useD3Colors, colorScaleObject, }) => {
|
|
39
|
+
let continuousLegend;
|
|
40
|
+
let discreteLegend;
|
|
41
|
+
// return continuous and discrete legend which uses colortable data
|
|
42
|
+
if (useColorTableColors) {
|
|
43
|
+
continuousLegend = continuosColorData.map((value, key) => {
|
|
44
|
+
return React.createElement("div", null,
|
|
45
|
+
React.createElement(ColorSelectorComponent, { position: position + key, colorsObject: value, useContColorTable: true, valueIndex: key, colorScaleData: colorScaleObject.colorScaleObject }));
|
|
46
|
+
});
|
|
47
|
+
discreteLegend = discreteColorData.map((val, key) => {
|
|
48
|
+
return React.createElement(ColorSelectorComponent, { position: position + key, colorsObject: discreteColorData[key], legendColorName: val.name, useDiscColorTable: true, colorScaleData: colorScaleObject.colorScaleObject });
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// return continuous and discrete legend which uses d3 data
|
|
52
|
+
if (useD3Colors) {
|
|
53
|
+
continuousLegend = continuosD3ColorData.map((val, key) => {
|
|
54
|
+
return React.createElement(ColorSelectorComponent, { position: position + key, legendColor: val.color, legendColorName: val.name, useContColorTable: false, valueIndex: key + "0", colorScaleData: colorScaleObject.colorScaleObject });
|
|
55
|
+
});
|
|
56
|
+
discreteLegend = d3discreteData.map((val, key) => {
|
|
57
|
+
return React.createElement(ColorSelectorComponent, { position: position + key, colorsObject: val.colors, legendColorName: val.name, useDiscColorTable: false, colorScaleData: colorScaleObject.colorScaleObject });
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return (React.createElement("div", { className: "legendWrapper", style: { height: 200, overflow: "auto", display: "flex", flexDirection: "column", overflowX: "hidden" } },
|
|
61
|
+
continuousLegend,
|
|
62
|
+
discreteLegend));
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=ColorSelectorWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSelectorWrapper.js","sourceRoot":"","sources":["../../../src/component/ColorSelector/ColorSelectorWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAEhE,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3B,MAAM,kB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C3D,IAAI,WAAW,EAAE;QACb,gBAAgB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,GAAQ,EAAE,EAAE;YAC/D,OAAO,oBAAC,sBAAsB,IAClB,QAAQ,EAAE,QAAQ,GAAG,GAAG,EACxB,WAAW,EAAE,GAAG,CAAC,KAAK,EACtB,eAAe,EAAE,GAAG,CAAC,IAAI,EACzB,iBAAiB,EAAE,KAAK,EACxB,UAAU,EAAE,GAAG,GAAG,GAAG,EACrB,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,GAC3D,CAAA;QACN,CAAC,CAAC,CAAC;QAEH,cAAc,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,GAAQ,EAAE,EAAE;YACvD,OAAO,oBAAC,sBAAsB,IAClB,QAAQ,EAAE,QAAQ,GAAG,GAAG,EACxB,YAAY,EAAE,GAAG,CAAC,MAAM,EACxB,eAAe,EAAE,GAAG,CAAC,IAAI,EACzB,iBAAiB,EAAE,KAAK,EACxB,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,GACnD,CAAA;QACd,CAAC,CAAC,CAAC;KACN;IAED,OAAO,CACH,6BAAK,SAAS,EAAC,eAAe,EAC1B,KAAK,EAAE,EAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAC;QAEpG,gBAAgB;QAChB,cAAc,CACb,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
interface ColorLegendProps {
|
|
3
|
+
colorTables: any;
|
|
4
|
+
min: number;
|
|
5
|
+
max: number;
|
|
6
|
+
dataObjectName: string;
|
|
7
|
+
position?: number[] | null;
|
|
8
|
+
colorName: string;
|
|
9
|
+
horizontal?: boolean | null;
|
|
10
|
+
discreteData: any;
|
|
11
|
+
}
|
|
12
|
+
declare const ColorLegend: React.FC<ColorLegendProps>;
|
|
13
|
+
export default ColorLegend;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DiscreteColorLegend } from "./DiscreteLegend";
|
|
3
|
+
import { ContinuousLegend } from "./ContinuousLegend";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
import { ColorSelectorAccordion } from "../ColorSelector/ColorSelectorAccordion";
|
|
6
|
+
// Todo: Adapt it for other layers too
|
|
7
|
+
const ColorLegend = ({ position, horizontal, colorTables, min, max, dataObjectName, colorName, discreteData }) => {
|
|
8
|
+
const [isToggled, setIsToggled] = React.useState(false);
|
|
9
|
+
const handleClick = useCallback(() => {
|
|
10
|
+
setIsToggled(true);
|
|
11
|
+
}, []);
|
|
12
|
+
const [updateLegend, setUpdateLegendColor] = React.useState([]);
|
|
13
|
+
const [isCont, setIsCont] = React.useState(true);
|
|
14
|
+
// Get new colorscale from colorselector and update legend
|
|
15
|
+
const colorScaleObject = React.useCallback((data, value) => {
|
|
16
|
+
setUpdateLegendColor(data);
|
|
17
|
+
setIsCont(value);
|
|
18
|
+
}, []);
|
|
19
|
+
return (React.createElement("div", null,
|
|
20
|
+
React.createElement("div", { onClick: handleClick },
|
|
21
|
+
isCont && (React.createElement(ContinuousLegend, { min: min, max: max, dataObjectName: dataObjectName, position: position, colorName: colorName, colorTables: colorTables, horizontal: horizontal, updateLegend: updateLegend })),
|
|
22
|
+
!isCont && (React.createElement(DiscreteColorLegend, { discreteData: discreteData, dataObjectName: dataObjectName, position: position, colorName: colorName, colorTables: colorTables, horizontal: horizontal, updateLegend: updateLegend }))),
|
|
23
|
+
React.createElement("div", null, isToggled && (React.createElement(ColorSelectorAccordion, { colorScaleObject: colorScaleObject })))));
|
|
24
|
+
};
|
|
25
|
+
export default ColorLegend;
|
|
26
|
+
//# sourceMappingURL=ColorLegend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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