@devgateway/dvz-wp-commons 1.2.0 → 1.3.0
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/build/APIConfig.cjs +479 -0
- package/build/APIConfig.d.ts +12 -0
- package/build/APIConfig.js +367 -283
- package/build/APIutils.cjs +54 -0
- package/build/APIutils.js +7 -1
- package/build/Blocks.cjs +672 -0
- package/build/Blocks.d.ts +14 -1
- package/build/Blocks.js +523 -330
- package/build/CSVSourceConfig.cjs +99 -0
- package/build/CSVSourceConfig.js +63 -46
- package/build/ChartColors.cjs +593 -0
- package/build/ChartColors.d.ts +0 -1
- package/build/ChartColors.js +430 -366
- package/build/ChartLegends.cjs +157 -0
- package/build/ChartLegends.d.ts +0 -1
- package/build/ChartLegends.js +173 -54
- package/build/ChartMeasures.cjs +192 -0
- package/build/ChartMeasures.d.ts +0 -1
- package/build/ChartMeasures.js +197 -109
- package/build/Constants.cjs +21 -0
- package/build/Constants.js +3 -1
- package/build/DataFilters.cjs +176 -0
- package/build/DataFilters.js +100 -89
- package/build/Format.cjs +1038 -0
- package/build/Format.js +428 -378
- package/build/MapCSVSourceConfig.cjs +36 -0
- package/build/MapCSVSourceConfig.js +19 -8
- package/build/Measures.cjs +196 -0
- package/build/Measures.js +204 -108
- package/build/MobileConfigUtils.cjs +92 -0
- package/build/MobileConfigUtils.js +19 -8
- package/build/Tooltip.cjs +63 -0
- package/build/Tooltip.d.ts +1 -3
- package/build/Tooltip.js +27 -51
- package/build/Util.cjs +29 -0
- package/build/Util.js +7 -7
- package/build/hooks/index.cjs +1 -0
- package/build/hooks/index.js +0 -3
- package/build/icons/Chart.cjs +49 -0
- package/build/icons/Chart.d.ts +1 -2
- package/build/icons/Chart.js +10 -11
- package/build/icons/Generic.cjs +24 -0
- package/build/icons/Generic.d.ts +1 -2
- package/build/icons/Generic.js +25 -4
- package/build/icons/index.cjs +19 -0
- package/build/icons/index.js +2 -2
- package/build/index.cjs +225 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +47 -16
- package/package.json +16 -7
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sequential = exports.diverging = exports.categorical = exports.ChartColors = void 0;
|
|
7
|
+
var _components = require("@wordpress/components");
|
|
8
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
9
|
+
var _i18n = require("@wordpress/i18n");
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _papaparse = _interopRequireDefault(require("papaparse"));
|
|
12
|
+
var _element = require("@wordpress/element");
|
|
13
|
+
var _APIutils = require("./APIutils.cjs");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const OVERALL = "Overall";
|
|
16
|
+
const system = [{
|
|
17
|
+
value: "system",
|
|
18
|
+
label: "System Colors"
|
|
19
|
+
}, {
|
|
20
|
+
value: "manual",
|
|
21
|
+
label: "Manual Colors"
|
|
22
|
+
}];
|
|
23
|
+
const categorical = exports.categorical = [{
|
|
24
|
+
value: "nivo",
|
|
25
|
+
label: "nivo"
|
|
26
|
+
}, {
|
|
27
|
+
value: "category10",
|
|
28
|
+
label: "category10"
|
|
29
|
+
}, {
|
|
30
|
+
value: "accent",
|
|
31
|
+
label: "Accent"
|
|
32
|
+
}, {
|
|
33
|
+
value: "dark2",
|
|
34
|
+
label: "dark2"
|
|
35
|
+
}, {
|
|
36
|
+
value: "paired",
|
|
37
|
+
label: "paired"
|
|
38
|
+
}, {
|
|
39
|
+
value: "pastel1",
|
|
40
|
+
label: "pastel1"
|
|
41
|
+
}, {
|
|
42
|
+
value: "pastel2",
|
|
43
|
+
label: "pastel2"
|
|
44
|
+
}, {
|
|
45
|
+
value: "set1",
|
|
46
|
+
label: "set1"
|
|
47
|
+
}, {
|
|
48
|
+
value: "set2",
|
|
49
|
+
label: "set2"
|
|
50
|
+
}, {
|
|
51
|
+
value: "set3",
|
|
52
|
+
label: "set3"
|
|
53
|
+
}];
|
|
54
|
+
const sequential = exports.sequential = [{
|
|
55
|
+
value: "blues",
|
|
56
|
+
label: "blues"
|
|
57
|
+
}, {
|
|
58
|
+
value: "greens",
|
|
59
|
+
label: "greens"
|
|
60
|
+
}, {
|
|
61
|
+
value: "greys",
|
|
62
|
+
label: "greys"
|
|
63
|
+
}, {
|
|
64
|
+
value: "oranges",
|
|
65
|
+
label: "oranges"
|
|
66
|
+
}, {
|
|
67
|
+
value: "purples",
|
|
68
|
+
label: "purples"
|
|
69
|
+
}, {
|
|
70
|
+
value: "reds",
|
|
71
|
+
label: "reds"
|
|
72
|
+
}, {
|
|
73
|
+
value: "blue_green",
|
|
74
|
+
label: "blue_green"
|
|
75
|
+
}, {
|
|
76
|
+
value: "blue_purple",
|
|
77
|
+
label: "blue_purple"
|
|
78
|
+
}, {
|
|
79
|
+
value: "green_blue",
|
|
80
|
+
label: "green_blue"
|
|
81
|
+
}, {
|
|
82
|
+
value: "orange_red",
|
|
83
|
+
label: "orange_red"
|
|
84
|
+
}, {
|
|
85
|
+
value: "purple_blue_green",
|
|
86
|
+
label: "purple_blue_green"
|
|
87
|
+
}, {
|
|
88
|
+
value: "purple_blue",
|
|
89
|
+
label: "purple_blue"
|
|
90
|
+
}, {
|
|
91
|
+
value: "purple_red",
|
|
92
|
+
label: "purple_red"
|
|
93
|
+
}, {
|
|
94
|
+
value: "red_purple",
|
|
95
|
+
label: "red_purple"
|
|
96
|
+
}, {
|
|
97
|
+
value: "yellow_green_blue",
|
|
98
|
+
label: "yellow_green_blue"
|
|
99
|
+
}, {
|
|
100
|
+
value: "yellow_green",
|
|
101
|
+
label: "yellow_green"
|
|
102
|
+
}, {
|
|
103
|
+
value: "yellow_orange_brown",
|
|
104
|
+
label: "yellow_orange_brown"
|
|
105
|
+
}, {
|
|
106
|
+
value: "yellow_orange_red",
|
|
107
|
+
label: "yellow_orange_brown"
|
|
108
|
+
}];
|
|
109
|
+
const diverging = exports.diverging = [{
|
|
110
|
+
value: "brown_blueGreen",
|
|
111
|
+
label: "brown_blueGreen"
|
|
112
|
+
}, {
|
|
113
|
+
value: "purpleRed_green",
|
|
114
|
+
label: "purpleRed_green"
|
|
115
|
+
}, {
|
|
116
|
+
value: "pink_yellowGreen",
|
|
117
|
+
label: "pink_yellowGreen"
|
|
118
|
+
}, {
|
|
119
|
+
value: "purple_orange",
|
|
120
|
+
label: "purple_orange"
|
|
121
|
+
}, {
|
|
122
|
+
value: "red_blue",
|
|
123
|
+
label: "red_blue"
|
|
124
|
+
}, {
|
|
125
|
+
value: "red_grey",
|
|
126
|
+
label: "red_grey"
|
|
127
|
+
}, {
|
|
128
|
+
value: "red_yellow_blue",
|
|
129
|
+
label: "red_yellow_blue"
|
|
130
|
+
}, {
|
|
131
|
+
value: "red_yellow_green",
|
|
132
|
+
label: "red_yellow_green"
|
|
133
|
+
}, {
|
|
134
|
+
value: "spectral",
|
|
135
|
+
label: "spectral"
|
|
136
|
+
}];
|
|
137
|
+
const plainColor = {
|
|
138
|
+
value: "plain_color",
|
|
139
|
+
label: "Use Plain color"
|
|
140
|
+
};
|
|
141
|
+
const ChartColors = props => {
|
|
142
|
+
const {
|
|
143
|
+
allDimensions,
|
|
144
|
+
allFilters,
|
|
145
|
+
allMeasures,
|
|
146
|
+
allCategories,
|
|
147
|
+
allApps,
|
|
148
|
+
setAttributes,
|
|
149
|
+
attributes: {
|
|
150
|
+
swap,
|
|
151
|
+
measures,
|
|
152
|
+
manualColors,
|
|
153
|
+
scheme,
|
|
154
|
+
colorBy,
|
|
155
|
+
dimension1,
|
|
156
|
+
dimension2,
|
|
157
|
+
barColor,
|
|
158
|
+
type,
|
|
159
|
+
app,
|
|
160
|
+
csv,
|
|
161
|
+
includeOverall
|
|
162
|
+
}
|
|
163
|
+
} = props;
|
|
164
|
+
let l1Label;
|
|
165
|
+
let d2Label;
|
|
166
|
+
let d3Label;
|
|
167
|
+
const selectedMeasures = measures[app] ? Object.keys(measures[app]).map(k => measures[app][k]).filter(m => m.selected) : [];
|
|
168
|
+
let colorOptions = [];
|
|
169
|
+
if (app !== "csv") {
|
|
170
|
+
l1Label = dimension1 != "none" && allDimensions ? "1st Dimension - " + allDimensions.filter(d => d.value == dimension1)[0].label : null;
|
|
171
|
+
if (dimension2 == "none" && selectedMeasures.length > 0) {
|
|
172
|
+
d2Label = (0, _i18n.__)("Measure Labels");
|
|
173
|
+
d3Label = (0, _i18n.__)("Measure Values");
|
|
174
|
+
} else if (dimension2 != "none") {
|
|
175
|
+
d2Label = allDimensions ? "2nd Dimension - " + allDimensions.filter(d => d.value == dimension2)[0].label : null;
|
|
176
|
+
d3Label = (0, _i18n.__)("Measure Values");
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
const data = _papaparse.default.parse(csv, {
|
|
180
|
+
header: true,
|
|
181
|
+
dynamicTyping: true
|
|
182
|
+
});
|
|
183
|
+
l1Label = data.meta.fields.length > 0 ? "1st Column Values " : null;
|
|
184
|
+
d2Label = (0, _i18n.__)("Measure Columns Labels");
|
|
185
|
+
d3Label = (0, _i18n.__)("Measure Columns Values");
|
|
186
|
+
}
|
|
187
|
+
if (type == "bar" || type == "line") {
|
|
188
|
+
if (swap && dimension2 == "none" && selectedMeasures.length > 0) {
|
|
189
|
+
colorOptions = [];
|
|
190
|
+
if (l1Label) {
|
|
191
|
+
colorOptions.push({
|
|
192
|
+
label: l1Label,
|
|
193
|
+
value: "id"
|
|
194
|
+
});
|
|
195
|
+
colorOptions.push({
|
|
196
|
+
label: d2Label,
|
|
197
|
+
value: "index"
|
|
198
|
+
});
|
|
199
|
+
} else {
|
|
200
|
+
colorOptions.push({
|
|
201
|
+
label: d2Label,
|
|
202
|
+
value: "id"
|
|
203
|
+
});
|
|
204
|
+
colorOptions.push({
|
|
205
|
+
label: "Measure Values",
|
|
206
|
+
value: "values"
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
colorOptions = [];
|
|
211
|
+
if (l1Label && l1Label !== "none") {
|
|
212
|
+
colorOptions.push({
|
|
213
|
+
label: l1Label,
|
|
214
|
+
value: "index"
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (d2Label && d2Label !== "none") {
|
|
218
|
+
colorOptions.push({
|
|
219
|
+
label: d2Label,
|
|
220
|
+
value: l1Label && l1Label !== "none" ? "id" : "index"
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (d3Label && d3Label !== "none") {
|
|
224
|
+
colorOptions.push({
|
|
225
|
+
label: d3Label,
|
|
226
|
+
value: "values"
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (type == "pie") {
|
|
232
|
+
if (dimension1 != "none" && dimension2 == "none" && colorBy != "index") {
|
|
233
|
+
setAttributes({
|
|
234
|
+
colorBy: "index"
|
|
235
|
+
});
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
if (dimension1 != "none" && dimension2 != "none" && colorBy != "id") {
|
|
239
|
+
setAttributes({
|
|
240
|
+
colorBy: "id"
|
|
241
|
+
});
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
let options = [];
|
|
246
|
+
if (colorBy === "index" || colorBy === "id") {
|
|
247
|
+
if (type == "bar") {
|
|
248
|
+
options = [...system, plainColor, ...categorical, ...sequential];
|
|
249
|
+
} else if (type == "line") {
|
|
250
|
+
options = [...system, plainColor, ...categorical];
|
|
251
|
+
} else {
|
|
252
|
+
options = [...system, ...categorical, ...sequential];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (colorBy === "values") {
|
|
256
|
+
options = [...sequential];
|
|
257
|
+
}
|
|
258
|
+
const [useColors, setUseColors] = (0, _element.useState)("dimension");
|
|
259
|
+
(0, _react.useEffect)(() => {
|
|
260
|
+
let nextUseColors = useColors;
|
|
261
|
+
if (app != "csv") {
|
|
262
|
+
if (dimension2 == "none" && colorBy === "index" && swap || dimension1 == "none" && dimension2 == "none") {
|
|
263
|
+
nextUseColors = "measure";
|
|
264
|
+
} else if (dimension2 == "none" && colorBy === "id" && !swap) {
|
|
265
|
+
nextUseColors = "measure";
|
|
266
|
+
} else {
|
|
267
|
+
nextUseColors = "dimension";
|
|
268
|
+
}
|
|
269
|
+
if (prevStatus.current) {
|
|
270
|
+
if (nextUseColors == "dimension") {
|
|
271
|
+
if (prevStatus.current["scheme"] != scheme && scheme === "manual") {
|
|
272
|
+
initColors(colorBy === "index" ? dimension1 : dimension2);
|
|
273
|
+
}
|
|
274
|
+
if (prevStatus.current["colorBy"] != colorBy) {
|
|
275
|
+
initColors(colorBy === "index" ? dimension1 : dimension2);
|
|
276
|
+
}
|
|
277
|
+
if (prevStatus.current["dimension1"] != dimension1 || prevStatus.current["dimension2"] != dimension2) {
|
|
278
|
+
initColors(colorBy === "index" ? dimension1 : dimension2);
|
|
279
|
+
}
|
|
280
|
+
} else {
|
|
281
|
+
initMeasuresColors();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
setUseColors(nextUseColors);
|
|
285
|
+
} else {
|
|
286
|
+
if (!manualColors["csv"]) {
|
|
287
|
+
setAttributes({
|
|
288
|
+
manualColors: {
|
|
289
|
+
"csv": {}
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
prevStatus.current = {
|
|
295
|
+
scheme,
|
|
296
|
+
colorBy,
|
|
297
|
+
dimension1,
|
|
298
|
+
dimension2,
|
|
299
|
+
useColors,
|
|
300
|
+
app
|
|
301
|
+
};
|
|
302
|
+
}, [scheme, dimension1, dimension2, colorBy, swap, app, type]);
|
|
303
|
+
const prevStatus = (0, _element.useRef)();
|
|
304
|
+
const updateColor = (value, color, colorByMode = null) => {
|
|
305
|
+
const newColors = Object.assign({}, manualColors);
|
|
306
|
+
if (colorByMode) {
|
|
307
|
+
if (!newColors[app][colorByMode]) {
|
|
308
|
+
newColors[app][colorByMode] = {};
|
|
309
|
+
}
|
|
310
|
+
newColors[app][colorByMode][value] = color;
|
|
311
|
+
} else {
|
|
312
|
+
newColors[app][value] = color;
|
|
313
|
+
}
|
|
314
|
+
setAttributes({
|
|
315
|
+
manualColors: newColors
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
const initColors = dimension => {
|
|
319
|
+
const ds = allDimensions.filter(d => d.value == dimension);
|
|
320
|
+
const newColors = Object.assign({}, manualColors);
|
|
321
|
+
if (!newColors[app]) {
|
|
322
|
+
newColors[app] = {};
|
|
323
|
+
}
|
|
324
|
+
if (ds.length > 0) {
|
|
325
|
+
const {
|
|
326
|
+
type: type2
|
|
327
|
+
} = ds[0];
|
|
328
|
+
const cat = allCategories.filter(a => a.type === type2);
|
|
329
|
+
if (cat.length > 0) {
|
|
330
|
+
cat[0].items.forEach(item => {
|
|
331
|
+
if (!newColors[app][item.code]) {
|
|
332
|
+
newColors[app][item.code] = item.categoryStyle ? item.categoryStyle.color : "#eeeeee";
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
setAttributes({
|
|
337
|
+
manualColors: newColors
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
const initMeasuresColors = () => {
|
|
342
|
+
const newColors = Object.assign({}, manualColors);
|
|
343
|
+
if (!newColors[app]) {
|
|
344
|
+
newColors[app] = {};
|
|
345
|
+
}
|
|
346
|
+
if (!allMeasures) {}
|
|
347
|
+
if (allMeasures) {
|
|
348
|
+
allMeasures.forEach(p => {
|
|
349
|
+
if (!newColors[app][p.value]) {
|
|
350
|
+
newColors[app][p.value] = p.styles ? p.styles.color : "#eeeeee";
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
setAttributes({
|
|
355
|
+
manualColors: newColors
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
const combinedCatColors = (dimension12, dimension22) => {
|
|
359
|
+
if (manualColors[app]) {
|
|
360
|
+
const ds1 = allDimensions.filter(d => d.value == dimension12);
|
|
361
|
+
const ds2 = allDimensions.filter(d => d.value == dimension22);
|
|
362
|
+
if (ds1.length > 0 && ds2.length > 0) {
|
|
363
|
+
const {
|
|
364
|
+
type: type2
|
|
365
|
+
} = ds1[0];
|
|
366
|
+
const {
|
|
367
|
+
type: type22
|
|
368
|
+
} = ds2[0];
|
|
369
|
+
const cat = allCategories.filter(a => a.type === type2);
|
|
370
|
+
const cat2 = allCategories.filter(a => a.type === type22);
|
|
371
|
+
const list = [];
|
|
372
|
+
cat[0].items.sort((a, b) => a.position - b.position).forEach(c1 => {
|
|
373
|
+
cat2[0].items.sort((a, b) => a.position - b.position).forEach(c2 => {
|
|
374
|
+
list.push(/* @__PURE__ */React.createElement(_blockEditor.PanelColorSettings, {
|
|
375
|
+
colorSettings: [{
|
|
376
|
+
value: manualColors[app][c1.value + " - " + c2.value],
|
|
377
|
+
onChange: color => {
|
|
378
|
+
if (color) {
|
|
379
|
+
updateColor(c1.value + " - " + c2.value, color);
|
|
380
|
+
} else {
|
|
381
|
+
updateColor(c1.value + " - " + c2.value, "#eeeeee");
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
label: c1.value + " - " + c2.value
|
|
385
|
+
}]
|
|
386
|
+
}));
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
return list;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return null;
|
|
393
|
+
};
|
|
394
|
+
const catColors = dimension => {
|
|
395
|
+
if (manualColors[app]) {
|
|
396
|
+
const ds = allDimensions.filter(d => d.value == dimension);
|
|
397
|
+
if (ds.length > 0) {
|
|
398
|
+
const {
|
|
399
|
+
type: type2
|
|
400
|
+
} = ds[0];
|
|
401
|
+
const cat = allCategories.filter(a => a.type === type2);
|
|
402
|
+
if (cat && cat.length > 0) {
|
|
403
|
+
const list = cat[0].items.filter(c => c.code !== null && c.code !== void 0 && c.code !== "").sort((a, b) => b.position - a.position).map(item => {
|
|
404
|
+
return /* @__PURE__ */React.createElement(_blockEditor.PanelColorSettings, {
|
|
405
|
+
colorSettings: [{
|
|
406
|
+
value: manualColors[app][item.code],
|
|
407
|
+
onChange: color => {
|
|
408
|
+
if (color) {
|
|
409
|
+
updateColor(item.code, color);
|
|
410
|
+
} else {
|
|
411
|
+
updateColor(item.code, item.categoryStyle ? item.categoryStyle.color : "#eeeeee");
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
label: (0, _APIutils.getTranslation)(item)
|
|
415
|
+
}]
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
const dimensions = [dimension1, dimension2].filter(f => f != "" && f != "none");
|
|
419
|
+
let selectedMeasures2 = [];
|
|
420
|
+
allMeasures.forEach(m => {
|
|
421
|
+
if (measures[app] && measures[app][m.value] && measures[app][m.value].selected) {
|
|
422
|
+
selectedMeasures2.push(m.value);
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
if (includeOverall) {
|
|
426
|
+
list.push(/* @__PURE__ */React.createElement(_blockEditor.PanelColorSettings, {
|
|
427
|
+
colorSettings: [{
|
|
428
|
+
value: manualColors[app][OVERALL],
|
|
429
|
+
onChange: color => {
|
|
430
|
+
if (color) {
|
|
431
|
+
updateColor(OVERALL, color);
|
|
432
|
+
} else {
|
|
433
|
+
updateColor(OVERALL, "#eeeeee");
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
label: (0, _i18n.__)("Overall")
|
|
437
|
+
}]
|
|
438
|
+
}));
|
|
439
|
+
}
|
|
440
|
+
return list;
|
|
441
|
+
} else {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return null;
|
|
447
|
+
};
|
|
448
|
+
const measureColors = () => {
|
|
449
|
+
if (manualColors[app] && allMeasures && measures[app]) {
|
|
450
|
+
const selectedMeasures2 = allMeasures.filter(m => Object.keys(measures[app]).indexOf(m.value) > -1 && measures[app][m.value].selected);
|
|
451
|
+
if (selectedMeasures2.length > 0) {
|
|
452
|
+
const list = selectedMeasures2.sort((a, b) => b.position - a.position).map(item => {
|
|
453
|
+
return /* @__PURE__ */React.createElement(_blockEditor.PanelColorSettings, {
|
|
454
|
+
colorSettings: [{
|
|
455
|
+
value: manualColors[app][item.value],
|
|
456
|
+
onChange: color => {
|
|
457
|
+
if (color) {
|
|
458
|
+
updateColor(item.value, color);
|
|
459
|
+
} else {
|
|
460
|
+
updateColor(item.value, item.styles ? item.styles.color : "#555555");
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
label: (0, _i18n.__)(item.label)
|
|
464
|
+
}]
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
if (includeOverall && selectedMeasures2.length == 1) {
|
|
468
|
+
list.push(/* @__PURE__ */React.createElement(_blockEditor.PanelColorSettings, {
|
|
469
|
+
colorSettings: [{
|
|
470
|
+
value: manualColors[app][OVERALL],
|
|
471
|
+
onChange: color => {
|
|
472
|
+
if (color) {
|
|
473
|
+
updateColor(OVERALL, color);
|
|
474
|
+
} else {
|
|
475
|
+
updateColor(OVERALL, "#eeeeee");
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
label: (0, _i18n.__)("Overall")
|
|
479
|
+
}]
|
|
480
|
+
}));
|
|
481
|
+
}
|
|
482
|
+
return list;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return null;
|
|
486
|
+
};
|
|
487
|
+
const csvColors = () => {
|
|
488
|
+
const data = _papaparse.default.parse(csv, {
|
|
489
|
+
header: true,
|
|
490
|
+
dynamicTyping: true
|
|
491
|
+
});
|
|
492
|
+
const values = [];
|
|
493
|
+
if (colorBy === "index" && type != "line" || type == "pie") {
|
|
494
|
+
const field = data.meta.fields[0];
|
|
495
|
+
values.push(...data.data.map(d => d[field]));
|
|
496
|
+
}
|
|
497
|
+
if (colorBy === "id" || type == "line") {
|
|
498
|
+
values.push(...data.meta.fields.slice(1));
|
|
499
|
+
}
|
|
500
|
+
if (colorBy === "values") {
|
|
501
|
+
values.push(0, 100);
|
|
502
|
+
}
|
|
503
|
+
if (manualColors[app] && values) {
|
|
504
|
+
return values.map(v => {
|
|
505
|
+
const colorByColors = manualColors[app][colorBy] || {};
|
|
506
|
+
return /* @__PURE__ */React.createElement(_blockEditor.PanelColorSettings, {
|
|
507
|
+
colorSettings: [{
|
|
508
|
+
value: colorByColors[v],
|
|
509
|
+
onChange: color => {
|
|
510
|
+
if (color) {
|
|
511
|
+
updateColor(v, color, colorBy);
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
label: (0, _i18n.__)(v)
|
|
515
|
+
}]
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
return null;
|
|
520
|
+
};
|
|
521
|
+
const elements = [];
|
|
522
|
+
if (type == "bar" || type == "line") {
|
|
523
|
+
elements.push(/* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.SelectControl, {
|
|
524
|
+
label: (0, _i18n.__)("Color By"),
|
|
525
|
+
value: [colorBy],
|
|
526
|
+
onChange: colorBy2 => {
|
|
527
|
+
setAttributes({
|
|
528
|
+
colorBy: colorBy2
|
|
529
|
+
});
|
|
530
|
+
if (colorBy2 === "index" || colorBy2 === "id") {
|
|
531
|
+
setAttributes({
|
|
532
|
+
colorBy: colorBy2
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
if (colorBy2 === "values") {
|
|
536
|
+
setAttributes({
|
|
537
|
+
scheme: "blues",
|
|
538
|
+
colorBy: colorBy2
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
options: colorOptions
|
|
543
|
+
})));
|
|
544
|
+
}
|
|
545
|
+
if (type == "pie") {
|
|
546
|
+
setAttributes({
|
|
547
|
+
colorBy: "index"
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
return [...elements, /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.SelectControl, {
|
|
551
|
+
label: (0, _i18n.__)("Color Scheme"),
|
|
552
|
+
value: [scheme],
|
|
553
|
+
onChange: value => {
|
|
554
|
+
setAttributes({
|
|
555
|
+
scheme: value
|
|
556
|
+
});
|
|
557
|
+
},
|
|
558
|
+
options
|
|
559
|
+
})), scheme == "plain_color" && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_blockEditor.PanelColorSettings, {
|
|
560
|
+
title: (0, _i18n.__)("Color settings"),
|
|
561
|
+
colorSettings: [{
|
|
562
|
+
value: decodeURIComponent(barColor),
|
|
563
|
+
onChange: color => {
|
|
564
|
+
if (color) {
|
|
565
|
+
setAttributes({
|
|
566
|
+
barColor: encodeURIComponent(color)
|
|
567
|
+
});
|
|
568
|
+
} else {
|
|
569
|
+
setAttributes({
|
|
570
|
+
barColor: null
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
label: (0, _i18n.__)("Plain color")
|
|
575
|
+
}]
|
|
576
|
+
})), scheme == "manual" && /* @__PURE__ */React.createElement(_components.PanelRow, null, app != "csv" && useColors == "dimension" && colorBy == "index" && /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
577
|
+
initialOpen: false,
|
|
578
|
+
title: (0, _i18n.__)("Set Colors")
|
|
579
|
+
}, catColors(dimension1)), app != "csv" && useColors == "dimension" && colorBy == "id" && dimension2 != "none" && /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
580
|
+
initialOpen: false,
|
|
581
|
+
title: (0, _i18n.__)("Set Colors")
|
|
582
|
+
}, type == "bar" && catColors(dimension2), type == "line" && catColors(dimension2), type == "pie" && combinedCatColors(dimension1, dimension2)), app != "csv" && useColors == "dimension" && swap && colorBy == "id" && dimension1 != "none" && dimension2 == "none" && /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
583
|
+
initialOpen: false,
|
|
584
|
+
title: (0, _i18n.__)("Set Colors")
|
|
585
|
+
}, catColors(dimension1)), app != "csv" && useColors === "measure" && /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
586
|
+
initialOpen: false,
|
|
587
|
+
title: (0, _i18n.__)("Set Color By Measure")
|
|
588
|
+
}, measureColors()), app == "csv" && /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
589
|
+
initialOpen: false,
|
|
590
|
+
title: (0, _i18n.__)("Set Colors")
|
|
591
|
+
}, csvColors(colorBy)))];
|
|
592
|
+
};
|
|
593
|
+
exports.ChartColors = ChartColors;
|
package/build/ChartColors.d.ts
CHANGED