@progress/kendo-charts 2.4.2 → 2.5.0-dev.202409030746
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/README.md +20 -14
- package/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/chart-wizard/get-wizard-data-from-data-rows.js +22 -0
- package/dist/es/chart-wizard/messages.js +108 -0
- package/dist/es/chart-wizard/state.js +719 -0
- package/dist/es/chart-wizard.js +19 -0
- package/dist/es/main.js +1 -0
- package/dist/es2015/chart-wizard/get-wizard-data-from-data-rows.js +21 -0
- package/dist/es2015/chart-wizard/messages.js +108 -0
- package/dist/es2015/chart-wizard/state.js +727 -0
- package/dist/es2015/chart-wizard.js +19 -0
- package/dist/es2015/main.js +1 -0
- package/dist/npm/chart-wizard.d.ts +313 -0
- package/dist/npm/main.d.ts +1 -0
- package/dist/npm/main.js +854 -3
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
const ActionTypes = Object.freeze({
|
|
4
|
+
seriesType: 0,
|
|
5
|
+
stacked: 1,
|
|
6
|
+
|
|
7
|
+
categoryAxisX: 2,
|
|
8
|
+
valueAxisY: 3,
|
|
9
|
+
|
|
10
|
+
seriesChange: 4,
|
|
11
|
+
|
|
12
|
+
areaMarginLeft: 5,
|
|
13
|
+
areaMarginRight: 6,
|
|
14
|
+
areaMarginTop: 7,
|
|
15
|
+
areaMarginBottom: 8,
|
|
16
|
+
areaBackground: 9,
|
|
17
|
+
|
|
18
|
+
titleText: 10,
|
|
19
|
+
titleFontName: 11,
|
|
20
|
+
titleFontSize: 12,
|
|
21
|
+
titleColor: 13,
|
|
22
|
+
|
|
23
|
+
subtitleText: 14,
|
|
24
|
+
subtitleFontName: 15,
|
|
25
|
+
subtitleFontSize: 16,
|
|
26
|
+
subtitleColor: 17,
|
|
27
|
+
|
|
28
|
+
seriesColor: 18,
|
|
29
|
+
seriesLabel: 19,
|
|
30
|
+
|
|
31
|
+
legendVisible: 20,
|
|
32
|
+
legendFontName: 21,
|
|
33
|
+
legendFontSize: 22,
|
|
34
|
+
legendColor: 23,
|
|
35
|
+
legendPosition: 24,
|
|
36
|
+
|
|
37
|
+
categoryAxisTitleText: 25,
|
|
38
|
+
categoryAxisTitleFontName: 26,
|
|
39
|
+
categoryAxisTitleFontSize: 27,
|
|
40
|
+
categoryAxisTitleColor: 28,
|
|
41
|
+
categoryAxisLabelsFontName: 29,
|
|
42
|
+
categoryAxisLabelsFontSize: 30,
|
|
43
|
+
categoryAxisLabelsColor: 31,
|
|
44
|
+
categoryAxisLabelsRotation: 32,
|
|
45
|
+
categoryAxisReverseOrder: 33,
|
|
46
|
+
|
|
47
|
+
valueAxisTitleText: 34,
|
|
48
|
+
valueAxisTitleFontName: 35,
|
|
49
|
+
valueAxisTitleFontSize: 36,
|
|
50
|
+
valueAxisTitleColor: 37,
|
|
51
|
+
valueAxisLabelsFormat: 38,
|
|
52
|
+
valueAxisLabelsFontName: 39,
|
|
53
|
+
valueAxisLabelsFontSize: 40,
|
|
54
|
+
valueAxisLabelsColor: 41,
|
|
55
|
+
valueAxisLabelsRotation: 42,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const fontSizes = [
|
|
59
|
+
{ text: "10", value: "10px" },
|
|
60
|
+
{ text: "12", value: "12px" },
|
|
61
|
+
{ text: "14", value: "14px" },
|
|
62
|
+
{ text: "16", value: "16px" },
|
|
63
|
+
{ text: "20", value: "20px" },
|
|
64
|
+
{ text: "28", value: "28px" },
|
|
65
|
+
{ text: "42", value: "42px" },
|
|
66
|
+
{ text: "56", value: "56px" }
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const titleSizeDefault = '20px';
|
|
70
|
+
const subtitleSizeDefault = '16px';
|
|
71
|
+
const labelSizeDefault = '12px';
|
|
72
|
+
const axisTitleSizeDefault = '16px';
|
|
73
|
+
|
|
74
|
+
const fontNames = [
|
|
75
|
+
{
|
|
76
|
+
text: "Arial",
|
|
77
|
+
value: "Arial, Helvetica, sans-serif",
|
|
78
|
+
style: { fontFamily: "Arial, Helvetica, sans-serif" },
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
text: "Courier New",
|
|
82
|
+
value: "'Courier New', Courier, monospace",
|
|
83
|
+
style: { fontFamily: "'Courier New', Courier, monospace" },
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
text: "Georgia",
|
|
87
|
+
value: "Georgia, serif",
|
|
88
|
+
style: { fontFamily: "Georgia, serif" },
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
text: "Impact",
|
|
92
|
+
value: "Impact, Charcoal, sans-serif",
|
|
93
|
+
style: { fontFamily: "Impact, Charcoal, sans-serif" },
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
text: "Lucida Console",
|
|
97
|
+
value: "'Lucida Console', Monaco, monospace",
|
|
98
|
+
style: { fontFamily: "'Lucida Console', Monaco, monospace" },
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
text: "Tahoma",
|
|
102
|
+
value: "Tahoma, Geneva, sans-serif",
|
|
103
|
+
style: { fontFamily: "Tahoma, Geneva, sans-serif" },
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
text: "Times New Roman",
|
|
107
|
+
value: "'Times New Roman', Times,serif",
|
|
108
|
+
style: { fontFamily: "'Times New Roman', Times,serif" },
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
text: "Trebuchet MS",
|
|
112
|
+
value: "'Trebuchet MS', Helvetica, sans-serif",
|
|
113
|
+
style: { fontFamily: "'Trebuchet MS', Helvetica, sans-serif" },
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
text: "Verdana",
|
|
117
|
+
value: "Verdana, Geneva, sans-serif",
|
|
118
|
+
style: { fontFamily: "Verdana, Geneva, sans-serif" },
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
const fontNameDefault = fontNames[0].value;
|
|
123
|
+
|
|
124
|
+
const columnType = "column";
|
|
125
|
+
const barType = "bar";
|
|
126
|
+
const lineType = "line";
|
|
127
|
+
const pieType = "pie";
|
|
128
|
+
const scatterType = "scatter";
|
|
129
|
+
const categoricalTypes = [columnType, barType, lineType, scatterType];
|
|
130
|
+
|
|
131
|
+
const scatterSeries = {
|
|
132
|
+
type: lineType,
|
|
133
|
+
width: 0,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
function isCategorical(type) {
|
|
137
|
+
return type && categoricalTypes.includes(type);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const categoryTypes = ["string", "date", "number"];
|
|
141
|
+
const valueTypes = ["number"];
|
|
142
|
+
|
|
143
|
+
const axesDefinitions = {
|
|
144
|
+
bar: [
|
|
145
|
+
{ axisType: "category", types: categoryTypes },
|
|
146
|
+
{ axisType: "value", types: valueTypes },
|
|
147
|
+
],
|
|
148
|
+
column: [
|
|
149
|
+
{ axisType: "category", types: categoryTypes },
|
|
150
|
+
{ axisType: "value", types: valueTypes },
|
|
151
|
+
],
|
|
152
|
+
line: [
|
|
153
|
+
{ axisType: "category", types: categoryTypes },
|
|
154
|
+
{ axisType: "value", types: valueTypes },
|
|
155
|
+
],
|
|
156
|
+
pie: [
|
|
157
|
+
{ axisType: "category", types: categoryTypes },
|
|
158
|
+
{ axisType: "value", types: valueTypes, count: 1 },
|
|
159
|
+
],
|
|
160
|
+
scatter: [
|
|
161
|
+
{ axisType: "category", types: categoryTypes },
|
|
162
|
+
{ axisType: "value", types: valueTypes },
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
function getFont(font, size) {
|
|
167
|
+
return `${size || ""} ${font || ""}`.trim();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function parseFont(font) {
|
|
171
|
+
const spaceIndex = (font || "").indexOf(" ");
|
|
172
|
+
const size = font && font.substring(0, spaceIndex);
|
|
173
|
+
const name = font && font.substring(spaceIndex + 1);
|
|
174
|
+
return { size, name };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const updateFontName = (fontName, defaultSize, currentFont) => {
|
|
178
|
+
const { size } = parseFont(currentFont);
|
|
179
|
+
return fontName ? getFont(fontName, size || defaultSize) : "";
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const updateFontSize = (fontSize, defaultFontName, currentFont) => {
|
|
183
|
+
const { name } = parseFont(currentFont);
|
|
184
|
+
return fontSize ? getFont(name || defaultFontName, fontSize) : "";
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const hasValue = (value) => value !== undefined && value !== null;
|
|
188
|
+
|
|
189
|
+
const recordWithValues = (data) => {
|
|
190
|
+
const result = structuredClone(data[0]);
|
|
191
|
+
result.forEach((item, i) => {
|
|
192
|
+
if (!hasValue(item.value)) {
|
|
193
|
+
for (let index = 0; index < data.length; index++) {
|
|
194
|
+
const value = data[index][i].value;
|
|
195
|
+
if (hasValue(value)) {
|
|
196
|
+
item.value = value;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
return result;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const getCategoryColumnIndex = (data, categoryDef) => {
|
|
207
|
+
const candidates = [];
|
|
208
|
+
const sampleRecord = recordWithValues(data);
|
|
209
|
+
|
|
210
|
+
categoryDef.types.forEach((type) => {
|
|
211
|
+
sampleRecord.forEach((item, i) => {
|
|
212
|
+
if (typeof item.value === type) {
|
|
213
|
+
candidates.push(i);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const result = candidates.findIndex((index) => {
|
|
219
|
+
const values = data.map((record) => record[index].value);
|
|
220
|
+
return new Set(values).size === values.length;
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
return Math.max(result, 0);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const getValueColumnIndexes = (data, valuesDef) => {
|
|
227
|
+
const candidates = [];
|
|
228
|
+
const sampleRecord = recordWithValues(data);
|
|
229
|
+
|
|
230
|
+
valuesDef.forEach((def) => {
|
|
231
|
+
def.types.forEach((type) => {
|
|
232
|
+
sampleRecord.forEach((item, i) => {
|
|
233
|
+
if (typeof item.value === type) {
|
|
234
|
+
candidates.push(i);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
return candidates;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const emptyState = () =>
|
|
244
|
+
structuredClone({
|
|
245
|
+
columns: [],
|
|
246
|
+
data: [],
|
|
247
|
+
series: [],
|
|
248
|
+
initialSeries: [],
|
|
249
|
+
categoryAxis: [ { categories: [], labels: { visible: true, rotation: "auto" }, title: { text: '' } } ],
|
|
250
|
+
valueAxis: [{ labels: { visible: true } }],
|
|
251
|
+
area: {
|
|
252
|
+
margin: {
|
|
253
|
+
left: undefined,
|
|
254
|
+
right: undefined,
|
|
255
|
+
top: undefined,
|
|
256
|
+
bottom: undefined,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
title: { text: '' },
|
|
260
|
+
subtitle: { text: '' },
|
|
261
|
+
stack: false,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const categoryValueChartState = (data, seriesType, options) => {
|
|
265
|
+
const state = emptyState();
|
|
266
|
+
state.seriesType = seriesType;
|
|
267
|
+
state.data = data || [];
|
|
268
|
+
state.legend = { visible: true };
|
|
269
|
+
const chartDef = axesDefinitions[seriesType];
|
|
270
|
+
|
|
271
|
+
if (!chartDef || !data.length) {
|
|
272
|
+
return state;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const firstRecord = data[0].slice();
|
|
276
|
+
state.columns = data[0].map((i) => String(i.field));
|
|
277
|
+
|
|
278
|
+
const categoryDef = chartDef.find((def) => def.axisType === "category");
|
|
279
|
+
let catIndex = -1;
|
|
280
|
+
if (categoryDef) {
|
|
281
|
+
catIndex =
|
|
282
|
+
options && options.categoryAxis
|
|
283
|
+
? state.columns.indexOf(options.categoryAxis)
|
|
284
|
+
: getCategoryColumnIndex(data, categoryDef);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const valuesDef = chartDef.filter((def) => def.axisType === "value");
|
|
288
|
+
let valuesIndexes = getValueColumnIndexes(data, valuesDef);
|
|
289
|
+
|
|
290
|
+
if (valuesIndexes.includes(catIndex)) {
|
|
291
|
+
if (valuesIndexes.length > 1) {
|
|
292
|
+
valuesIndexes = valuesIndexes.filter((index) => index !== catIndex);
|
|
293
|
+
} else {
|
|
294
|
+
catIndex = -1;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const series = [];
|
|
299
|
+
valuesIndexes.forEach((index) => {
|
|
300
|
+
const valuesColumn = firstRecord[index];
|
|
301
|
+
const valuesResult = [];
|
|
302
|
+
data.forEach((record) => {
|
|
303
|
+
valuesResult.push(record[index].value);
|
|
304
|
+
});
|
|
305
|
+
series.push(Object.assign({}, {name: valuesColumn.field,
|
|
306
|
+
type: seriesType,
|
|
307
|
+
data: valuesResult,
|
|
308
|
+
stack: false,
|
|
309
|
+
labels: { visible: false }},
|
|
310
|
+
(seriesType === scatterType ? scatterSeries : {})));
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
const categories =
|
|
314
|
+
catIndex > -1
|
|
315
|
+
? data.map((item) =>
|
|
316
|
+
String(
|
|
317
|
+
hasValue(item[catIndex].value)
|
|
318
|
+
? item[catIndex].value
|
|
319
|
+
: " "
|
|
320
|
+
)
|
|
321
|
+
)
|
|
322
|
+
: [];
|
|
323
|
+
|
|
324
|
+
if (series.length) {
|
|
325
|
+
state.series = series.map((s, i) => (Object.assign({}, s, {id: i})));
|
|
326
|
+
state.initialSeries = structuredClone(state.series);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
state.categoryAxis = [
|
|
330
|
+
{ categories, labels: { visible: true, rotation: "auto" } },
|
|
331
|
+
];
|
|
332
|
+
state.categoryField = state.columns[catIndex];
|
|
333
|
+
|
|
334
|
+
return state;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
const pieChartState = (data, seriesType, options) => {
|
|
338
|
+
const state = emptyState();
|
|
339
|
+
state.seriesType = seriesType;
|
|
340
|
+
state.data = data || [];
|
|
341
|
+
|
|
342
|
+
const chartDef = axesDefinitions[seriesType];
|
|
343
|
+
|
|
344
|
+
if (!chartDef || !data.length) {
|
|
345
|
+
return state;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const categoriesAxis = data[0].map((i) => i.field);
|
|
349
|
+
const categoryDef = chartDef.find((def) => def.axisType === "category");
|
|
350
|
+
let catIndex = -1;
|
|
351
|
+
if (categoryDef) {
|
|
352
|
+
catIndex =
|
|
353
|
+
options && options.categoryAxis
|
|
354
|
+
? categoriesAxis.indexOf(options.categoryAxis)
|
|
355
|
+
: getCategoryColumnIndex(data, categoryDef);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const valuesDef = chartDef.filter((def) => def.axisType === "value");
|
|
359
|
+
|
|
360
|
+
let valuesIndexes = [];
|
|
361
|
+
if (options && options.valueAxis) {
|
|
362
|
+
valuesIndexes = [categoriesAxis.indexOf(options.valueAxis)];
|
|
363
|
+
} else {
|
|
364
|
+
valuesIndexes = getValueColumnIndexes(data, valuesDef);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (valuesIndexes.includes(catIndex) && valuesIndexes.length > 1) {
|
|
368
|
+
valuesIndexes = valuesIndexes.filter((index) => index !== catIndex);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (typeof valuesDef[0].count === "number") {
|
|
372
|
+
valuesIndexes = valuesIndexes.slice(0, valuesDef[0].count);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const categories =
|
|
376
|
+
catIndex > -1 ? data.map((item) => String(item[catIndex].value)) : [];
|
|
377
|
+
|
|
378
|
+
const flatData = [];
|
|
379
|
+
|
|
380
|
+
data.forEach((item) => {
|
|
381
|
+
const record = {};
|
|
382
|
+
valuesIndexes.forEach((index) => {
|
|
383
|
+
const col = item[index];
|
|
384
|
+
record[col.field] = col.value || 0;
|
|
385
|
+
record[item[catIndex].field] = item[catIndex].value || " ";
|
|
386
|
+
});
|
|
387
|
+
flatData.push(record);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
state.columns = categoriesAxis;
|
|
391
|
+
state.categoryAxis = [{ categories, title: { text: "" } }];
|
|
392
|
+
|
|
393
|
+
state.series = [
|
|
394
|
+
{
|
|
395
|
+
id: 0,
|
|
396
|
+
data: flatData,
|
|
397
|
+
type: seriesType,
|
|
398
|
+
name: categoriesAxis[catIndex],
|
|
399
|
+
labels: { visible: true },
|
|
400
|
+
categoryField: categoriesAxis[catIndex],
|
|
401
|
+
field: categoriesAxis[valuesIndexes[0]],
|
|
402
|
+
},
|
|
403
|
+
];
|
|
404
|
+
|
|
405
|
+
state.categoryField = categoriesAxis[catIndex];
|
|
406
|
+
state.valueField = categoriesAxis[valuesIndexes[0]];
|
|
407
|
+
|
|
408
|
+
state.initialSeries = structuredClone(state.series);
|
|
409
|
+
|
|
410
|
+
return state;
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
function createInitialState(data, seriesType, defaultState) {
|
|
414
|
+
const state = createState(
|
|
415
|
+
data,
|
|
416
|
+
(defaultState && defaultState.seriesType) || seriesType
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
return typeof (defaultState && defaultState.stack) !== "undefined"
|
|
420
|
+
? updateState(state, ActionTypes.stacked, defaultState.stack)
|
|
421
|
+
: state;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function createState(data, seriesType) {
|
|
425
|
+
return (isCategorical(seriesType) ? categoryValueChartState : pieChartState)(
|
|
426
|
+
data,
|
|
427
|
+
seriesType
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function mergeStates(state, newState) {
|
|
432
|
+
newState.legend = state.legend;
|
|
433
|
+
newState.area = state.area;
|
|
434
|
+
newState.title = state.title;
|
|
435
|
+
newState.subtitle = state.subtitle;
|
|
436
|
+
if (newState.series.length === state.series.length) {
|
|
437
|
+
for (let i = 0; i < newState.series.length; i++) {
|
|
438
|
+
newState.series[i].color = state.series[i].color;
|
|
439
|
+
newState.series[i].labels = state.series[i].labels;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (
|
|
444
|
+
state.series.every((s) => s.labels && s.labels.visible) &&
|
|
445
|
+
isCategorical(newState.seriesType) &&
|
|
446
|
+
isCategorical(state.seriesType)
|
|
447
|
+
) {
|
|
448
|
+
newState.series.forEach((s) => {
|
|
449
|
+
s.labels = s.labels || {};
|
|
450
|
+
s.labels.visible = true;
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return newState;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/* eslint-disable complexity */
|
|
458
|
+
function updateState(currentState, action, value) {
|
|
459
|
+
const state = Object.assign({}, currentState);
|
|
460
|
+
|
|
461
|
+
switch (action) {
|
|
462
|
+
case ActionTypes.seriesType:
|
|
463
|
+
return createState(state.data, value);
|
|
464
|
+
|
|
465
|
+
case ActionTypes.stacked:
|
|
466
|
+
state.series = state.series.map((s) => (Object.assign({}, s, {stack: value})));
|
|
467
|
+
state.stack = value;
|
|
468
|
+
return state;
|
|
469
|
+
|
|
470
|
+
case ActionTypes.categoryAxisX: {
|
|
471
|
+
if (state.seriesType && isCategorical(state.seriesType)) {
|
|
472
|
+
const newState = categoryValueChartState(
|
|
473
|
+
state.data,
|
|
474
|
+
state.seriesType,
|
|
475
|
+
{ categoryAxis: value }
|
|
476
|
+
);
|
|
477
|
+
return mergeStates(state, newState);
|
|
478
|
+
} else if (state.seriesType === pieType) {
|
|
479
|
+
const newState = pieChartState(state.data, state.seriesType, {
|
|
480
|
+
categoryAxis: value,
|
|
481
|
+
});
|
|
482
|
+
return mergeStates(state, newState);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return state;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
case ActionTypes.valueAxisY: {
|
|
489
|
+
if (state.seriesType === pieType) {
|
|
490
|
+
const newState = pieChartState(state.data, state.seriesType, {
|
|
491
|
+
categoryAxis: state.categoryField,
|
|
492
|
+
valueAxis: value,
|
|
493
|
+
});
|
|
494
|
+
return mergeStates(state, newState);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return state;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
case ActionTypes.seriesChange:
|
|
501
|
+
state.series = value;
|
|
502
|
+
return state;
|
|
503
|
+
|
|
504
|
+
case ActionTypes.areaMarginLeft:
|
|
505
|
+
state.area = Object.assign({}, state.area,
|
|
506
|
+
{margin: Object.assign({}, ((state.area && state.area.margin) || {}),
|
|
507
|
+
{left: value})});
|
|
508
|
+
return state;
|
|
509
|
+
|
|
510
|
+
case ActionTypes.areaMarginRight:
|
|
511
|
+
state.area = Object.assign({}, state.area,
|
|
512
|
+
{margin: Object.assign({}, ((state.area && state.area.margin) || {}),
|
|
513
|
+
{right: value})});
|
|
514
|
+
return state;
|
|
515
|
+
|
|
516
|
+
case ActionTypes.areaMarginTop:
|
|
517
|
+
state.area = Object.assign({}, state.area,
|
|
518
|
+
{margin: Object.assign({}, ((state.area && state.area.margin) || {}),
|
|
519
|
+
{top: value})});
|
|
520
|
+
return state;
|
|
521
|
+
|
|
522
|
+
case ActionTypes.areaMarginBottom:
|
|
523
|
+
state.area = Object.assign({}, state.area,
|
|
524
|
+
{margin: Object.assign({}, ((state.area && state.area.margin) || {}),
|
|
525
|
+
{bottom: value})});
|
|
526
|
+
return state;
|
|
527
|
+
|
|
528
|
+
case ActionTypes.areaBackground:
|
|
529
|
+
state.area = Object.assign({}, state.area, {background: value});
|
|
530
|
+
return state;
|
|
531
|
+
|
|
532
|
+
case ActionTypes.titleText:
|
|
533
|
+
state.title = Object.assign({}, state.title, {text: value});
|
|
534
|
+
return state;
|
|
535
|
+
|
|
536
|
+
case ActionTypes.titleFontName: {
|
|
537
|
+
state.title = Object.assign({}, state.title,
|
|
538
|
+
{font: updateFontName(
|
|
539
|
+
value,
|
|
540
|
+
titleSizeDefault,
|
|
541
|
+
state.title && state.title.font
|
|
542
|
+
)});
|
|
543
|
+
return state;
|
|
544
|
+
}
|
|
545
|
+
case ActionTypes.titleFontSize:
|
|
546
|
+
state.title = Object.assign({}, state.title,
|
|
547
|
+
{font: updateFontSize(
|
|
548
|
+
value,
|
|
549
|
+
fontNameDefault,
|
|
550
|
+
state.title && state.title.font
|
|
551
|
+
)});
|
|
552
|
+
return state;
|
|
553
|
+
|
|
554
|
+
case ActionTypes.titleColor:
|
|
555
|
+
state.title = Object.assign({}, state.title, {color: value});
|
|
556
|
+
return state;
|
|
557
|
+
|
|
558
|
+
case ActionTypes.subtitleText:
|
|
559
|
+
state.subtitle = Object.assign({}, state.subtitle, {text: value});
|
|
560
|
+
return state;
|
|
561
|
+
|
|
562
|
+
case ActionTypes.subtitleFontName:
|
|
563
|
+
state.subtitle = Object.assign({}, state.subtitle,
|
|
564
|
+
{font: updateFontName(
|
|
565
|
+
value,
|
|
566
|
+
subtitleSizeDefault,
|
|
567
|
+
state.subtitle && state.subtitle.font
|
|
568
|
+
)});
|
|
569
|
+
return state;
|
|
570
|
+
|
|
571
|
+
case ActionTypes.subtitleFontSize:
|
|
572
|
+
state.subtitle = Object.assign({}, state.subtitle,
|
|
573
|
+
{font: updateFontSize(
|
|
574
|
+
value,
|
|
575
|
+
fontNameDefault,
|
|
576
|
+
state.subtitle && state.subtitle.font
|
|
577
|
+
)});
|
|
578
|
+
return state;
|
|
579
|
+
|
|
580
|
+
case ActionTypes.subtitleColor:
|
|
581
|
+
state.subtitle = Object.assign({}, state.subtitle, {color: value});
|
|
582
|
+
return state;
|
|
583
|
+
|
|
584
|
+
case ActionTypes.seriesColor:
|
|
585
|
+
state.series = state.series.map((s) => (Object.assign({}, s,
|
|
586
|
+
{color: value.seriesName === s.name ? value.color : s.color})));
|
|
587
|
+
return state;
|
|
588
|
+
|
|
589
|
+
case ActionTypes.seriesLabel:
|
|
590
|
+
state.series = state.series.map((s) => {
|
|
591
|
+
if (value.all || value.seriesName === s.name) {
|
|
592
|
+
return Object.assign({}, s, {labels: { visible: value.visible }});
|
|
593
|
+
}
|
|
594
|
+
return s;
|
|
595
|
+
});
|
|
596
|
+
return state;
|
|
597
|
+
|
|
598
|
+
case ActionTypes.legendVisible:
|
|
599
|
+
state.legend = Object.assign({}, state.legend, {visible: value});
|
|
600
|
+
return state;
|
|
601
|
+
|
|
602
|
+
case ActionTypes.legendFontName: {
|
|
603
|
+
const legend = state.legend || {};
|
|
604
|
+
state.legend = Object.assign({}, legend,
|
|
605
|
+
{labels: Object.assign({}, legend.labels,
|
|
606
|
+
{font: updateFontName(
|
|
607
|
+
value,
|
|
608
|
+
labelSizeDefault,
|
|
609
|
+
legend.labels && legend.labels.font
|
|
610
|
+
)})});
|
|
611
|
+
return state;
|
|
612
|
+
}
|
|
613
|
+
case ActionTypes.legendFontSize: {
|
|
614
|
+
const legend = state.legend || {};
|
|
615
|
+
state.legend = Object.assign({}, legend,
|
|
616
|
+
{labels: Object.assign({}, legend.labels,
|
|
617
|
+
{font: updateFontSize(
|
|
618
|
+
value,
|
|
619
|
+
fontNameDefault,
|
|
620
|
+
legend.labels && legend.labels.font
|
|
621
|
+
)})});
|
|
622
|
+
return state;
|
|
623
|
+
}
|
|
624
|
+
case ActionTypes.legendColor: {
|
|
625
|
+
const legend = state.legend || {};
|
|
626
|
+
state.legend = Object.assign({}, legend,
|
|
627
|
+
{labels: Object.assign({}, legend.labels, {color: value})});
|
|
628
|
+
return state;
|
|
629
|
+
}
|
|
630
|
+
case ActionTypes.legendPosition:
|
|
631
|
+
state.legend = Object.assign({}, state.legend, {position: value});
|
|
632
|
+
return state;
|
|
633
|
+
|
|
634
|
+
case ActionTypes.categoryAxisTitleText:
|
|
635
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {title: Object.assign({}, axis.title, {text: value})})));
|
|
636
|
+
return state;
|
|
637
|
+
|
|
638
|
+
case ActionTypes.categoryAxisTitleFontName: {
|
|
639
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {title: Object.assign({}, axis.title, {font: updateFontName(value, axisTitleSizeDefault, axis.title && axis.title.font)})})));
|
|
640
|
+
return state;
|
|
641
|
+
}
|
|
642
|
+
case ActionTypes.categoryAxisTitleFontSize:
|
|
643
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {title: Object.assign({}, axis.title, {font: updateFontSize(value, fontNameDefault, axis.title && axis.title.font)})})));
|
|
644
|
+
return state;
|
|
645
|
+
|
|
646
|
+
case ActionTypes.categoryAxisTitleColor:
|
|
647
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {title: Object.assign({}, axis.title, {color: value})})));
|
|
648
|
+
return state;
|
|
649
|
+
|
|
650
|
+
case ActionTypes.categoryAxisLabelsFontName: {
|
|
651
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {font: updateFontName(value, labelSizeDefault, axis.labels && axis.labels.font)})})));
|
|
652
|
+
return state;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
case ActionTypes.categoryAxisLabelsFontSize:
|
|
656
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {font: updateFontSize(value, fontNameDefault, axis.labels && axis.labels.font)})})));
|
|
657
|
+
return state;
|
|
658
|
+
|
|
659
|
+
case ActionTypes.categoryAxisLabelsColor:
|
|
660
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {color: value})})));
|
|
661
|
+
return state;
|
|
662
|
+
|
|
663
|
+
case ActionTypes.categoryAxisLabelsRotation: {
|
|
664
|
+
const rotation = hasValue(value) ? value : 'auto';
|
|
665
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {rotation})})));
|
|
666
|
+
return state;
|
|
667
|
+
}
|
|
668
|
+
case ActionTypes.categoryAxisReverseOrder:
|
|
669
|
+
state.categoryAxis = (state.categoryAxis || []).map(axis => (Object.assign({}, axis, {reverse: value})));
|
|
670
|
+
return state;
|
|
671
|
+
|
|
672
|
+
case ActionTypes.valueAxisTitleText: {
|
|
673
|
+
if (!state.valueAxis || state.valueAxis.length === 0) {
|
|
674
|
+
state.valueAxis = [{ title: { text: value } }];
|
|
675
|
+
} else {
|
|
676
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {title: Object.assign({}, axis.title, {text: value})})));
|
|
677
|
+
}
|
|
678
|
+
return state;
|
|
679
|
+
}
|
|
680
|
+
case ActionTypes.valueAxisTitleFontName: {
|
|
681
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {title: Object.assign({}, axis.title, {font: updateFontName(value, axisTitleSizeDefault, axis.title && axis.title.font)})})));
|
|
682
|
+
return state;
|
|
683
|
+
}
|
|
684
|
+
case ActionTypes.valueAxisTitleFontSize:
|
|
685
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {title: Object.assign({}, axis.title, {font: updateFontSize(value, fontNameDefault, axis.title && axis.title.font)})})));
|
|
686
|
+
return state;
|
|
687
|
+
case ActionTypes.valueAxisTitleColor:
|
|
688
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {title: Object.assign({}, axis.title, {color: value})})));
|
|
689
|
+
return state;
|
|
690
|
+
|
|
691
|
+
case ActionTypes.valueAxisLabelsFormat:
|
|
692
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {format: value})})));
|
|
693
|
+
return state;
|
|
694
|
+
|
|
695
|
+
case ActionTypes.valueAxisLabelsFontName: {
|
|
696
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {font: updateFontName(value, labelSizeDefault, axis.labels && axis.labels.font)})})));
|
|
697
|
+
return state;
|
|
698
|
+
}
|
|
699
|
+
case ActionTypes.valueAxisLabelsFontSize:
|
|
700
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {font: updateFontSize(value, fontNameDefault, axis.labels && axis.labels.font)})})));
|
|
701
|
+
return state;
|
|
702
|
+
case ActionTypes.valueAxisLabelsColor:
|
|
703
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {color: value})})));
|
|
704
|
+
return state;
|
|
705
|
+
|
|
706
|
+
case ActionTypes.valueAxisLabelsRotation: {
|
|
707
|
+
const rotation = hasValue(value) ? value : 'auto';
|
|
708
|
+
state.valueAxis = (state.valueAxis || []).map(axis => (Object.assign({}, axis, {labels: Object.assign({}, axis.labels, {rotation: rotation})})));
|
|
709
|
+
return state;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
default:
|
|
713
|
+
return state;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
export {
|
|
718
|
+
ActionTypes,
|
|
719
|
+
fontSizes,
|
|
720
|
+
fontNames,
|
|
721
|
+
isCategorical,
|
|
722
|
+
parseFont,
|
|
723
|
+
createInitialState,
|
|
724
|
+
createState,
|
|
725
|
+
mergeStates,
|
|
726
|
+
updateState
|
|
727
|
+
};
|