@emerson-eps/color-tables 0.2.11 → 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/ColorSelectorWrapper.d.ts +0 -1
- package/dist/component/ColorSelector/ColorSelectorWrapper.js +5 -4
- package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -1
- package/dist/component/Legend/ColorLegend.js +11 -3
- package/dist/component/Legend/ColorLegend.js.map +1 -1
- package/dist/component/Legend/ContinuousLegend.js +18 -4
- package/dist/component/Legend/ContinuousLegend.js.map +1 -1
- package/dist/component/Legend/DiscreteLegend.js +22 -9
- package/dist/component/Legend/DiscreteLegend.js.map +1 -1
- package/dist/component/Utils/continousLegend.d.ts +1 -1
- package/dist/component/Utils/continousLegend.js.map +1 -1
- package/dist/stories/ColorLegends/SingleComponent/Single.stories.js +1 -1
- package/package.json +1 -1
- package/src/component/ColorSelector/ColorSelectorAccordion.tsx +2 -2
- package/src/component/ColorSelector/ColorSelectorWrapper.tsx +50 -50
- package/src/component/Legend/ColorLegend.tsx +20 -3
- package/src/component/Legend/ContinuousLegend.tsx +17 -4
- package/src/component/Legend/DiscreteLegend.tsx +24 -10
- package/src/component/Utils/continousLegend.ts +2 -2
- package/src/stories/ColorLegends/SingleComponent/Single.stories.jsx +1 -1
- package/tsconfig.json +2 -2
|
@@ -16,12 +16,12 @@ export var ColorSelectorAccordion = function (props) {
|
|
|
16
16
|
React.createElement(Accordion.Item, null,
|
|
17
17
|
React.createElement(Accordion.Header, null, "Geologic Color Scale"),
|
|
18
18
|
React.createElement(Accordion.Panel, null,
|
|
19
|
-
React.createElement(ColorSelectorWrapper, { useColorTableColors: true,
|
|
19
|
+
React.createElement(ColorSelectorWrapper, { useColorTableColors: true, colorScaleObject: props })))),
|
|
20
20
|
React.createElement(Accordion, null,
|
|
21
21
|
React.createElement(Accordion.Item, null,
|
|
22
22
|
React.createElement(Accordion.Header, null, "D3 Color Scale"),
|
|
23
23
|
React.createElement(Accordion.Panel, null,
|
|
24
|
-
React.createElement(ColorSelectorWrapper, {
|
|
24
|
+
React.createElement(ColorSelectorWrapper, { useColorTableColors: false, colorScaleObject: props })))),
|
|
25
25
|
React.createElement(Accordion, null,
|
|
26
26
|
React.createElement(Accordion.Item, null,
|
|
27
27
|
React.createElement(Accordion.Header, null, "Custom Color Scale"),
|
|
@@ -1 +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,IAAM,sBAAsB,GAAG,UAAC,KAAU;IAC7C,OAAO,CACH,6BAAK,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO;YACjD,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,CAAC;YACT,GAAG,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAClC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;SAClC;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,
|
|
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,IAAM,sBAAsB,GAAG,UAAC,KAAU;IAC7C,OAAO,CACH,6BAAK,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO;YACjD,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,CAAC;YACT,GAAG,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAClC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;SAClC;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,gBAAgB,EAAE,KAAK,GAAG,CAC7D,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,mBAAmB,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,GAAG,CAC9D,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,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
var colorTables = require("../color-tables.json");
|
|
3
3
|
import { d3ColorScales } from "../Utils/d3ColorScale";
|
|
4
4
|
import { ColorSelectorComponent } from "./ColorSelectorComponent";
|
|
5
5
|
var position = [16, 206];
|
|
@@ -36,11 +36,11 @@ d3discreteData.forEach(function (element) {
|
|
|
36
36
|
discreteD3ColorData.push({ color: element.colors, name: element.name });
|
|
37
37
|
});
|
|
38
38
|
export var ColorSelectorWrapper = function (_a) {
|
|
39
|
-
var useColorTableColors = _a.useColorTableColors,
|
|
39
|
+
var useColorTableColors = _a.useColorTableColors, colorScaleObject = _a.colorScaleObject;
|
|
40
40
|
var continuousLegend;
|
|
41
41
|
var discreteLegend;
|
|
42
42
|
// return continuous and discrete legend which uses d3 data
|
|
43
|
-
if (
|
|
43
|
+
if (useColorTableColors) {
|
|
44
44
|
continuousLegend = continuosD3ColorData.map(function (val, key) {
|
|
45
45
|
return React.createElement(ColorSelectorComponent, { position: position + key, legendColor: val.color, legendColorName: val.name, useContColorTable: false, valueIndex: key + "0", colorScaleData: colorScaleObject.colorScaleObject });
|
|
46
46
|
});
|
|
@@ -49,7 +49,7 @@ export var ColorSelectorWrapper = function (_a) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
// return continuous and discrete legend which uses colortable data
|
|
52
|
-
if (useColorTableColors) {
|
|
52
|
+
else if (!useColorTableColors) {
|
|
53
53
|
continuousLegend = continuosColorData.map(function (value, key) {
|
|
54
54
|
return React.createElement("div", null,
|
|
55
55
|
React.createElement(ColorSelectorComponent, { position: position + key, colorsObject: value, useContColorTable: true, valueIndex: key, colorScaleData: colorScaleObject.colorScaleObject }));
|
|
@@ -58,6 +58,7 @@ export var ColorSelectorWrapper = function (_a) {
|
|
|
58
58
|
return React.createElement(ColorSelectorComponent, { position: position + key, colorsObject: discreteColorData[key], legendColorName: val.name, useDiscColorTable: true, colorScaleData: colorScaleObject.colorScaleObject });
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
//}
|
|
61
62
|
return (React.createElement("div", { className: "legendWrapper", style: { height: 200, overflow: "auto", display: "flex", flexDirection: "column", overflowX: "hidden" } },
|
|
62
63
|
continuousLegend,
|
|
63
64
|
discreteLegend));
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"ColorSelectorWrapper.js","sourceRoot":"","sources":["../../../src/component/ColorSelector/ColorSelectorWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,IAAM,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAEhE,IAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3B,IAAM,kBAAkB,GAAQ,EAAE,CAAC;AACnC,IAAM,oBAAoB,GAAQ,EAAE,CAAC;AACrC,IAAM,iBAAiB,GAAQ,EAAE,CAAC;AAClC,IAAM,mBAAmB,GAAQ,EAAE,CAAC;AAOpC,4CAA4C;AAC5C,IAAM,wBAAwB,GAAG,WAAW,CAAC,MAAM,CAAC,UAAC,OAAY;IAC7D,OAAO,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;AACrC,C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C,GAAG,CAAC,UAAC,GAAQ,EAAE,GAAQ;YACtD,OAAO,oBAAC,sBAAsB,IAClB,QAAQ,EAAE,QAAQ,GAAG,GAAG,EACxB,YAAY,EAAE,iBAAiB,CAAC,GAAG,CAAC,EACpC,eAAe,EAAE,GAAG,CAAC,IAAI,EACzB,iBAAiB,EAAE,IAAI,EACvB,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,GACnD,CAAA;QACd,CAAC,CAAC,CAAC;KACN;IACL,GAAG;IAEH,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"}
|
|
@@ -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
|
// Todo: Adapt it for other layers too
|
|
7
8
|
export var ColorLegend = function (_a) {
|
|
8
9
|
var position = _a.position, horizontal = _a.horizontal, colorTables = _a.colorTables, min = _a.min, max = _a.max, dataObjectName = _a.dataObjectName, colorName = _a.colorName, discreteData = _a.discreteData, getColorMapname = _a.getColorMapname;
|
|
@@ -11,7 +12,14 @@ export var ColorLegend = function (_a) {
|
|
|
11
12
|
setIsToggled(true);
|
|
12
13
|
}, []);
|
|
13
14
|
var _c = React.useState([]), updateLegend = _c[0], setUpdateLegendColor = _c[1];
|
|
14
|
-
var
|
|
15
|
+
var isColortableColors = colorTables.find(function (value) {
|
|
16
|
+
return (value === null || value === void 0 ? void 0 : value.name) == colorName;
|
|
17
|
+
});
|
|
18
|
+
var isD3Colors = d3ColorScales.find(function (value) {
|
|
19
|
+
return (value === null || value === void 0 ? void 0 : value.name) == colorName;
|
|
20
|
+
});
|
|
21
|
+
var _d = React.useState((isColortableColors || isD3Colors) &&
|
|
22
|
+
((isColortableColors === null || isColortableColors === void 0 ? void 0 : isColortableColors.discrete) == false || (isD3Colors === null || isD3Colors === void 0 ? void 0 : isD3Colors.discrete) == false) ? true : false), isCont = _d[0], setIsCont = _d[1];
|
|
15
23
|
// Get new colorscale from colorselector and update legend
|
|
16
24
|
var colorScaleObject = React.useCallback(function (data, value) {
|
|
17
25
|
// update color map layer
|
|
@@ -27,8 +35,8 @@ export var ColorLegend = function (_a) {
|
|
|
27
35
|
}, []);
|
|
28
36
|
return (React.createElement("div", null,
|
|
29
37
|
React.createElement("div", { onClick: handleClick },
|
|
30
|
-
isCont && (React.createElement(ContinuousLegend, { min: min, max: max, dataObjectName: dataObjectName, position: position, colorName: colorName, colorTables: colorTables, horizontal: horizontal, updateLegend: updateLegend })),
|
|
31
|
-
|
|
38
|
+
isCont == true && (React.createElement(ContinuousLegend, { min: min, max: max, dataObjectName: dataObjectName, position: position, colorName: colorName, colorTables: colorTables, horizontal: horizontal, updateLegend: updateLegend })),
|
|
39
|
+
isCont == false && (React.createElement(DiscreteColorLegend, { discreteData: discreteData, dataObjectName: dataObjectName, position: position, colorName: colorName, colorTables: colorTables, horizontal: horizontal, updateLegend: updateLegend }))),
|
|
32
40
|
React.createElement("div", null, isToggled && (React.createElement(ColorSelectorAccordion, { colorScaleObject: colorScaleObject, isHorizontal: horizontal })))));
|
|
33
41
|
};
|
|
34
42
|
//# sourceMappingURL=ColorLegend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/ColorLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,mBAA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AAY,EAAE,YAAY,GAC5B,CACL;YACA,MAAM,IAAI,KAAK,IAAI,CAChB,oBAAC,mBAAmB,IAChB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,GAC5B,CACL,CACC;QACN,iCACK,SAAS,IAAI,CACV,oBAAC,sBAAsB,IAAC,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,GAAI,CAC3F,CACC,CACJ,CAET,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -38,6 +38,9 @@ import * as React from "react";
|
|
|
38
38
|
import { useRef } from "react";
|
|
39
39
|
import { RGBToHex, colorsArray } from "../Utils/continousLegend";
|
|
40
40
|
import { select, scaleLinear, scaleSequential, axisBottom, axisRight } from "d3";
|
|
41
|
+
import { d3ColorScales } from "../Utils/d3ColorScale";
|
|
42
|
+
import { color } from "d3-color";
|
|
43
|
+
import { range } from "d3";
|
|
41
44
|
export var ContinuousLegend = function (_a) {
|
|
42
45
|
var min = _a.min, max = _a.max, dataObjectName = _a.dataObjectName, position = _a.position, colorName = _a.colorName, colorTables = _a.colorTables, horizontal = _a.horizontal, updateLegend = _a.updateLegend;
|
|
43
46
|
var divRef = useRef(null);
|
|
@@ -53,7 +56,7 @@ export var ContinuousLegend = function (_a) {
|
|
|
53
56
|
}, [min, max, colorName, colorTables, horizontal, updateLegend]);
|
|
54
57
|
function continuousLegend() {
|
|
55
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
var itemColor, dataSet, res, legendColors, colorScale, svgLegend, defs, linearGradient, xLeg, yLeg, horizontalAxisLeg, VerticalAxisLeg, error_1;
|
|
59
|
+
var itemColor, dataSet, res, legendColors, arrayData_1, d3ColorArrays_1, data, colorScale, svgLegend, defs, linearGradient, xLeg, yLeg, horizontalAxisLeg, VerticalAxisLeg, error_1;
|
|
57
60
|
return __generator(this, function (_a) {
|
|
58
61
|
switch (_a.label) {
|
|
59
62
|
case 0:
|
|
@@ -76,7 +79,7 @@ export var ContinuousLegend = function (_a) {
|
|
|
76
79
|
colorsArray(colorName, colorTables);
|
|
77
80
|
// Update color of legend based on color selector scales
|
|
78
81
|
// data is passed on click upon color scales
|
|
79
|
-
if (updateLegend) {
|
|
82
|
+
if (updateLegend && Object.keys(updateLegend).length > 0) {
|
|
80
83
|
// legend using color table data
|
|
81
84
|
if (updateLegend.color) {
|
|
82
85
|
legendColors = updateLegend.color;
|
|
@@ -86,9 +89,20 @@ export var ContinuousLegend = function (_a) {
|
|
|
86
89
|
legendColors = updateLegend.arrayData;
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
|
-
// main continuous legend
|
|
92
|
+
// main continuous legend for colortable colors
|
|
93
|
+
if (legendColors.length > 0) {
|
|
94
|
+
legendColors = legendColors;
|
|
95
|
+
}
|
|
96
|
+
// main continuous legend for d3 colors
|
|
90
97
|
else {
|
|
91
|
-
|
|
98
|
+
arrayData_1 = [];
|
|
99
|
+
d3ColorArrays_1 = colorsArray(colorName, d3ColorScales);
|
|
100
|
+
data = range(10).map(function (d) { return ({ color: d3ColorArrays_1(d / 10) }); });
|
|
101
|
+
data.forEach(function (colorsObject, index) {
|
|
102
|
+
var _a, _b, _c;
|
|
103
|
+
arrayData_1.push([0 + "." + index, (_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]);
|
|
104
|
+
});
|
|
105
|
+
legendColors = arrayData_1;
|
|
92
106
|
}
|
|
93
107
|
legendColors.forEach(function (value) {
|
|
94
108
|
// return the color and offset needed to draw the legend
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContinuousLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/ContinuousLegend.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,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ContinuousLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/ContinuousLegend.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,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEjF,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAkB3B,MAAM,CAAC,IAAM,gBAAgB,GAA0B,UAAC,EAS1C;QARV,GAAG,SAAA,EACH,GAAG,SAAA,EACH,cAAc,oBAAA,EACd,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,WAAW,iBAAA,EACX,UAAU,gBAAA,EACV,YAAY,kBAAA;IAEZ,IAAM,MAAM,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAE5C,KAAK,CAAC,SAAS,CAAC;QACZ,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,gBAAgB,EAAE,CAAC;SACtB;QAAA,CAAC;Q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AC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;YACjC,MAAM,EAAE,GAAG;SACd;QAED,6BAAK,EAAE,EAAC,QAAQ,EAAC,GAAG,EAAE,MAAM,GAAQ,CAClC,CACT,CAAC;AACN,CAAC,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG;IAC5B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;CACpB,CAAC"}
|
|
@@ -39,6 +39,7 @@ import { useRef } from "react";
|
|
|
39
39
|
import discreteLegendUtil from "../Utils/discreteLegend";
|
|
40
40
|
import { select, scaleOrdinal } from "d3";
|
|
41
41
|
import { colorsArray } from "../Utils/continousLegend";
|
|
42
|
+
import { d3ColorScales } from "../Utils/d3ColorScale";
|
|
42
43
|
export var DiscreteColorLegend = function (_a) {
|
|
43
44
|
var discreteData = _a.discreteData, dataObjectName = _a.dataObjectName, position = _a.position, colorName = _a.colorName, colorTables = _a.colorTables, horizontal = _a.horizontal, updateLegend = _a.updateLegend;
|
|
44
45
|
var divRef = useRef(null);
|
|
@@ -59,7 +60,7 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
59
60
|
}, [discreteData, colorName, colorTables, horizontal, updateLegend]);
|
|
60
61
|
function discreteLegend() {
|
|
61
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var dataSet, useSelectorLegend, res, arrayOfColors_1, ordinalValues, colorLegend, currentDiv, totalRect, svgLegend, error_1;
|
|
63
|
+
var dataSet, useSelectorLegend, res, arrayOfColors_1, d3ColorArrays_1, ordinalValues, colorLegend, currentDiv, totalRect, svgLegend, error_1;
|
|
63
64
|
return __generator(this, function (_a) {
|
|
64
65
|
switch (_a.label) {
|
|
65
66
|
case 0:
|
|
@@ -79,20 +80,32 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
79
80
|
arrayOfColors_1 = typeof colorTables === "string"
|
|
80
81
|
? colorsArray(colorName, dataSet)
|
|
81
82
|
: colorsArray(colorName, colorTables);
|
|
83
|
+
d3ColorArrays_1 = colorsArray(colorName, d3ColorScales);
|
|
82
84
|
// Main discrete legend
|
|
83
85
|
if (!updateLegend || updateLegend.length == 0) {
|
|
84
86
|
Object.keys(discreteData).forEach(function (key) {
|
|
85
87
|
//eslint-disable-next-line
|
|
86
88
|
var code = discreteData[key][1];
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
itemColor.push({
|
|
93
|
-
color: RGBToHex(matchedColorsArrays),
|
|
89
|
+
// for colortable colors
|
|
90
|
+
if (arrayOfColors_1.length > 0) {
|
|
91
|
+
//compare the first value in colorarray(colortable) and code from discreteData
|
|
92
|
+
var matchedColorsArrays_1 = arrayOfColors_1.find(function (value) {
|
|
93
|
+
return value[0] == code;
|
|
94
94
|
});
|
|
95
|
-
|
|
95
|
+
if (matchedColorsArrays_1)
|
|
96
|
+
itemColor.push({
|
|
97
|
+
color: RGBToHex(matchedColorsArrays_1),
|
|
98
|
+
});
|
|
99
|
+
itemName.push(key);
|
|
100
|
+
}
|
|
101
|
+
// for d3 colors
|
|
102
|
+
else {
|
|
103
|
+
var matchedColorsArrays = d3ColorArrays_1.find(function (value, index) {
|
|
104
|
+
return index == code;
|
|
105
|
+
});
|
|
106
|
+
if (matchedColorsArrays)
|
|
107
|
+
itemColor.push({ color: matchedColorsArrays });
|
|
108
|
+
}
|
|
96
109
|
});
|
|
97
110
|
useSelectorLegend = false;
|
|
98
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscreteLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/DiscreteLegend.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,MAA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IAAI,CAAC;QAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,mBAAmB,CAAC,YAAY,GAAG;IAC/B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;CACpB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { colorTablesArray } from "../Utils/ColorTableTypes";
|
|
2
|
-
export declare function colorsArray(colorName: string, colorTables:
|
|
2
|
+
export declare function colorsArray(colorName: string, colorTables: any): any;
|
|
3
3
|
export declare function rgbValues(point: number, colorName: string, colorTables: colorTablesArray): number[] | {
|
|
4
4
|
r: number;
|
|
5
5
|
g: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"continousLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/continousLegend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CACvB,SAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"continousLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/continousLegend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CACvB,SAAiB,EACjB,WAAgB;IAEhB,IAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CACrC,UAAC,KAAqB;QAClB,OAAA,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC,WAAW,EAAE;IAAnD,CA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B,QAAQ,CAAC,gBAAgB,CAAC,CAAC,KAAK,CACnC,CAAC,CAAC,CAAC,CAAC;YACL,OAAO,MAAA,KAAK,CAAC,kBAAkB,CAAC,0CAAE,GAAG,EAAE,CAAC;SAC3C;QACD,OAAO,SAAS,CAAC;KACpB;AACL,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,QAAQ,CAAC,GAAa;IAClC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EACnC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EACnC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,IAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IAE9B,OAAO,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACtD,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>
|
|
@@ -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,60 +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;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
59
|
+
|
|
60
|
+
// return continuous and discrete legend which uses d3 data
|
|
61
|
+
if (useColorTableColors) {
|
|
62
|
+
|
|
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}
|
|
95
105
|
colorScaleData={colorScaleObject.colorScaleObject}
|
|
96
106
|
/>
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
discreteLegend = discreteColorData.map((val: any, key: any) => {
|
|
101
|
-
return <ColorSelectorComponent
|
|
102
|
-
position={position + key}
|
|
103
|
-
colorsObject={discreteColorData[key]}
|
|
104
|
-
legendColorName={val.name}
|
|
105
|
-
useDiscColorTable={true}
|
|
106
|
-
colorScaleData={colorScaleObject.colorScaleObject}
|
|
107
|
-
/>
|
|
108
|
-
});
|
|
109
|
-
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//}
|
|
110
110
|
|
|
111
111
|
return (
|
|
112
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;
|
|
@@ -35,7 +36,23 @@ export 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 @@ export 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 @@ export 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}
|
|
@@ -3,6 +3,9 @@ import { useRef } from "react";
|
|
|
3
3
|
import { RGBToHex, colorsArray } from "../Utils/continousLegend";
|
|
4
4
|
import { select, scaleLinear, scaleSequential, axisBottom, axisRight } from "d3";
|
|
5
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]) => {
|
|
@@ -4,6 +4,7 @@ import discreteLegendUtil from "../Utils/discreteLegend";
|
|
|
4
4
|
import { select, scaleOrdinal } from "d3";
|
|
5
5
|
import { colorTablesArray } from "../Utils/ColorTableTypes";
|
|
6
6
|
import { colorsArray } from "../Utils/continousLegend"
|
|
7
|
+
import {d3ColorScales} from "../Utils/d3ColorScale";
|
|
7
8
|
|
|
8
9
|
declare type ItemColor = {
|
|
9
10
|
color: string;
|
|
@@ -62,22 +63,35 @@ export const DiscreteColorLegend: React.FC<colorLegendProps> = ({
|
|
|
62
63
|
? colorsArray(colorName, dataSet)
|
|
63
64
|
: colorsArray(colorName, colorTables);
|
|
64
65
|
|
|
66
|
+
const d3ColorArrays = colorsArray(colorName, d3ColorScales)
|
|
67
|
+
|
|
65
68
|
// Main discrete legend
|
|
66
69
|
if (!updateLegend || updateLegend.length == 0) {
|
|
67
70
|
Object.keys(discreteData).forEach((key) => {
|
|
68
71
|
//eslint-disable-next-line
|
|
69
72
|
let code = (discreteData as { [key: string]: any })[key][1]
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
// for colortable colors
|
|
74
|
+
if (arrayOfColors.length > 0) {
|
|
75
|
+
//compare the first value in colorarray(colortable) and code from discreteData
|
|
76
|
+
const matchedColorsArrays = arrayOfColors.find(
|
|
77
|
+
(value: number[]) => {
|
|
78
|
+
return value[0] == code;
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
if (matchedColorsArrays)
|
|
82
|
+
itemColor.push({
|
|
83
|
+
color: RGBToHex(matchedColorsArrays),
|
|
84
|
+
});
|
|
85
|
+
itemName.push(key);
|
|
86
|
+
}
|
|
87
|
+
// for d3 colors
|
|
88
|
+
else {
|
|
89
|
+
var matchedColorsArrays = d3ColorArrays.find((value: number,index: number) => {
|
|
90
|
+
return index == code;
|
|
79
91
|
});
|
|
80
|
-
|
|
92
|
+
if(matchedColorsArrays) itemColor.push({color: matchedColorsArrays});
|
|
93
|
+
}
|
|
94
|
+
|
|
81
95
|
});
|
|
82
96
|
useSelectorLegend = false;
|
|
83
97
|
}
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
// Based on objectName return the colors array from color.tables.json file
|
|
9
9
|
export function colorsArray(
|
|
10
10
|
colorName: string,
|
|
11
|
-
colorTables:
|
|
12
|
-
):
|
|
11
|
+
colorTables: any
|
|
12
|
+
): any {
|
|
13
13
|
const colorTableData = colorTables.filter(
|
|
14
14
|
(value: colorTablesObj) =>
|
|
15
15
|
value.name.toLowerCase() == colorName.toLowerCase()
|
package/tsconfig.json
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"noImplicitAny": true,
|
|
15
15
|
"strictNullChecks": true,
|
|
16
16
|
"suppressImplicitAnyIndexErrors": true,
|
|
17
|
-
"noUnusedLocals":
|
|
18
|
-
"noUnusedParameters":
|
|
17
|
+
"noUnusedLocals": false,
|
|
18
|
+
"noUnusedParameters": false,
|
|
19
19
|
"resolveJsonModule": true,
|
|
20
20
|
},
|
|
21
21
|
"include": ["src", "./src/custom.d.ts"],
|