@emerson-eps/color-tables 0.2.8 → 0.2.11
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/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.js +9 -9
- package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -1
- package/dist/component/Legend/ColorLegend.d.ts +2 -2
- package/dist/component/Legend/ColorLegend.js +1 -2
- package/dist/component/Legend/ColorLegend.js.map +1 -1
- package/dist/component/Legend/ContinuousLegend.d.ts +1 -1
- package/dist/component/Legend/DiscreteLegend.d.ts +1 -2
- package/dist/component/Legend/DiscreteLegend.js +8 -20
- 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 +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 +1 -1
- package/dist/stories/ColorLegends/SingleComponent/Single.stories.js.map +1 -1
- package/package.json +1 -1
- package/src/component/ColorSelector/ColorSelectorComponent.tsx +1 -18
- package/src/component/ColorSelector/ColorSelectorWrapper.tsx +24 -23
- package/src/component/Legend/ColorLegend.tsx +2 -4
- package/src/component/Legend/ContinuousLegend.tsx +1 -1
- package/src/component/Legend/DiscreteLegend.tsx +10 -52
- package/src/component/{ColorTableTypes.ts → Utils/ColorTableTypes.ts} +0 -0
- package/src/component/Utils/continousLegend.ts +1 -1
- package/src/component/Utils/discreteLegend.ts +11 -82
- package/src/index.ts +12 -9
- package/src/stories/ColorLegends/SingleComponent/Single.stories.jsx +1 -1
- package/tsconfig.json +1 -1
- package/dist/component/ColorTableTypes.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { colorTablesArray } from "../ColorTableTypes";
|
|
3
2
|
declare type legendProps = {
|
|
4
3
|
position: number[];
|
|
5
4
|
colorsObject?: any;
|
|
@@ -9,8 +8,6 @@ declare type legendProps = {
|
|
|
9
8
|
useDiscColorTable?: boolean;
|
|
10
9
|
valueIndex?: any;
|
|
11
10
|
colorScaleData: any;
|
|
12
|
-
getColorMapname?: any | null;
|
|
13
11
|
};
|
|
14
12
|
export declare const ColorSelectorComponent: React.FC<legendProps>;
|
|
15
|
-
export declare function colorTableData(colorName: string, colorTables: colorTablesArray): [number, number, number, number][];
|
|
16
13
|
export {};
|
|
@@ -7,9 +7,7 @@ import * as d3 from "d3";
|
|
|
7
7
|
import discreteLegendUtil from "../Utils/discreteLegend";
|
|
8
8
|
import { color } from "d3-color";
|
|
9
9
|
export var ColorSelectorComponent = function (_a) {
|
|
10
|
-
var
|
|
11
|
-
// position,
|
|
12
|
-
colorsObject = _a.colorsObject, legendColor = _a.legendColor, legendColorName = _a.legendColorName, useContColorTable = _a.useContColorTable, useDiscColorTable = _a.useDiscColorTable, valueIndex = _a.valueIndex, colorScaleData = _a.colorScaleData;
|
|
10
|
+
var colorsObject = _a.colorsObject, legendColor = _a.legendColor, legendColorName = _a.legendColorName, useContColorTable = _a.useContColorTable, useDiscColorTable = _a.useDiscColorTable, valueIndex = _a.valueIndex, colorScaleData = _a.colorScaleData;
|
|
13
11
|
var divRef = useRef(null);
|
|
14
12
|
// create an array of steps based on the color scale
|
|
15
13
|
// returns an array of evenly-spaced numbers. Returns the integers from zero to the specified end minus one.
|
|
@@ -125,7 +123,6 @@ export var ColorSelectorComponent = function (_a) {
|
|
|
125
123
|
.attr("y", 15)
|
|
126
124
|
.style("font-size", "smaller")
|
|
127
125
|
.style("font-weight", "900")
|
|
128
|
-
// .attr("textLength","5em")
|
|
129
126
|
.text(colorsObject.name);
|
|
130
127
|
// draw the rectangle and fill with gradient
|
|
131
128
|
svgLegend
|
|
@@ -261,11 +258,4 @@ export var ColorSelectorComponent = function (_a) {
|
|
|
261
258
|
return (React.createElement("div", null,
|
|
262
259
|
React.createElement("div", { id: "legend", style: { height: 30 }, ref: divRef, onClick: handleChange })));
|
|
263
260
|
};
|
|
264
|
-
// Based on name return the colors array from color.tables.json file
|
|
265
|
-
export function colorTableData(colorName, colorTables) {
|
|
266
|
-
var colorTableData = colorTables.filter(function (value) {
|
|
267
|
-
return value.name.toLowerCase() == colorName.toLowerCase();
|
|
268
|
-
});
|
|
269
|
-
return colorTableData.length > 0 ? colorTableData[0].colors : [];
|
|
270
|
-
}
|
|
271
261
|
//# 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,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;
|
|
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,EA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 -39,6 +39,15 @@ export var ColorSelectorWrapper = function (_a) {
|
|
|
39
39
|
var useColorTableColors = _a.useColorTableColors, useD3Colors = _a.useD3Colors, colorScaleObject = _a.colorScaleObject;
|
|
40
40
|
var continuousLegend;
|
|
41
41
|
var discreteLegend;
|
|
42
|
+
// return continuous and discrete legend which uses d3 data
|
|
43
|
+
if (useD3Colors) {
|
|
44
|
+
continuousLegend = continuosD3ColorData.map(function (val, key) {
|
|
45
|
+
return React.createElement(ColorSelectorComponent, { position: position + key, legendColor: val.color, legendColorName: val.name, useContColorTable: false, valueIndex: key + "0", colorScaleData: colorScaleObject.colorScaleObject });
|
|
46
|
+
});
|
|
47
|
+
discreteLegend = d3discreteData.map(function (val, key) {
|
|
48
|
+
return React.createElement(ColorSelectorComponent, { position: position + key, colorsObject: val.colors, legendColorName: val.name, useDiscColorTable: false, colorScaleData: colorScaleObject.colorScaleObject });
|
|
49
|
+
});
|
|
50
|
+
}
|
|
42
51
|
// return continuous and discrete legend which uses colortable data
|
|
43
52
|
if (useColorTableColors) {
|
|
44
53
|
continuousLegend = continuosColorData.map(function (value, key) {
|
|
@@ -49,15 +58,6 @@ export var ColorSelectorWrapper = function (_a) {
|
|
|
49
58
|
return React.createElement(ColorSelectorComponent, { position: position + key, colorsObject: discreteColorData[key], legendColorName: val.name, useDiscColorTable: true, colorScaleData: colorScaleObject.colorScaleObject });
|
|
50
59
|
});
|
|
51
60
|
}
|
|
52
|
-
// return continuous and discrete legend which uses d3 data
|
|
53
|
-
if (useD3Colors) {
|
|
54
|
-
continuousLegend = continuosD3ColorData.map(function (val, key) {
|
|
55
|
-
return React.createElement(ColorSelectorComponent, { position: position + key, legendColor: val.color, legendColorName: val.name, useContColorTable: false, valueIndex: key + "0", colorScaleData: colorScaleObject.colorScaleObject });
|
|
56
|
-
});
|
|
57
|
-
discreteLegend = d3discreteData.map(function (val, key) {
|
|
58
|
-
return React.createElement(ColorSelectorComponent, { position: position + key, colorsObject: val.colors, legendColorName: val.name, useDiscColorTable: false, colorScaleData: colorScaleObject.colorScaleObject });
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
61
|
return (React.createElement("div", { className: "legendWrapper", style: { height: 200, overflow: "auto", display: "flex", flexDirection: "column", overflowX: "hidden" } },
|
|
62
62
|
continuousLegend,
|
|
63
63
|
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,OAAO,KAAK,WAAW,MAAM,sBAAsB,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;AAQpC,4CAA4C;AAC5C,IAAM,wBAAwB,GAAG,WAAW,CAAC,MAAM,CAAC,UAAC,OAAY;IAC7D,OAAO,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,wBAAwB,CAAC,OAAO,CAAC,UAAC,OAAY;IAC1C,kBAAkB,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAC,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC;AAEH,kCAAkC;AAClC,IAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,UAAC,OAAY;IACvD,OAAO,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;AACrC,CAAC,CA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C,IAAI,EACzB,iBAAiB,EAAE,KAAK,EACxB,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,GACnD,CAAA;QACd,CAAC,CAAC,CAAC;KACN;IAED,mEAAmE;IACnE,IAAI,mBAAmB,EAAE;QACrB,gBAAgB,GAAI,kBAAkB,CAAC,GAAG,CAAC,UAAC,KAAU,EAAE,GAAQ;YAC5D,OAAO;gBACK,oBAAC,sBAAsB,IACnB,QAAQ,EAAE,QAAQ,GAAG,GAAG,EACxB,YAAY,EAAE,KAAK,EACnB,iBAAiB,EAAE,IAAI,EACvB,UAAU,EAAE,GAAG,EACf,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,GACnD,CACJ,CAAA;QACd,CAAC,CAAC,CAAC;QAEH,cAAc,GAAG,iBAAiB,CAAC,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;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"}
|
|
@@ -4,7 +4,7 @@ import { ContinuousLegend } from "./ContinuousLegend";
|
|
|
4
4
|
import { useCallback } from "react";
|
|
5
5
|
import { ColorSelectorAccordion } from "../ColorSelector/ColorSelectorAccordion";
|
|
6
6
|
// Todo: Adapt it for other layers too
|
|
7
|
-
var ColorLegend = function (_a) {
|
|
7
|
+
export var ColorLegend = function (_a) {
|
|
8
8
|
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;
|
|
9
9
|
var _b = React.useState(false), isToggled = _b[0], setIsToggled = _b[1];
|
|
10
10
|
var handleClick = useCallback(function () {
|
|
@@ -31,5 +31,4 @@ var ColorLegend = function (_a) {
|
|
|
31
31
|
!isCont && (React.createElement(DiscreteColorLegend, { discreteData: discreteData, dataObjectName: dataObjectName, position: position, colorName: colorName, colorTables: colorTables, horizontal: horizontal, updateLegend: updateLegend }))),
|
|
32
32
|
React.createElement("div", null, isToggled && (React.createElement(ColorSelectorAccordion, { colorScaleObject: colorScaleObject, isHorizontal: horizontal })))));
|
|
33
33
|
};
|
|
34
|
-
export default ColorLegend;
|
|
35
34
|
//# 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,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAcjF,sCAAsC;AACtC,IAAM,WAAW,GAA+B,UAAC,
|
|
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,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM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I,CACP,oBAAC,gBAAgB,IACb,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,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;YACA,CAAC,MAAM,IAAI,CACR,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { colorTablesArray } from "../ColorTableTypes";
|
|
2
|
+
import { colorTablesArray } from "../Utils/ColorTableTypes";
|
|
3
3
|
declare type colorLegendProps = {
|
|
4
4
|
discreteData: {
|
|
5
5
|
objects: Record<string, [number[], number]>;
|
|
@@ -12,6 +12,5 @@ declare type colorLegendProps = {
|
|
|
12
12
|
updateLegend?: any;
|
|
13
13
|
};
|
|
14
14
|
export declare const DiscreteColorLegend: React.FC<colorLegendProps>;
|
|
15
|
-
export declare function colorTableData(colorName: string, colorTables: colorTablesArray): [number, number, number, number][];
|
|
16
15
|
export declare function RGBToHex(rgb: number[]): string;
|
|
17
16
|
export {};
|
|
@@ -38,6 +38,7 @@ import * as React from "react";
|
|
|
38
38
|
import { useRef } from "react";
|
|
39
39
|
import discreteLegendUtil from "../Utils/discreteLegend";
|
|
40
40
|
import { select, scaleOrdinal } from "d3";
|
|
41
|
+
import { colorsArray } from "../Utils/continousLegend";
|
|
41
42
|
export var DiscreteColorLegend = function (_a) {
|
|
42
43
|
var discreteData = _a.discreteData, dataObjectName = _a.dataObjectName, position = _a.position, colorName = _a.colorName, colorTables = _a.colorTables, horizontal = _a.horizontal, updateLegend = _a.updateLegend;
|
|
43
44
|
var divRef = useRef(null);
|
|
@@ -58,7 +59,7 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
58
59
|
}, [discreteData, colorName, colorTables, horizontal, updateLegend]);
|
|
59
60
|
function discreteLegend() {
|
|
60
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
var dataSet, useSelectorLegend, res,
|
|
62
|
+
var dataSet, useSelectorLegend, res, arrayOfColors_1, ordinalValues, colorLegend, currentDiv, totalRect, svgLegend, error_1;
|
|
62
63
|
return __generator(this, function (_a) {
|
|
63
64
|
switch (_a.label) {
|
|
64
65
|
case 0:
|
|
@@ -75,17 +76,16 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
75
76
|
dataSet = _a.sent();
|
|
76
77
|
_a.label = 4;
|
|
77
78
|
case 4:
|
|
78
|
-
|
|
79
|
-
?
|
|
80
|
-
:
|
|
81
|
-
console.log('updateLegend', updateLegend);
|
|
79
|
+
arrayOfColors_1 = typeof colorTables === "string"
|
|
80
|
+
? colorsArray(colorName, dataSet)
|
|
81
|
+
: colorsArray(colorName, colorTables);
|
|
82
82
|
// Main discrete legend
|
|
83
83
|
if (!updateLegend || updateLegend.length == 0) {
|
|
84
84
|
Object.keys(discreteData).forEach(function (key) {
|
|
85
85
|
//eslint-disable-next-line
|
|
86
86
|
var code = discreteData[key][1];
|
|
87
87
|
//compare the first value in colorarray(colortable) and code from discreteData
|
|
88
|
-
var matchedColorsArrays =
|
|
88
|
+
var matchedColorsArrays = arrayOfColors_1.find(function (value) {
|
|
89
89
|
return value[0] == code;
|
|
90
90
|
});
|
|
91
91
|
if (matchedColorsArrays)
|
|
@@ -115,7 +115,8 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
115
115
|
useSelectorLegend = true;
|
|
116
116
|
}
|
|
117
117
|
ordinalValues = scaleOrdinal().domain(itemName);
|
|
118
|
-
colorLegend = discreteLegendUtil(itemColor, useSelectorLegend, horizontal)
|
|
118
|
+
colorLegend = discreteLegendUtil(itemColor, useSelectorLegend, horizontal)
|
|
119
|
+
.inputScale(ordinalValues);
|
|
119
120
|
currentDiv = select(divRef.current);
|
|
120
121
|
totalRect = void 0;
|
|
121
122
|
// append the title
|
|
@@ -128,12 +129,6 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
128
129
|
svgLegend = currentDiv
|
|
129
130
|
.style("margin", "5px")
|
|
130
131
|
.append("svg")
|
|
131
|
-
// .on("mouseover", function () {
|
|
132
|
-
// return tooltip.style("visibility", "visible");
|
|
133
|
-
// })
|
|
134
|
-
// .on("mouseout", function () {
|
|
135
|
-
// return tooltip.style("visibility", "hidden");
|
|
136
|
-
// })
|
|
137
132
|
.call(colorLegend);
|
|
138
133
|
// Style for main horizontal legend
|
|
139
134
|
if (!useSelectorLegend) {
|
|
@@ -187,13 +182,6 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
187
182
|
} },
|
|
188
183
|
React.createElement("div", { id: "legend", ref: divRef })));
|
|
189
184
|
};
|
|
190
|
-
// Based on name return the colors array from color.tables.json file
|
|
191
|
-
export function colorTableData(colorName, colorTables) {
|
|
192
|
-
var colorTableData = colorTables.filter(function (value) {
|
|
193
|
-
return value.name.toLowerCase() == colorName.toLowerCase();
|
|
194
|
-
});
|
|
195
|
-
return colorTableData.length > 0 ? colorTableData[0].colors : [];
|
|
196
|
-
}
|
|
197
185
|
export function RGBToHex(rgb) {
|
|
198
186
|
var r = rgb[1].toString(16), g = rgb[2].toString(16), b = rgb[3].toString(16);
|
|
199
187
|
if (r.length == 1)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscreteLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/DiscreteLegend.tsx"],"names":[],"mappings":";;;;;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AAC"}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorTableTypes.js","sourceRoot":"","sources":["../../../src/component/Utils/ColorTableTypes.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { colorTablesArray } from "../ColorTableTypes";
|
|
1
|
+
import { colorTablesArray } from "../Utils/ColorTableTypes";
|
|
2
2
|
export declare function colorsArray(colorName: string, colorTables: colorTablesArray): [number, number, number, number][];
|
|
3
3
|
export declare function rgbValues(point: number, colorName: string, colorTables: colorTablesArray): number[] | {
|
|
4
4
|
r: number;
|
|
@@ -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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;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",
|
|
@@ -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
|
@@ -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
|
+
};
|
|
@@ -59,6 +59,30 @@ export const ColorSelectorWrapper: React.FC<legendProps> = ({
|
|
|
59
59
|
let continuousLegend;
|
|
60
60
|
let discreteLegend;
|
|
61
61
|
|
|
62
|
+
// return continuous and discrete legend which uses d3 data
|
|
63
|
+
if (useD3Colors) {
|
|
64
|
+
continuousLegend = continuosD3ColorData.map((val: any, key: any) => {
|
|
65
|
+
return <ColorSelectorComponent
|
|
66
|
+
position={position + key}
|
|
67
|
+
legendColor={val.color}
|
|
68
|
+
legendColorName={val.name}
|
|
69
|
+
useContColorTable={false}
|
|
70
|
+
valueIndex={key + "0"}
|
|
71
|
+
colorScaleData={colorScaleObject.colorScaleObject}
|
|
72
|
+
/>
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
discreteLegend = d3discreteData.map((val: any, key: any) => {
|
|
76
|
+
return <ColorSelectorComponent
|
|
77
|
+
position={position + key}
|
|
78
|
+
colorsObject={val.colors}
|
|
79
|
+
legendColorName={val.name}
|
|
80
|
+
useDiscColorTable={false}
|
|
81
|
+
colorScaleData={colorScaleObject.colorScaleObject}
|
|
82
|
+
/>
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
62
86
|
// return continuous and discrete legend which uses colortable data
|
|
63
87
|
if (useColorTableColors) {
|
|
64
88
|
continuousLegend = continuosColorData.map((value: any, key: any) => {
|
|
@@ -83,29 +107,6 @@ export const ColorSelectorWrapper: React.FC<legendProps> = ({
|
|
|
83
107
|
/>
|
|
84
108
|
});
|
|
85
109
|
}
|
|
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
|
-
}
|
|
109
110
|
|
|
110
111
|
return (
|
|
111
112
|
<div className="legendWrapper"
|
|
@@ -17,7 +17,7 @@ declare type ColorLegendProps = {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Todo: Adapt it for other layers too
|
|
20
|
-
const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
20
|
+
export const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
21
21
|
position,
|
|
22
22
|
horizontal,
|
|
23
23
|
colorTables,
|
|
@@ -86,6 +86,4 @@ const ColorLegend: React.FC<ColorLegendProps> = ({
|
|
|
86
86
|
</div>
|
|
87
87
|
|
|
88
88
|
);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export default ColorLegend;
|
|
89
|
+
};
|
|
@@ -2,7 +2,7 @@ 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
6
|
|
|
7
7
|
declare type legendProps = {
|
|
8
8
|
min: number;
|
|
@@ -2,11 +2,12 @@ import * as React from "react";
|
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import discreteLegendUtil from "../Utils/discreteLegend";
|
|
4
4
|
import { select, scaleOrdinal } from "d3";
|
|
5
|
-
import { colorTablesArray
|
|
5
|
+
import { colorTablesArray } from "../Utils/ColorTableTypes";
|
|
6
|
+
import { colorsArray } from "../Utils/continousLegend"
|
|
6
7
|
|
|
7
8
|
declare type ItemColor = {
|
|
8
9
|
color: string;
|
|
9
|
-
}
|
|
10
|
+
};
|
|
10
11
|
|
|
11
12
|
declare type colorLegendProps = {
|
|
12
13
|
discreteData: { objects: Record<string, [number[], number]> };
|
|
@@ -16,7 +17,7 @@ declare type colorLegendProps = {
|
|
|
16
17
|
colorTables: colorTablesArray | string;
|
|
17
18
|
horizontal?: boolean | null;
|
|
18
19
|
updateLegend?: any
|
|
19
|
-
}
|
|
20
|
+
};
|
|
20
21
|
|
|
21
22
|
export const DiscreteColorLegend: React.FC<colorLegendProps> = ({
|
|
22
23
|
discreteData,
|
|
@@ -56,12 +57,10 @@ export const DiscreteColorLegend: React.FC<colorLegendProps> = ({
|
|
|
56
57
|
dataSet = await res.json();
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
const
|
|
60
|
+
const arrayOfColors =
|
|
60
61
|
typeof colorTables === "string"
|
|
61
|
-
?
|
|
62
|
-
:
|
|
63
|
-
|
|
64
|
-
console.log('updateLegend', updateLegend)
|
|
62
|
+
? colorsArray(colorName, dataSet)
|
|
63
|
+
: colorsArray(colorName, colorTables);
|
|
65
64
|
|
|
66
65
|
// Main discrete legend
|
|
67
66
|
if (!updateLegend || updateLegend.length == 0) {
|
|
@@ -69,7 +68,7 @@ export const DiscreteColorLegend: React.FC<colorLegendProps> = ({
|
|
|
69
68
|
//eslint-disable-next-line
|
|
70
69
|
let code = (discreteData as { [key: string]: any })[key][1]
|
|
71
70
|
//compare the first value in colorarray(colortable) and code from discreteData
|
|
72
|
-
const matchedColorsArrays =
|
|
71
|
+
const matchedColorsArrays = arrayOfColors.find(
|
|
73
72
|
(value: number[]) => {
|
|
74
73
|
return value[0] == code;
|
|
75
74
|
}
|
|
@@ -103,36 +102,13 @@ export const DiscreteColorLegend: React.FC<colorLegendProps> = ({
|
|
|
103
102
|
useSelectorLegend = true;
|
|
104
103
|
}
|
|
105
104
|
|
|
106
|
-
// const toolTipName = itemName.map((word, idx) => {
|
|
107
|
-
// return <li key={idx}>{word}</li>;
|
|
108
|
-
// });
|
|
109
|
-
|
|
110
|
-
// let nameTool;
|
|
111
|
-
|
|
112
|
-
// toolTipName.forEach((data) => {
|
|
113
|
-
// //nameTool.push(data.props.children)
|
|
114
|
-
// nameTool = data.props.children;
|
|
115
|
-
// });
|
|
116
|
-
|
|
117
|
-
// // create a tooltip
|
|
118
|
-
// const tooltip = select(divRef.current)
|
|
119
|
-
// .append("div")
|
|
120
|
-
// .style("position", "absolute")
|
|
121
|
-
// .style("visibility", "hidden")
|
|
122
|
-
// .style("background-color", "black")
|
|
123
|
-
// .style("border", "solid")
|
|
124
|
-
// .style("border-width", "1px")
|
|
125
|
-
// .style("border-radius", "5px")
|
|
126
|
-
// .style("padding", "10px")
|
|
127
|
-
// .text(nameTool)
|
|
128
|
-
// .style("color", "grey");
|
|
129
|
-
|
|
130
105
|
const ordinalValues = scaleOrdinal().domain(itemName);
|
|
131
106
|
const colorLegend = discreteLegendUtil(
|
|
132
107
|
itemColor,
|
|
133
108
|
useSelectorLegend,
|
|
134
109
|
horizontal
|
|
135
|
-
)
|
|
110
|
+
)
|
|
111
|
+
.inputScale(ordinalValues);
|
|
136
112
|
const currentDiv = select(divRef.current);
|
|
137
113
|
let totalRect;
|
|
138
114
|
|
|
@@ -148,12 +124,6 @@ export const DiscreteColorLegend: React.FC<colorLegendProps> = ({
|
|
|
148
124
|
const svgLegend = currentDiv
|
|
149
125
|
.style("margin", "5px")
|
|
150
126
|
.append("svg")
|
|
151
|
-
// .on("mouseover", function () {
|
|
152
|
-
// return tooltip.style("visibility", "visible");
|
|
153
|
-
// })
|
|
154
|
-
// .on("mouseout", function () {
|
|
155
|
-
// return tooltip.style("visibility", "hidden");
|
|
156
|
-
// })
|
|
157
127
|
.call(colorLegend);
|
|
158
128
|
|
|
159
129
|
// Style for main horizontal legend
|
|
@@ -210,18 +180,6 @@ export const DiscreteColorLegend: React.FC<colorLegendProps> = ({
|
|
|
210
180
|
);
|
|
211
181
|
};
|
|
212
182
|
|
|
213
|
-
// Based on name return the colors array from color.tables.json file
|
|
214
|
-
export function colorTableData(
|
|
215
|
-
colorName: string,
|
|
216
|
-
colorTables: colorTablesArray
|
|
217
|
-
): [number, number, number, number][] {
|
|
218
|
-
const colorTableData = colorTables.filter(
|
|
219
|
-
(value: colorTablesObj) =>
|
|
220
|
-
value.name.toLowerCase() == colorName.toLowerCase()
|
|
221
|
-
);
|
|
222
|
-
return colorTableData.length > 0 ? colorTableData[0].colors : [];
|
|
223
|
-
}
|
|
224
|
-
|
|
225
183
|
export function RGBToHex(rgb: number[]) {
|
|
226
184
|
let r = rgb[1].toString(16),
|
|
227
185
|
g = rgb[2].toString(16),
|
|
File without changes
|
|
@@ -3,7 +3,7 @@ import { interpolateRgb } from "d3-interpolate";
|
|
|
3
3
|
import {
|
|
4
4
|
colorTablesArray,
|
|
5
5
|
colorTablesObj,
|
|
6
|
-
} from "../ColorTableTypes";
|
|
6
|
+
} from "../Utils/ColorTableTypes";
|
|
7
7
|
|
|
8
8
|
// Based on objectName return the colors array from color.tables.json file
|
|
9
9
|
export function colorsArray(
|
|
@@ -4,14 +4,6 @@ declare type ItemColor = {
|
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line
|
|
6
6
|
export default function discreteLegendUtil(itemColor: ItemColor[], isSelectorLegend?: boolean, horizontal?: any): any {
|
|
7
|
-
// var cellWidth = 22;
|
|
8
|
-
// var cellHeight = 22;
|
|
9
|
-
|
|
10
|
-
// if (isSelectorLegend) {
|
|
11
|
-
// cellWidth = 25;
|
|
12
|
-
// cellHeight = 22;
|
|
13
|
-
// }
|
|
14
|
-
|
|
15
7
|
const legendValues: ItemColor[] = [];
|
|
16
8
|
|
|
17
9
|
// eslint-disable-next-line
|
|
@@ -37,105 +29,42 @@ export default function discreteLegendUtil(itemColor: ItemColor[], isSelectorLeg
|
|
|
37
29
|
if (horizontal && !isSelectorLegend) {
|
|
38
30
|
g.selectAll("rect")
|
|
39
31
|
.attr("x", function (d: number, i: number) {
|
|
40
|
-
|
|
41
|
-
return i;
|
|
32
|
+
// temporary workaround to ignore typescript error (d value as unused)
|
|
33
|
+
if (i) return i;
|
|
34
|
+
else if (d) return null;
|
|
42
35
|
})
|
|
43
36
|
.attr("y", 0);
|
|
44
37
|
} else if (!horizontal && !isSelectorLegend) {
|
|
45
38
|
g.selectAll("rect")
|
|
46
39
|
.attr("y", function (d: number, i: number) {
|
|
47
|
-
|
|
48
|
-
return
|
|
40
|
+
if (i) return i;
|
|
41
|
+
else if (d) return null;
|
|
49
42
|
})
|
|
50
43
|
.attr("x", 0);
|
|
51
44
|
} else if (horizontal == true && isSelectorLegend) {
|
|
52
45
|
g.selectAll("rect")
|
|
53
46
|
.attr("x", function (d: number, i: number) {
|
|
54
|
-
|
|
55
|
-
return
|
|
47
|
+
if (i) return i;
|
|
48
|
+
else if (d) return null;
|
|
56
49
|
})
|
|
57
50
|
.attr("y", 0);
|
|
58
51
|
} else if (horizontal == false && isSelectorLegend) {
|
|
59
52
|
g.selectAll("rect")
|
|
60
53
|
.attr("y", function (d: number, i: number) {
|
|
61
|
-
|
|
62
|
-
return
|
|
54
|
+
if (i) return i;
|
|
55
|
+
else if (d) return null;
|
|
63
56
|
})
|
|
64
57
|
.attr("x", 0);
|
|
65
58
|
} else {
|
|
66
59
|
g.selectAll("rect")
|
|
67
60
|
.attr("x", function (d: number, i: number) {
|
|
68
|
-
|
|
69
|
-
return
|
|
61
|
+
if (i) return i;
|
|
62
|
+
else if (d) return null;
|
|
70
63
|
})
|
|
71
64
|
.attr("y", 0);
|
|
72
65
|
}
|
|
73
|
-
|
|
74
|
-
// Display the labels for legend
|
|
75
|
-
// g.selectAll("g")
|
|
76
|
-
// .style("background", "grey")
|
|
77
|
-
// .append("text")
|
|
78
|
-
// .attr("class", "breakLabels")
|
|
79
|
-
// .style("font-size", "0.4")
|
|
80
|
-
// //.attr("x", cellWidth + cellPadding)
|
|
81
|
-
// //.attr("y", 5 + cellHeight / 2)
|
|
82
|
-
// .attr("x", function (d: any, i: any) {
|
|
83
|
-
// //console.log(d)
|
|
84
|
-
// return i + "." + 25
|
|
85
|
-
// })
|
|
86
|
-
// .attr("y", 1.5)
|
|
87
|
-
// .text(function (d: any, i: any) {
|
|
88
|
-
// //console.log(d)
|
|
89
|
-
// return i;
|
|
90
|
-
// })
|
|
91
|
-
//}
|
|
92
|
-
// styling for main legend
|
|
93
|
-
// else {
|
|
94
|
-
// itemColor.forEach((item, index) => {
|
|
95
|
-
// legendValues[index].color = item.color;
|
|
96
|
-
// });
|
|
97
|
-
// g.selectAll("g.legendCells")
|
|
98
|
-
// .append("text")
|
|
99
|
-
// .attr("class", "breakLabels")
|
|
100
|
-
// .style("fill", "#6F6F6F")
|
|
101
|
-
// .attr("x", cellWidth + cellPadding)
|
|
102
|
-
// .attr("y", 5 + cellHeight / 2)
|
|
103
|
-
// .text(function (d: Record<string, unknown>, i:any) {
|
|
104
|
-
// return d['label'];
|
|
105
|
-
// });
|
|
106
|
-
// g.selectAll("g.legendCells")
|
|
107
|
-
// .style("cursor", "pointer")
|
|
108
|
-
// .append("rect")
|
|
109
|
-
// .attr("height", cellHeight)
|
|
110
|
-
// .attr("width", cellWidth)
|
|
111
|
-
// .style("fill", function (d: Record<string, unknown>) {
|
|
112
|
-
// //console.log('d', d)
|
|
113
|
-
// return d["color"];
|
|
114
|
-
// })
|
|
115
|
-
|
|
116
|
-
// // Alighment of cell in straight line
|
|
117
|
-
// g.selectAll("g.legendCells").attr(
|
|
118
|
-
// "transform",
|
|
119
|
-
// function (_d: Record<string, unknown>, i: number) {
|
|
120
|
-
// return (
|
|
121
|
-
// "translate(0," + i * (cellHeight + cellPadding) + ")"
|
|
122
|
-
// //"translate(0," + i + ")"
|
|
123
|
-
// );
|
|
124
|
-
// }
|
|
125
|
-
// );
|
|
126
|
-
// }
|
|
127
66
|
}
|
|
128
67
|
|
|
129
|
-
// display the discrete legend
|
|
130
|
-
// if (!isSelectorLegend) {
|
|
131
|
-
// // console.log('itemcolor', itemColor)
|
|
132
|
-
// g.selectAll("g.legendCells")
|
|
133
|
-
// .data(legendValues)
|
|
134
|
-
// .enter()
|
|
135
|
-
// .append("g")
|
|
136
|
-
// .attr("class", "legendCells")
|
|
137
|
-
// }
|
|
138
|
-
|
|
139
68
|
drawLegend();
|
|
140
69
|
}
|
|
141
70
|
// eslint-disable-next-line
|
package/src/index.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
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
11
|
|
|
10
12
|
export {
|
|
13
|
+
ColorSelectorAccordion,
|
|
14
|
+
ColorSelectorComponent,
|
|
15
|
+
ColorSelectorWrapper,
|
|
11
16
|
ContinuousLegend,
|
|
17
|
+
DiscreteColorLegend,
|
|
18
|
+
ColorLegend,
|
|
12
19
|
colorsArray,
|
|
13
20
|
rgbValues,
|
|
14
21
|
RGBToHex,
|
|
15
|
-
|
|
16
|
-
DiscreteColorLegend,
|
|
22
|
+
d3ColorScales,
|
|
17
23
|
colorTablesObj,
|
|
18
24
|
colorTablesArray,
|
|
19
|
-
ColorSelectorAccordion,
|
|
20
|
-
ColorSelectorComponent,
|
|
21
|
-
ColorSelectorWrapper,
|
|
22
25
|
colorTables,
|
|
23
26
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import colorTables from "../../../component/color-tables.json";
|
|
3
|
-
import ColorLegend from "../../../component/Legend/ColorLegend";
|
|
3
|
+
import {ColorLegend} from "../../../component/Legend/ColorLegend";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
component: ColorLegend,
|
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ColorTableTypes.js","sourceRoot":"","sources":["../../src/component/ColorTableTypes.ts"],"names":[],"mappings":""}
|