@emerson-eps/color-tables 0.4.0 → 0.4.3
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.js +53 -26
- package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
- package/dist/component/ColorSelector/ColorSelectorWrapper.js +4 -4
- package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -1
- package/dist/component/Legend/ColorLegend.d.ts +2 -1
- package/dist/component/Legend/ColorLegend.js +11 -11
- package/dist/component/Legend/ColorLegend.js.map +1 -1
- package/dist/component/Legend/ContinuousLegend.d.ts +42 -0
- package/dist/component/Legend/ContinuousLegend.js +174 -162
- package/dist/component/Legend/ContinuousLegend.js.map +1 -1
- package/dist/component/Legend/ContinuousLegend.stories.d.ts +1 -0
- package/dist/component/Legend/DiscreteLegend.d.ts +28 -0
- package/dist/component/Legend/DiscreteLegend.js +128 -125
- package/dist/component/Legend/DiscreteLegend.js.map +1 -1
- package/dist/component/Utils/discreteLegend.js +2 -2
- package/dist/component/Utils/discreteLegend.js.map +1 -1
- package/dist/component/Utils/legendCommonFunction.js +8 -8
- package/dist/component/Utils/legendCommonFunction.js.map +1 -1
- package/dist/component/Utils/legendCommonFunction.stories.d.ts +1 -0
- package/package.json +1 -1
|
@@ -43,17 +43,183 @@ import { color } from "d3-color";
|
|
|
43
43
|
import { range } from "d3";
|
|
44
44
|
import defaultColorTables from "../color-tables.json";
|
|
45
45
|
export var ContinuousLegend = function (_a) {
|
|
46
|
-
var min = _a.min, max = _a.max, dataObjectName = _a.dataObjectName, position = _a.position, _b = _a.colorName, colorName = _b === void 0 ? "Rainbow" : _b, horizontal = _a.horizontal, getColorScaleData = _a.getColorScaleData, id = _a.id, _c = _a.colorTables, colorTables = _c === void 0 ? defaultColorTables : _c, colorMapFunction = _a.colorMapFunction;
|
|
46
|
+
var min = _a.min, max = _a.max, dataObjectName = _a.dataObjectName, position = _a.position, _b = _a.colorName, colorName = _b === void 0 ? "Rainbow" : _b, horizontal = _a.horizontal, getColorScaleData = _a.getColorScaleData, id = _a.id, _c = _a.colorTables, colorTables = _c === void 0 ? defaultColorTables : _c, colorMapFunction = _a.colorMapFunction, reverseRange = _a.reverseRange;
|
|
47
47
|
var generateUniqueId = Math.ceil(Math.random() * 9999).toString();
|
|
48
48
|
var divRef = useRef(null);
|
|
49
49
|
React.useEffect(function () {
|
|
50
50
|
if (divRef.current) {
|
|
51
|
-
continuousLegend();
|
|
52
|
-
}
|
|
53
|
-
return function cleanup() {
|
|
54
51
|
select(divRef.current).select("div").remove();
|
|
55
52
|
select(divRef.current).select("svg").remove();
|
|
56
|
-
|
|
53
|
+
continuousLegend();
|
|
54
|
+
}
|
|
55
|
+
function continuousLegend() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var itemColor, dataSet, res, legendColors, arrayData_1, d3ColorArrays_1, data, getColorTableScale_1, maxValue_1, rgbValue, i, value, colorScale, svgLegend, defs, currentIndex, linearGradient, xLeg, yLeg, horizontalAxisLeg, VerticalAxisLeg, error_1;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
itemColor = [];
|
|
62
|
+
_a.label = 1;
|
|
63
|
+
case 1:
|
|
64
|
+
_a.trys.push([1, 5, , 6]);
|
|
65
|
+
if (!(typeof colorTables === "string")) return [3 /*break*/, 4];
|
|
66
|
+
return [4 /*yield*/, fetch(colorTables)];
|
|
67
|
+
case 2:
|
|
68
|
+
res = _a.sent();
|
|
69
|
+
return [4 /*yield*/, res.json()];
|
|
70
|
+
case 3:
|
|
71
|
+
dataSet = _a.sent();
|
|
72
|
+
_a.label = 4;
|
|
73
|
+
case 4:
|
|
74
|
+
legendColors = typeof colorTables === "string"
|
|
75
|
+
? colorsArray(colorName, dataSet)
|
|
76
|
+
: colorsArray(colorName, colorTables);
|
|
77
|
+
// Update color of legend based on color selector scales
|
|
78
|
+
// data is passed on click upon color scales
|
|
79
|
+
if (getColorScaleData && Object.keys(getColorScaleData).length > 0) {
|
|
80
|
+
// legend using color table data
|
|
81
|
+
if (getColorScaleData.color) {
|
|
82
|
+
legendColors = getColorScaleData.color;
|
|
83
|
+
}
|
|
84
|
+
// legend using d3 data
|
|
85
|
+
else if (getColorScaleData.arrayData) {
|
|
86
|
+
legendColors = getColorScaleData.arrayData;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// main continuous legend for d3 colors
|
|
90
|
+
if (legendColors.length === 0) {
|
|
91
|
+
arrayData_1 = [];
|
|
92
|
+
d3ColorArrays_1 = colorsArray(colorName, d3ColorScales);
|
|
93
|
+
data = range(10).map(function (d) { return ({ color: d3ColorArrays_1(d / 10) }); });
|
|
94
|
+
data.forEach(function (colorsObject, index) {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
arrayData_1.push([
|
|
97
|
+
0 + "." + index,
|
|
98
|
+
(_a = color(colorsObject.color)) === null || _a === void 0 ? void 0 : _a.rgb().r,
|
|
99
|
+
(_b = color(colorsObject.color)) === null || _b === void 0 ? void 0 : _b.rgb().g,
|
|
100
|
+
(_c = color(colorsObject.color)) === null || _c === void 0 ? void 0 : _c.rgb().b,
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
legendColors = arrayData_1;
|
|
104
|
+
}
|
|
105
|
+
getColorTableScale_1 = colorTables.find(function (value) {
|
|
106
|
+
if (getColorScaleData) {
|
|
107
|
+
return value.name === (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.name);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return value.name === colorName;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
maxValue_1 = legendColors.length - 1;
|
|
114
|
+
// if colorMapFunction prop is passed
|
|
115
|
+
if (colorMapFunction) {
|
|
116
|
+
rgbValue = [];
|
|
117
|
+
for (i = 0; i <= 1; i += 0.05) {
|
|
118
|
+
value = colorMapFunction(i);
|
|
119
|
+
rgbValue.push([i.toFixed(2), value[0], value[1], value[2]]);
|
|
120
|
+
}
|
|
121
|
+
legendColors = rgbValue;
|
|
122
|
+
}
|
|
123
|
+
legendColors.forEach(function (value) {
|
|
124
|
+
// return the color and offset needed to draw the legend
|
|
125
|
+
itemColor.push({
|
|
126
|
+
// to support discrete color for continous data
|
|
127
|
+
offset: (getColorTableScale_1 === null || getColorTableScale_1 === void 0 ? void 0 : getColorTableScale_1.discrete) === true
|
|
128
|
+
? RGBToHexValue(value, maxValue_1).offset
|
|
129
|
+
: RGBToHex(value).offset,
|
|
130
|
+
color: RGBToHex(value).color,
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
colorScale = scaleSequential().domain([min, max]);
|
|
134
|
+
svgLegend = select(divRef.current)
|
|
135
|
+
.style("margin-right", "2px")
|
|
136
|
+
.style("margin-left", "2px")
|
|
137
|
+
.append("svg")
|
|
138
|
+
.style("background-color", "#ffffffcc")
|
|
139
|
+
.style("border-radius", "5px");
|
|
140
|
+
defs = svgLegend.append("defs");
|
|
141
|
+
svgLegend
|
|
142
|
+
.attr("width", horizontal ? "190" : "77")
|
|
143
|
+
.attr("height", horizontal ? "70" : "173");
|
|
144
|
+
currentIndex = "linear-gradient-" + id + "0";
|
|
145
|
+
linearGradient = defs
|
|
146
|
+
.append("linearGradient")
|
|
147
|
+
.attr("id", currentIndex);
|
|
148
|
+
// append a linearGradient element to the defs and give it a unique id
|
|
149
|
+
if ((horizontal && !reverseRange) || (!horizontal && reverseRange)) {
|
|
150
|
+
linearGradient
|
|
151
|
+
.attr("x1", "0%")
|
|
152
|
+
.attr("x2", horizontal ? "100%" : "0%")
|
|
153
|
+
.attr("y1", "0%")
|
|
154
|
+
.attr("y2", horizontal ? "0%" : "100%");
|
|
155
|
+
}
|
|
156
|
+
else if ((!horizontal && !reverseRange) ||
|
|
157
|
+
(horizontal && reverseRange)) {
|
|
158
|
+
linearGradient
|
|
159
|
+
.attr("x1", horizontal ? "100%" : "0%")
|
|
160
|
+
.attr("x2", "0%")
|
|
161
|
+
.attr("y1", horizontal ? "0%" : "100%")
|
|
162
|
+
.attr("y2", "0%");
|
|
163
|
+
}
|
|
164
|
+
// append multiple color stops by using D3's data/enter step
|
|
165
|
+
linearGradient
|
|
166
|
+
.selectAll("stop")
|
|
167
|
+
.data(itemColor)
|
|
168
|
+
.enter()
|
|
169
|
+
.append("stop")
|
|
170
|
+
.attr("offset", function (data) {
|
|
171
|
+
return data.offset + "%";
|
|
172
|
+
})
|
|
173
|
+
.attr("stop-color", function (data) {
|
|
174
|
+
return data.color;
|
|
175
|
+
});
|
|
176
|
+
// draw the rectangle and fill with gradient
|
|
177
|
+
svgLegend
|
|
178
|
+
.append("rect")
|
|
179
|
+
.attr("x", 25)
|
|
180
|
+
.attr("y", horizontal ? 30 : 18)
|
|
181
|
+
.attr("width", horizontal ? "149" : 20)
|
|
182
|
+
.attr("height", horizontal ? 20 : "149")
|
|
183
|
+
.style("fill", "url(#" + currentIndex + ")");
|
|
184
|
+
// append title
|
|
185
|
+
svgLegend
|
|
186
|
+
.append("text")
|
|
187
|
+
.attr("x", horizontal ? 25 : -168)
|
|
188
|
+
.attr("y", horizontal ? 20 : 15)
|
|
189
|
+
.style("text-anchor", "left")
|
|
190
|
+
.style("transform", horizontal ? "none" : "left")
|
|
191
|
+
.style("transform", horizontal ? "none" : "rotate(270deg)")
|
|
192
|
+
.style("fill", "grey")
|
|
193
|
+
.style("font-size", "small")
|
|
194
|
+
.text(dataObjectName);
|
|
195
|
+
xLeg = scaleLinear()
|
|
196
|
+
.domain(reverseRange ? [max, min] : [min, max])
|
|
197
|
+
.range([10, 158]);
|
|
198
|
+
yLeg = scaleLinear()
|
|
199
|
+
.domain(reverseRange ? [min, max] : [max, min])
|
|
200
|
+
.range([10, 158]);
|
|
201
|
+
horizontalAxisLeg = axisBottom(xLeg).tickValues(colorScale.domain());
|
|
202
|
+
VerticalAxisLeg = axisRight(yLeg)
|
|
203
|
+
.tickSize(20)
|
|
204
|
+
.tickValues(colorScale.domain());
|
|
205
|
+
svgLegend
|
|
206
|
+
.attr("class", "axis")
|
|
207
|
+
.append("g")
|
|
208
|
+
.attr("transform", horizontal ? "translate(16, 50)" : "translate(25, 7.5)")
|
|
209
|
+
.style("font-size", "10px")
|
|
210
|
+
.style("font-weight", "700")
|
|
211
|
+
.call(horizontal ? horizontalAxisLeg : VerticalAxisLeg)
|
|
212
|
+
.style("height", 15);
|
|
213
|
+
return [3 /*break*/, 6];
|
|
214
|
+
case 5:
|
|
215
|
+
error_1 = _a.sent();
|
|
216
|
+
console.error(error_1);
|
|
217
|
+
return [3 /*break*/, 6];
|
|
218
|
+
case 6: return [2 /*return*/];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
57
223
|
}, [
|
|
58
224
|
min,
|
|
59
225
|
max,
|
|
@@ -62,164 +228,10 @@ export var ContinuousLegend = function (_a) {
|
|
|
62
228
|
horizontal,
|
|
63
229
|
getColorScaleData,
|
|
64
230
|
colorMapFunction,
|
|
231
|
+
dataObjectName,
|
|
232
|
+
id,
|
|
233
|
+
reverseRange,
|
|
65
234
|
]);
|
|
66
|
-
function continuousLegend() {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
-
var itemColor, dataSet, res, legendColors, arrayData_1, d3ColorArrays_1, data, getColorTableScale_1, maxValue_1, rgbValue, i, value, colorScale, svgLegend, defs, linearGradient, currentIndex, xLeg, yLeg, horizontalAxisLeg, VerticalAxisLeg, error_1;
|
|
69
|
-
return __generator(this, function (_a) {
|
|
70
|
-
switch (_a.label) {
|
|
71
|
-
case 0:
|
|
72
|
-
itemColor = [];
|
|
73
|
-
_a.label = 1;
|
|
74
|
-
case 1:
|
|
75
|
-
_a.trys.push([1, 5, , 6]);
|
|
76
|
-
if (!(typeof colorTables === "string")) return [3 /*break*/, 4];
|
|
77
|
-
return [4 /*yield*/, fetch(colorTables)];
|
|
78
|
-
case 2:
|
|
79
|
-
res = _a.sent();
|
|
80
|
-
return [4 /*yield*/, res.json()];
|
|
81
|
-
case 3:
|
|
82
|
-
dataSet = _a.sent();
|
|
83
|
-
_a.label = 4;
|
|
84
|
-
case 4:
|
|
85
|
-
legendColors = typeof colorTables === "string"
|
|
86
|
-
? colorsArray(colorName, dataSet)
|
|
87
|
-
: colorsArray(colorName, colorTables);
|
|
88
|
-
// Update color of legend based on color selector scales
|
|
89
|
-
// data is passed on click upon color scales
|
|
90
|
-
if (getColorScaleData && Object.keys(getColorScaleData).length > 0) {
|
|
91
|
-
// legend using color table data
|
|
92
|
-
if (getColorScaleData.color) {
|
|
93
|
-
legendColors = getColorScaleData.color;
|
|
94
|
-
}
|
|
95
|
-
// legend using d3 data
|
|
96
|
-
else if (getColorScaleData.arrayData) {
|
|
97
|
-
legendColors = getColorScaleData.arrayData;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
// main continuous legend for colortable colors
|
|
101
|
-
if (legendColors.length > 0) {
|
|
102
|
-
legendColors = legendColors;
|
|
103
|
-
}
|
|
104
|
-
// main continuous legend for d3 colors
|
|
105
|
-
else {
|
|
106
|
-
arrayData_1 = [];
|
|
107
|
-
d3ColorArrays_1 = colorsArray(colorName, d3ColorScales);
|
|
108
|
-
data = range(10).map(function (d) { return ({ color: d3ColorArrays_1(d / 10) }); });
|
|
109
|
-
data.forEach(function (colorsObject, index) {
|
|
110
|
-
var _a, _b, _c;
|
|
111
|
-
arrayData_1.push([
|
|
112
|
-
0 + "." + index,
|
|
113
|
-
(_a = color(colorsObject.color)) === null || _a === void 0 ? void 0 : _a.rgb().r,
|
|
114
|
-
(_b = color(colorsObject.color)) === null || _b === void 0 ? void 0 : _b.rgb().g,
|
|
115
|
-
(_c = color(colorsObject.color)) === null || _c === void 0 ? void 0 : _c.rgb().b,
|
|
116
|
-
]);
|
|
117
|
-
});
|
|
118
|
-
legendColors = arrayData_1;
|
|
119
|
-
}
|
|
120
|
-
getColorTableScale_1 = colorTables.find(function (value) {
|
|
121
|
-
if (getColorScaleData) {
|
|
122
|
-
return value.name === (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.name);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
return value.name === colorName;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
maxValue_1 = legendColors.length - 1;
|
|
129
|
-
// if colorMapFunction prop is passed
|
|
130
|
-
if (colorMapFunction) {
|
|
131
|
-
rgbValue = [];
|
|
132
|
-
for (i = 0; i <= 1; i += 0.05) {
|
|
133
|
-
value = colorMapFunction(i);
|
|
134
|
-
rgbValue.push([i.toFixed(2), value[0], value[1], value[2]]);
|
|
135
|
-
}
|
|
136
|
-
legendColors = rgbValue;
|
|
137
|
-
}
|
|
138
|
-
legendColors.forEach(function (value) {
|
|
139
|
-
// return the color and offset needed to draw the legend
|
|
140
|
-
itemColor.push({
|
|
141
|
-
// to support discrete color for continous data
|
|
142
|
-
offset: (getColorTableScale_1 === null || getColorTableScale_1 === void 0 ? void 0 : getColorTableScale_1.discrete) === true
|
|
143
|
-
? RGBToHexValue(value, maxValue_1).offset
|
|
144
|
-
: RGBToHex(value).offset,
|
|
145
|
-
color: RGBToHex(value).color,
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
colorScale = scaleSequential().domain([min, max]);
|
|
149
|
-
svgLegend = select(divRef.current)
|
|
150
|
-
.style("margin-right", "2px")
|
|
151
|
-
.style("margin-left", "2px")
|
|
152
|
-
.append("svg")
|
|
153
|
-
.style("background-color", "#ffffffcc")
|
|
154
|
-
.style("border-radius", "5px");
|
|
155
|
-
defs = svgLegend.append("defs");
|
|
156
|
-
linearGradient = void 0;
|
|
157
|
-
svgLegend
|
|
158
|
-
.attr("width", horizontal ? "190" : "77")
|
|
159
|
-
.attr("height", horizontal ? "70" : "173");
|
|
160
|
-
currentIndex = "linear-gradient-" + id + "0";
|
|
161
|
-
linearGradient = defs
|
|
162
|
-
.append("linearGradient")
|
|
163
|
-
.attr("id", currentIndex)
|
|
164
|
-
.attr("x1", "0%")
|
|
165
|
-
.attr("x2", horizontal ? "100%" : "0%")
|
|
166
|
-
.attr("y1", "0%")
|
|
167
|
-
.attr("y2", horizontal ? "0%" : "100%"); //since it's a vertical linear gradient
|
|
168
|
-
// append multiple color stops by using D3's data/enter step
|
|
169
|
-
linearGradient
|
|
170
|
-
.selectAll("stop")
|
|
171
|
-
.data(itemColor)
|
|
172
|
-
.enter()
|
|
173
|
-
.append("stop")
|
|
174
|
-
.attr("offset", function (data) {
|
|
175
|
-
return data.offset + "%";
|
|
176
|
-
})
|
|
177
|
-
.attr("stop-color", function (data) {
|
|
178
|
-
return data.color;
|
|
179
|
-
});
|
|
180
|
-
// draw the rectangle and fill with gradient
|
|
181
|
-
svgLegend
|
|
182
|
-
.append("rect")
|
|
183
|
-
.attr("x", 25)
|
|
184
|
-
.attr("y", horizontal ? 30 : 18)
|
|
185
|
-
.attr("width", horizontal ? "149" : 20)
|
|
186
|
-
.attr("height", horizontal ? 20 : "149")
|
|
187
|
-
.style("fill", "url(#" + currentIndex + ")");
|
|
188
|
-
// append title
|
|
189
|
-
svgLegend
|
|
190
|
-
.append("text")
|
|
191
|
-
.attr("x", horizontal ? 25 : -168)
|
|
192
|
-
.attr("y", horizontal ? 20 : 15)
|
|
193
|
-
.style("text-anchor", "left")
|
|
194
|
-
.style("transform", horizontal ? "none" : "left")
|
|
195
|
-
.style("transform", horizontal ? "none" : "rotate(270deg)")
|
|
196
|
-
.style("fill", "grey")
|
|
197
|
-
.style("font-size", "small")
|
|
198
|
-
.text(dataObjectName);
|
|
199
|
-
xLeg = scaleLinear().domain([min, max]).range([10, 158]);
|
|
200
|
-
yLeg = scaleLinear().domain([min, max]).range([10, 158]);
|
|
201
|
-
horizontalAxisLeg = axisBottom(xLeg).tickValues(colorScale.domain());
|
|
202
|
-
VerticalAxisLeg = axisRight(yLeg)
|
|
203
|
-
.tickSize(20)
|
|
204
|
-
.tickValues(colorScale.domain());
|
|
205
|
-
svgLegend
|
|
206
|
-
.attr("class", "axis")
|
|
207
|
-
.append("g")
|
|
208
|
-
.attr("transform", horizontal ? "translate(16, 50)" : "translate(25, 7.5)")
|
|
209
|
-
.style("font-size", "10px")
|
|
210
|
-
.style("font-weight", "700")
|
|
211
|
-
.call(horizontal ? horizontalAxisLeg : VerticalAxisLeg)
|
|
212
|
-
.style("height", 15);
|
|
213
|
-
return [3 /*break*/, 6];
|
|
214
|
-
case 5:
|
|
215
|
-
error_1 = _a.sent();
|
|
216
|
-
console.error(error_1);
|
|
217
|
-
return [3 /*break*/, 6];
|
|
218
|
-
case 6: return [2 /*return*/];
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
235
|
return (React.createElement("div", { style: {
|
|
224
236
|
right: position ? position[0] : " ",
|
|
225
237
|
top: position ? position[1] : " ",
|
|
@@ -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,EACL,QAAQ,EACR,WAAW,EACX,aAAa,GACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,MAAM,EACN,WAAW,EACX,eAAe,EACf,UAAU,EACV,SAAS,GACV,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAE3B,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ContinuousLegend.js","sourceRoot":"","sources":["../../../src/component/Legend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EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,wBAAiB,gBAAgB,CAAE,EACjD,GAAG,EAAE,MAAM,GACN,CACH,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG;IAC9B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;CAClB,CAAC"}
|
|
@@ -11,6 +11,7 @@ declare const _default: ComponentMeta<React.FC<{
|
|
|
11
11
|
id?: string;
|
|
12
12
|
colorTables?: import("../colorTableTypes").colorTablesArray;
|
|
13
13
|
colorMapFunction?: any;
|
|
14
|
+
reverseRange?: boolean;
|
|
14
15
|
}>>;
|
|
15
16
|
export default _default;
|
|
16
17
|
export declare const StandardColorTableLibrary: any;
|
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { colorTablesArray } from "../colorTableTypes";
|
|
3
3
|
declare type discreteLegendProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Discrete data to build legend
|
|
6
|
+
*/
|
|
4
7
|
discreteData: {
|
|
5
8
|
objects: Record<string, [number[], number]>;
|
|
6
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Title for the legend
|
|
12
|
+
*/
|
|
7
13
|
dataObjectName: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify the position
|
|
16
|
+
*/
|
|
8
17
|
position?: number[] | null;
|
|
18
|
+
/**
|
|
19
|
+
* Name of the color(ex: Rainbow)
|
|
20
|
+
*/
|
|
9
21
|
colorName: string;
|
|
22
|
+
/**
|
|
23
|
+
* Orientation for legend
|
|
24
|
+
*/
|
|
10
25
|
horizontal?: boolean | null;
|
|
26
|
+
/**
|
|
27
|
+
* Used while using color selector component
|
|
28
|
+
*
|
|
29
|
+
* Returns the object with name and array of colors
|
|
30
|
+
*/
|
|
11
31
|
getColorScaleData?: any;
|
|
32
|
+
/**
|
|
33
|
+
* ID
|
|
34
|
+
*/
|
|
12
35
|
id?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Prop containing color table data
|
|
38
|
+
*
|
|
39
|
+
* Reference: https://github.com/emerson-eps/color-tables/blob/main/react-app/src/component/color-tables.json
|
|
40
|
+
*/
|
|
13
41
|
colorTables: colorTablesArray | string;
|
|
14
42
|
};
|
|
15
43
|
export declare const DiscreteColorLegend: React.FC<discreteLegendProps>;
|