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