@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
package/build/ChartColors.js
CHANGED
|
@@ -1,388 +1,452 @@
|
|
|
1
|
-
import { PanelBody, PanelRow, SelectControl } from
|
|
2
|
-
import { PanelColorSettings } from
|
|
3
|
-
import { __ } from
|
|
1
|
+
import { PanelBody, PanelRow, SelectControl } from "@wordpress/components";
|
|
2
|
+
import { PanelColorSettings } from "@wordpress/block-editor";
|
|
3
|
+
import { __ } from "@wordpress/i18n";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
|
-
import Papa from
|
|
5
|
+
import Papa from "papaparse";
|
|
6
6
|
import { useRef, useState } from "@wordpress/element";
|
|
7
|
-
import { getTranslation } from "./APIutils";
|
|
8
|
-
const OVERALL =
|
|
9
|
-
const system = [{ value: "system", label:
|
|
10
|
-
export const categorical = [{ value: "nivo", label:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
7
|
+
import { getTranslation } from "./APIutils.js";
|
|
8
|
+
const OVERALL = "Overall";
|
|
9
|
+
const system = [{ value: "system", label: "System Colors" }, { value: "manual", label: "Manual Colors" }];
|
|
10
|
+
export const categorical = [{ value: "nivo", label: "nivo" }, {
|
|
11
|
+
value: "category10",
|
|
12
|
+
label: "category10"
|
|
13
|
+
}, { value: "accent", label: "Accent" }, { value: "dark2", label: "dark2" }, {
|
|
14
|
+
value: "paired",
|
|
15
|
+
label: "paired"
|
|
16
|
+
}, { value: "pastel1", label: "pastel1" }, { value: "pastel2", label: "pastel2" }, {
|
|
17
|
+
value: "set1",
|
|
18
|
+
label: "set1"
|
|
19
|
+
}, { value: "set2", label: "set2" }, { value: "set3", label: "set3" }];
|
|
20
|
+
export const sequential = [{ value: "blues", label: "blues" }, { value: "greens", label: "greens" }, {
|
|
21
|
+
value: "greys",
|
|
22
|
+
label: "greys"
|
|
23
|
+
}, { value: "oranges", label: "oranges" }, { value: "purples", label: "purples" }, {
|
|
24
|
+
value: "reds",
|
|
25
|
+
label: "reds"
|
|
26
|
+
}, { value: "blue_green", label: "blue_green" }, { value: "blue_purple", label: "blue_purple" }, {
|
|
27
|
+
value: "green_blue",
|
|
28
|
+
label: "green_blue"
|
|
29
|
+
}, { value: "orange_red", label: "orange_red" }, {
|
|
30
|
+
value: "purple_blue_green",
|
|
31
|
+
label: "purple_blue_green"
|
|
32
|
+
}, { value: "purple_blue", label: "purple_blue" }, { value: "purple_red", label: "purple_red" }, {
|
|
33
|
+
value: "red_purple",
|
|
34
|
+
label: "red_purple"
|
|
35
|
+
}, { value: "yellow_green_blue", label: "yellow_green_blue" }, {
|
|
36
|
+
value: "yellow_green",
|
|
37
|
+
label: "yellow_green"
|
|
38
|
+
}, { value: "yellow_orange_brown", label: "yellow_orange_brown" }, {
|
|
39
|
+
value: "yellow_orange_red",
|
|
40
|
+
label: "yellow_orange_brown"
|
|
41
|
+
}];
|
|
42
|
+
export const diverging = [
|
|
43
|
+
{ value: "brown_blueGreen", label: "brown_blueGreen" },
|
|
44
|
+
{ value: "purpleRed_green", label: "purpleRed_green" },
|
|
45
|
+
{ value: "pink_yellowGreen", label: "pink_yellowGreen" },
|
|
46
|
+
{ value: "purple_orange", label: "purple_orange" },
|
|
47
|
+
{ value: "red_blue", label: "red_blue" },
|
|
48
|
+
{ value: "red_grey", label: "red_grey" },
|
|
49
|
+
{ value: "red_yellow_blue", label: "red_yellow_blue" },
|
|
50
|
+
{ value: "red_yellow_green", label: "red_yellow_green" },
|
|
51
|
+
{ value: "spectral", label: "spectral" }
|
|
41
52
|
];
|
|
42
|
-
const plainColor = { value: "plain_color", label:
|
|
53
|
+
const plainColor = { value: "plain_color", label: "Use Plain color" };
|
|
43
54
|
export const ChartColors = (props) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const {
|
|
56
|
+
allDimensions,
|
|
57
|
+
allFilters,
|
|
58
|
+
allMeasures,
|
|
59
|
+
allCategories,
|
|
60
|
+
allApps,
|
|
61
|
+
setAttributes,
|
|
62
|
+
attributes: {
|
|
63
|
+
swap,
|
|
64
|
+
measures,
|
|
65
|
+
manualColors,
|
|
66
|
+
scheme,
|
|
67
|
+
colorBy,
|
|
68
|
+
dimension1,
|
|
69
|
+
dimension2,
|
|
70
|
+
barColor,
|
|
71
|
+
type,
|
|
72
|
+
app,
|
|
73
|
+
csv,
|
|
74
|
+
includeOverall
|
|
62
75
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
} = props;
|
|
77
|
+
let l1Label;
|
|
78
|
+
let d2Label;
|
|
79
|
+
let d3Label;
|
|
80
|
+
const selectedMeasures = measures[app] ? Object.keys(measures[app]).map((k) => measures[app][k]).filter((m) => m.selected) : [];
|
|
81
|
+
let colorOptions = [];
|
|
82
|
+
if (app !== "csv") {
|
|
83
|
+
l1Label = dimension1 != "none" && allDimensions ? "1st Dimension - " + allDimensions.filter((d) => d.value == dimension1)[0].label : null;
|
|
84
|
+
if (dimension2 == "none" && selectedMeasures.length > 0) {
|
|
85
|
+
d2Label = __("Measure Labels");
|
|
86
|
+
d3Label = __("Measure Values");
|
|
87
|
+
} else if (dimension2 != "none") {
|
|
88
|
+
d2Label = allDimensions ? "2nd Dimension - " + allDimensions.filter((d) => d.value == dimension2)[0].label : null;
|
|
89
|
+
d3Label = __("Measure Values");
|
|
69
90
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
} else {
|
|
92
|
+
const data = Papa.parse(csv, { header: true, dynamicTyping: true });
|
|
93
|
+
l1Label = data.meta.fields.length > 0 ? "1st Column Values " : null;
|
|
94
|
+
d2Label = __("Measure Columns Labels");
|
|
95
|
+
d3Label = __("Measure Columns Values");
|
|
96
|
+
}
|
|
97
|
+
if (type == "bar" || type == "line") {
|
|
98
|
+
if (swap && dimension2 == "none" && selectedMeasures.length > 0) {
|
|
99
|
+
colorOptions = [];
|
|
100
|
+
if (l1Label) {
|
|
101
|
+
colorOptions.push({ label: l1Label, value: "id" });
|
|
102
|
+
colorOptions.push({ label: d2Label, value: "index" });
|
|
103
|
+
} else {
|
|
104
|
+
colorOptions.push({ label: d2Label, value: "id" });
|
|
105
|
+
colorOptions.push({ label: "Measure Values", value: "values" });
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
colorOptions = [];
|
|
109
|
+
if (l1Label && l1Label !== "none") {
|
|
110
|
+
colorOptions.push({ label: l1Label, value: "index" });
|
|
111
|
+
}
|
|
112
|
+
if (d2Label && d2Label !== "none") {
|
|
113
|
+
colorOptions.push({ label: d2Label, value: l1Label && l1Label !== "none" ? "id" : "index" });
|
|
114
|
+
}
|
|
115
|
+
if (d3Label && d3Label !== "none") {
|
|
116
|
+
colorOptions.push({ label: d3Label, value: "values" });
|
|
117
|
+
}
|
|
94
118
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (dimension1 != 'none' && dimension2 != 'none' && colorBy != 'id') {
|
|
101
|
-
setAttributes({ colorBy: 'id' });
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
119
|
+
}
|
|
120
|
+
if (type == "pie") {
|
|
121
|
+
if (dimension1 != "none" && dimension2 == "none" && colorBy != "index") {
|
|
122
|
+
setAttributes({ colorBy: "index" });
|
|
123
|
+
return null;
|
|
104
124
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
125
|
+
if (dimension1 != "none" && dimension2 != "none" && colorBy != "id") {
|
|
126
|
+
setAttributes({ colorBy: "id" });
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
let options = [];
|
|
131
|
+
if (colorBy === "index" || colorBy === "id") {
|
|
132
|
+
if (type == "bar") {
|
|
133
|
+
options = [...system, plainColor, ...categorical, ...sequential];
|
|
134
|
+
} else if (type == "line") {
|
|
135
|
+
options = [...system, plainColor, ...categorical];
|
|
136
|
+
} else {
|
|
137
|
+
options = [...system, ...categorical, ...sequential];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (colorBy === "values") {
|
|
141
|
+
options = [...sequential];
|
|
142
|
+
}
|
|
143
|
+
const [useColors, setUseColors] = useState("dimension");
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
let nextUseColors = useColors;
|
|
146
|
+
if (app != "csv") {
|
|
147
|
+
if (dimension2 == "none" && colorBy === "index" && swap || dimension1 == "none" && dimension2 == "none") {
|
|
148
|
+
nextUseColors = "measure";
|
|
149
|
+
} else if (dimension2 == "none" && colorBy === "id" && !swap) {
|
|
150
|
+
nextUseColors = "measure";
|
|
151
|
+
} else {
|
|
152
|
+
nextUseColors = "dimension";
|
|
153
|
+
}
|
|
154
|
+
if (prevStatus.current) {
|
|
155
|
+
if (nextUseColors == "dimension") {
|
|
156
|
+
if (prevStatus.current["scheme"] != scheme && scheme === "manual") {
|
|
157
|
+
initColors(colorBy === "index" ? dimension1 : dimension2);
|
|
158
|
+
}
|
|
159
|
+
if (prevStatus.current["colorBy"] != colorBy) {
|
|
160
|
+
initColors(colorBy === "index" ? dimension1 : dimension2);
|
|
161
|
+
}
|
|
162
|
+
if (prevStatus.current["dimension1"] != dimension1 || prevStatus.current["dimension2"] != dimension2) {
|
|
163
|
+
initColors(colorBy === "index" ? dimension1 : dimension2);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
initMeasuresColors();
|
|
115
167
|
}
|
|
168
|
+
}
|
|
169
|
+
setUseColors(nextUseColors);
|
|
170
|
+
} else {
|
|
171
|
+
if (!manualColors["csv"]) {
|
|
172
|
+
setAttributes({ manualColors: { "csv": {} } });
|
|
173
|
+
}
|
|
116
174
|
}
|
|
117
|
-
|
|
118
|
-
|
|
175
|
+
prevStatus.current = { scheme, colorBy, dimension1, dimension2, useColors, app };
|
|
176
|
+
}, [scheme, dimension1, dimension2, colorBy, swap, app, type]);
|
|
177
|
+
const prevStatus = useRef();
|
|
178
|
+
const updateColor = (value, color, colorByMode = null) => {
|
|
179
|
+
const newColors = Object.assign({}, manualColors);
|
|
180
|
+
if (colorByMode) {
|
|
181
|
+
if (!newColors[app][colorByMode]) {
|
|
182
|
+
newColors[app][colorByMode] = {};
|
|
183
|
+
}
|
|
184
|
+
newColors[app][colorByMode][value] = color;
|
|
185
|
+
} else {
|
|
186
|
+
newColors[app][value] = color;
|
|
119
187
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
188
|
+
setAttributes({ manualColors: newColors });
|
|
189
|
+
};
|
|
190
|
+
const initColors = (dimension) => {
|
|
191
|
+
const ds = allDimensions.filter((d) => d.value == dimension);
|
|
192
|
+
const newColors = Object.assign({}, manualColors);
|
|
193
|
+
if (!newColors[app]) {
|
|
194
|
+
newColors[app] = {};
|
|
195
|
+
}
|
|
196
|
+
if (ds.length > 0) {
|
|
197
|
+
const { type: type2 } = ds[0];
|
|
198
|
+
const cat = allCategories.filter((a) => a.type === type2);
|
|
199
|
+
if (cat.length > 0) {
|
|
200
|
+
cat[0].items.forEach((item) => {
|
|
201
|
+
if (!newColors[app][item.code]) {
|
|
202
|
+
newColors[app][item.code] = item.categoryStyle ? item.categoryStyle.color : "#eeeeee";
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
setAttributes({ manualColors: newColors });
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const initMeasuresColors = () => {
|
|
210
|
+
const newColors = Object.assign({}, manualColors);
|
|
211
|
+
if (!newColors[app]) {
|
|
212
|
+
newColors[app] = {};
|
|
213
|
+
}
|
|
214
|
+
if (!allMeasures) {
|
|
215
|
+
}
|
|
216
|
+
if (allMeasures) {
|
|
217
|
+
allMeasures.forEach((p) => {
|
|
218
|
+
if (!newColors[app][p.value]) {
|
|
219
|
+
newColors[app][p.value] = p.styles ? p.styles.color : "#eeeeee";
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
setAttributes({ manualColors: newColors });
|
|
224
|
+
};
|
|
225
|
+
const combinedCatColors = (dimension12, dimension22) => {
|
|
226
|
+
if (manualColors[app]) {
|
|
227
|
+
const ds1 = allDimensions.filter((d) => d.value == dimension12);
|
|
228
|
+
const ds2 = allDimensions.filter((d) => d.value == dimension22);
|
|
229
|
+
if (ds1.length > 0 && ds2.length > 0) {
|
|
230
|
+
const { type: type2 } = ds1[0];
|
|
231
|
+
const { type: type22 } = ds2[0];
|
|
232
|
+
const cat = allCategories.filter((a) => a.type === type2);
|
|
233
|
+
const cat2 = allCategories.filter((a) => a.type === type22);
|
|
234
|
+
const list = [];
|
|
235
|
+
cat[0].items.sort((a, b) => a.position - b.position).forEach((c1) => {
|
|
236
|
+
cat2[0].items.sort((a, b) => a.position - b.position).forEach((c2) => {
|
|
237
|
+
list.push(/* @__PURE__ */ React.createElement(
|
|
238
|
+
PanelColorSettings,
|
|
239
|
+
{
|
|
240
|
+
colorSettings: [{
|
|
241
|
+
value: manualColors[app][c1.value + " - " + c2.value],
|
|
242
|
+
onChange: (color) => {
|
|
243
|
+
if (color) {
|
|
244
|
+
updateColor(c1.value + " - " + c2.value, color);
|
|
245
|
+
} else {
|
|
246
|
+
updateColor(c1.value + " - " + c2.value, "#eeeeee");
|
|
143
247
|
}
|
|
144
|
-
|
|
145
|
-
|
|
248
|
+
},
|
|
249
|
+
label: c1.value + " - " + c2.value
|
|
250
|
+
}]
|
|
251
|
+
}
|
|
252
|
+
));
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
return list;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
};
|
|
260
|
+
const catColors = (dimension) => {
|
|
261
|
+
if (manualColors[app]) {
|
|
262
|
+
const ds = allDimensions.filter((d) => d.value == dimension);
|
|
263
|
+
if (ds.length > 0) {
|
|
264
|
+
const { type: type2 } = ds[0];
|
|
265
|
+
const cat = allCategories.filter((a) => a.type === type2);
|
|
266
|
+
if (cat && cat.length > 0) {
|
|
267
|
+
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) => {
|
|
268
|
+
return /* @__PURE__ */ React.createElement(
|
|
269
|
+
PanelColorSettings,
|
|
270
|
+
{
|
|
271
|
+
colorSettings: [{
|
|
272
|
+
value: manualColors[app][item.code],
|
|
273
|
+
onChange: (color) => {
|
|
274
|
+
if (color) {
|
|
275
|
+
updateColor(item.code, color);
|
|
276
|
+
} else {
|
|
277
|
+
updateColor(item.code, item.categoryStyle ? item.categoryStyle.color : "#eeeeee");
|
|
146
278
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
279
|
+
},
|
|
280
|
+
label: getTranslation(item)
|
|
281
|
+
}]
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
const dimensions = [dimension1, dimension2].filter((f) => f != "" && f != "none");
|
|
286
|
+
let selectedMeasures2 = [];
|
|
287
|
+
allMeasures.forEach((m) => {
|
|
288
|
+
if (measures[app] && measures[app][m.value] && measures[app][m.value].selected) {
|
|
289
|
+
selectedMeasures2.push(m.value);
|
|
151
290
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
newColors[app][value] = color;
|
|
165
|
-
setAttributes({ manualColors: newColors });
|
|
166
|
-
};
|
|
167
|
-
const initColors = (dimension) => {
|
|
168
|
-
const ds = allDimensions.filter(d => d.value == dimension);
|
|
169
|
-
const newColors = Object.assign({}, manualColors);
|
|
170
|
-
if (!newColors[app]) {
|
|
171
|
-
newColors[app] = {};
|
|
172
|
-
}
|
|
173
|
-
if (ds.length > 0) {
|
|
174
|
-
const { type } = ds[0];
|
|
175
|
-
const cat = allCategories.filter(a => a.type === type);
|
|
176
|
-
if (cat.length > 0) {
|
|
177
|
-
cat[0].items.forEach(item => {
|
|
178
|
-
if (!newColors[app][item.code]) {
|
|
179
|
-
newColors[app][item.code] = item.categoryStyle ? item.categoryStyle.color : "#eeeeee";
|
|
291
|
+
});
|
|
292
|
+
if (includeOverall) {
|
|
293
|
+
list.push(/* @__PURE__ */ React.createElement(
|
|
294
|
+
PanelColorSettings,
|
|
295
|
+
{
|
|
296
|
+
colorSettings: [{
|
|
297
|
+
value: manualColors[app][OVERALL],
|
|
298
|
+
onChange: (color) => {
|
|
299
|
+
if (color) {
|
|
300
|
+
updateColor(OVERALL, color);
|
|
301
|
+
} else {
|
|
302
|
+
updateColor(OVERALL, "#eeeeee");
|
|
180
303
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
if (!allMeasures) {
|
|
304
|
+
},
|
|
305
|
+
label: __("Overall")
|
|
306
|
+
}]
|
|
307
|
+
}
|
|
308
|
+
));
|
|
309
|
+
}
|
|
310
|
+
return list;
|
|
311
|
+
} else {
|
|
312
|
+
return null;
|
|
192
313
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
onChange: (color) => {
|
|
217
|
-
if (color) {
|
|
218
|
-
updateColor(c1.value + ' - ' + c2.value, color);
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
updateColor(c1.value + ' - ' + c2.value, "#eeeeee");
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
label: c1.value + ' - ' + c2.value
|
|
225
|
-
}] }));
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
return list;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
};
|
|
318
|
+
const measureColors = () => {
|
|
319
|
+
if (manualColors[app] && allMeasures && measures[app]) {
|
|
320
|
+
const selectedMeasures2 = allMeasures.filter((m) => Object.keys(measures[app]).indexOf(m.value) > -1 && measures[app][m.value].selected);
|
|
321
|
+
if (selectedMeasures2.length > 0) {
|
|
322
|
+
const list = selectedMeasures2.sort((a, b) => b.position - a.position).map((item) => {
|
|
323
|
+
return /* @__PURE__ */ React.createElement(
|
|
324
|
+
PanelColorSettings,
|
|
325
|
+
{
|
|
326
|
+
colorSettings: [{
|
|
327
|
+
value: manualColors[app][item.value],
|
|
328
|
+
onChange: (color) => {
|
|
329
|
+
if (color) {
|
|
330
|
+
updateColor(item.value, color);
|
|
331
|
+
} else {
|
|
332
|
+
updateColor(item.value, item.styles ? item.styles.color : "#555555");
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
label: __(item.label)
|
|
336
|
+
}]
|
|
229
337
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
else {
|
|
248
|
-
updateColor(item.code, item.categoryStyle ? item.categoryStyle.color : "#eeeeee");
|
|
249
|
-
}
|
|
250
|
-
}, label: getTranslation(item)
|
|
251
|
-
}] });
|
|
252
|
-
});
|
|
253
|
-
const dimensions = [dimension1, dimension2].filter(f => f != '' && f != "none");
|
|
254
|
-
let selectedMeasures = [];
|
|
255
|
-
allMeasures.forEach(m => {
|
|
256
|
-
if (measures[app] && measures[app][m.value] && measures[app][m.value].selected) {
|
|
257
|
-
selectedMeasures.push(m.value);
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
if (includeOverall) {
|
|
261
|
-
list.push(React.createElement(PanelColorSettings, { colorSettings: [{
|
|
262
|
-
value: manualColors[app][OVERALL],
|
|
263
|
-
onChange: (color) => {
|
|
264
|
-
if (color) {
|
|
265
|
-
updateColor(OVERALL, color);
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
updateColor(OVERALL, "#eeeeee");
|
|
269
|
-
}
|
|
270
|
-
}, label: __("Overall")
|
|
271
|
-
}] }));
|
|
272
|
-
}
|
|
273
|
-
return list;
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
338
|
+
);
|
|
339
|
+
});
|
|
340
|
+
if (includeOverall && selectedMeasures2.length == 1) {
|
|
341
|
+
list.push(/* @__PURE__ */ React.createElement(
|
|
342
|
+
PanelColorSettings,
|
|
343
|
+
{
|
|
344
|
+
colorSettings: [{
|
|
345
|
+
value: manualColors[app][OVERALL],
|
|
346
|
+
onChange: (color) => {
|
|
347
|
+
if (color) {
|
|
348
|
+
updateColor(OVERALL, color);
|
|
349
|
+
} else {
|
|
350
|
+
updateColor(OVERALL, "#eeeeee");
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
label: __("Overall")
|
|
354
|
+
}]
|
|
278
355
|
}
|
|
356
|
+
));
|
|
279
357
|
}
|
|
280
|
-
return
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}] }));
|
|
358
|
+
return list;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return null;
|
|
362
|
+
};
|
|
363
|
+
const csvColors = () => {
|
|
364
|
+
const data = Papa.parse(csv, { header: true, dynamicTyping: true });
|
|
365
|
+
const values = [];
|
|
366
|
+
if (colorBy === "index" && type != "line" || type == "pie") {
|
|
367
|
+
const field = data.meta.fields[0];
|
|
368
|
+
values.push(...data.data.map((d) => d[field]));
|
|
369
|
+
}
|
|
370
|
+
if (colorBy === "id" || type == "line") {
|
|
371
|
+
values.push(...data.meta.fields.slice(1));
|
|
372
|
+
}
|
|
373
|
+
if (colorBy === "values") {
|
|
374
|
+
values.push(0, 100);
|
|
375
|
+
}
|
|
376
|
+
if (manualColors[app] && values) {
|
|
377
|
+
return values.map((v) => {
|
|
378
|
+
const colorByColors = manualColors[app][colorBy] || {};
|
|
379
|
+
return /* @__PURE__ */ React.createElement(
|
|
380
|
+
PanelColorSettings,
|
|
381
|
+
{
|
|
382
|
+
colorSettings: [{
|
|
383
|
+
value: colorByColors[v],
|
|
384
|
+
onChange: (color) => {
|
|
385
|
+
if (color) {
|
|
386
|
+
updateColor(v, color, colorBy);
|
|
310
387
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const data = Papa.parse(csv, { header: true, dynamicTyping: true });
|
|
318
|
-
const values = [];
|
|
319
|
-
if (colorBy === "index" && type != 'line') {
|
|
320
|
-
const field = data.meta.fields[0];
|
|
321
|
-
values.push(...data.data.map(d => d[field]));
|
|
322
|
-
}
|
|
323
|
-
if (colorBy === "id" || type == 'line') {
|
|
324
|
-
values.push(...data.meta.fields.slice(1));
|
|
325
|
-
}
|
|
326
|
-
if (colorBy === "values") {
|
|
327
|
-
values.push(0, 100);
|
|
328
|
-
}
|
|
329
|
-
if (manualColors[app] && values) {
|
|
330
|
-
return values.map(v => {
|
|
331
|
-
return React.createElement(PanelColorSettings, { colorSettings: [{
|
|
332
|
-
value: manualColors[app][v],
|
|
333
|
-
onChange: (color) => {
|
|
334
|
-
if (color) {
|
|
335
|
-
updateColor(v, color);
|
|
336
|
-
}
|
|
337
|
-
}, label: __(v)
|
|
338
|
-
}] });
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
return null;
|
|
342
|
-
};
|
|
343
|
-
const elements = [];
|
|
344
|
-
if (type == 'bar' || type == 'line') {
|
|
345
|
-
elements.push(React.createElement(PanelRow, null,
|
|
346
|
-
React.createElement(SelectControl, { label: __('Color By'), value: [colorBy], onChange: (colorBy) => {
|
|
347
|
-
setAttributes({ colorBy });
|
|
348
|
-
if (colorBy === 'index' || colorBy === 'id') {
|
|
349
|
-
setAttributes({ colorBy });
|
|
350
|
-
}
|
|
351
|
-
if (colorBy === 'values') {
|
|
352
|
-
setAttributes({ scheme: "blues", colorBy });
|
|
353
|
-
}
|
|
354
|
-
}, options: colorOptions })));
|
|
388
|
+
},
|
|
389
|
+
label: __(v)
|
|
390
|
+
}]
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
});
|
|
355
394
|
}
|
|
356
|
-
return
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
395
|
+
return null;
|
|
396
|
+
};
|
|
397
|
+
const elements = [];
|
|
398
|
+
if (type == "bar" || type == "line") {
|
|
399
|
+
elements.push(/* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
400
|
+
SelectControl,
|
|
401
|
+
{
|
|
402
|
+
label: __("Color By"),
|
|
403
|
+
value: [colorBy],
|
|
404
|
+
onChange: (colorBy2) => {
|
|
405
|
+
setAttributes({ colorBy: colorBy2 });
|
|
406
|
+
if (colorBy2 === "index" || colorBy2 === "id") {
|
|
407
|
+
setAttributes({ colorBy: colorBy2 });
|
|
408
|
+
}
|
|
409
|
+
if (colorBy2 === "values") {
|
|
410
|
+
setAttributes({ scheme: "blues", colorBy: colorBy2 });
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
options: colorOptions
|
|
414
|
+
}
|
|
415
|
+
)));
|
|
416
|
+
}
|
|
417
|
+
if (type == "pie") {
|
|
418
|
+
setAttributes({ colorBy: "index" });
|
|
419
|
+
}
|
|
420
|
+
return [
|
|
421
|
+
...elements,
|
|
422
|
+
/* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
423
|
+
SelectControl,
|
|
424
|
+
{
|
|
425
|
+
label: __("Color Scheme"),
|
|
426
|
+
value: [scheme],
|
|
427
|
+
onChange: (value) => {
|
|
428
|
+
setAttributes({ scheme: value });
|
|
429
|
+
},
|
|
430
|
+
options
|
|
431
|
+
}
|
|
432
|
+
)),
|
|
433
|
+
scheme == "plain_color" && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
434
|
+
PanelColorSettings,
|
|
435
|
+
{
|
|
436
|
+
title: __("Color settings"),
|
|
437
|
+
colorSettings: [{
|
|
438
|
+
value: decodeURIComponent(barColor),
|
|
439
|
+
onChange: (color) => {
|
|
440
|
+
if (color) {
|
|
441
|
+
setAttributes({ barColor: encodeURIComponent(color) });
|
|
442
|
+
} else {
|
|
443
|
+
setAttributes({ barColor: null });
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
label: __("Plain color")
|
|
447
|
+
}]
|
|
448
|
+
}
|
|
449
|
+
)),
|
|
450
|
+
scheme == "manual" && /* @__PURE__ */ React.createElement(PanelRow, null, app != "csv" && useColors == "dimension" && colorBy == "index" && /* @__PURE__ */ React.createElement(PanelBody, { initialOpen: false, title: __("Set Colors") }, catColors(dimension1)), app != "csv" && useColors == "dimension" && (colorBy == "id" && dimension2 != "none") && /* @__PURE__ */ React.createElement(PanelBody, { initialOpen: false, title: __("Set Colors") }, 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(PanelBody, { initialOpen: false, title: __("Set Colors") }, catColors(dimension1)), app != "csv" && useColors === "measure" && /* @__PURE__ */ React.createElement(PanelBody, { initialOpen: false, title: __("Set Color By Measure") }, measureColors()), app == "csv" && /* @__PURE__ */ React.createElement(PanelBody, { initialOpen: false, title: __("Set Colors") }, csvColors(colorBy)))
|
|
451
|
+
];
|
|
387
452
|
};
|
|
388
|
-
export default ChartColors;
|