evui 3.3.29 → 3.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evui.common.js +750 -309
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +750 -309
- package/dist/evui.umd.js.map +1 -1
- package/dist/evui.umd.min.js +1 -1
- package/dist/evui.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chart/Chart.vue +4 -0
- package/src/components/chart/chart.core.js +59 -41
- package/src/components/chart/element/element.bar.js +10 -6
- package/src/components/chart/element/element.bar.time.js +6 -3
- package/src/components/chart/element/element.line.js +37 -26
- package/src/components/chart/element/element.pie.js +2 -3
- package/src/components/chart/element/element.scatter.js +8 -15
- package/src/components/chart/helpers/helpers.util.js +10 -0
- package/src/components/chart/model/model.store.js +25 -0
- package/src/components/chart/plugins/plugins.interaction.js +53 -42
- package/src/components/chart/plugins/plugins.legend.js +362 -82
- package/src/components/chart/plugins/plugins.pie.js +14 -2
- package/src/components/chart/style/chart.scss +73 -5
- package/src/components/chart/uses.js +28 -0
- package/src/components/grid/style/grid.scss +0 -1
- package/src/components/treeGrid/style/treeGrid.scss +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Util from '
|
|
1
|
+
import Util from '../helpers/helpers.util';
|
|
2
2
|
|
|
3
3
|
const modules = {
|
|
4
4
|
/**
|
|
@@ -20,10 +20,48 @@ const modules = {
|
|
|
20
20
|
this.wrapperDOM.appendChild(this.resizeDOM);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
if (this.useTable) {
|
|
24
|
+
this.legendTableDOM = document.createElement('table');
|
|
25
|
+
this.legendTableDOM.className = 'ev-chart-legend--table';
|
|
26
|
+
this.setLegendColumnHeader();
|
|
27
|
+
this.legendBoxDOM.appendChild(this.legendTableDOM);
|
|
28
|
+
this.legendDOM.style.overflow = 'auto';
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
this.legendDOM.appendChild(this.legendBoxDOM);
|
|
24
32
|
this.wrapperDOM.appendChild(this.legendDOM);
|
|
25
33
|
},
|
|
26
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Create and append Table Header DOM
|
|
37
|
+
* Only chartOption > legend > table > use : true
|
|
38
|
+
*
|
|
39
|
+
* @returns {undefined}
|
|
40
|
+
*/
|
|
41
|
+
setLegendColumnHeader() {
|
|
42
|
+
const tableOpt = this.options.legend?.table;
|
|
43
|
+
const columns = tableOpt.columns;
|
|
44
|
+
const columnKeyList = ['color', ...Object.keys(columns)];
|
|
45
|
+
|
|
46
|
+
columnKeyList.forEach((key) => {
|
|
47
|
+
const columnNameDOM = document.createElement('th');
|
|
48
|
+
columnNameDOM.className = 'ev-chart-legend--table__column-name';
|
|
49
|
+
|
|
50
|
+
if (columns[key]?.use || key === 'color' || key === 'name') {
|
|
51
|
+
const columnOpt = columns[key];
|
|
52
|
+
const keyText = columnOpt?.title ?? '';
|
|
53
|
+
|
|
54
|
+
columnNameDOM.textContent = keyText;
|
|
55
|
+
columnNameDOM.setAttribute('title', keyText);
|
|
56
|
+
columnNameDOM.dataset.type = keyText;
|
|
57
|
+
|
|
58
|
+
Util.setDOMStyle(columnNameDOM, tableOpt?.style?.header);
|
|
59
|
+
|
|
60
|
+
this.legendTableDOM.append(columnNameDOM);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
|
|
27
65
|
/**
|
|
28
66
|
* Initialize legend
|
|
29
67
|
* If there was no initialization, create DOM and set default layout.
|
|
@@ -33,6 +71,8 @@ const modules = {
|
|
|
33
71
|
*/
|
|
34
72
|
initLegend() {
|
|
35
73
|
this.isHeatMapType = this.options.type === 'heatMap';
|
|
74
|
+
this.useTable = !!this.options.legend?.table?.use && this.options.type !== 'heatmap' && this.options.type !== 'scatter';
|
|
75
|
+
|
|
36
76
|
if (!this.isInitLegend) {
|
|
37
77
|
this.createLegendLayout();
|
|
38
78
|
}
|
|
@@ -44,6 +84,7 @@ const modules = {
|
|
|
44
84
|
this.initEvent();
|
|
45
85
|
this.addLegendList();
|
|
46
86
|
}
|
|
87
|
+
|
|
47
88
|
this.initResizeEvent();
|
|
48
89
|
|
|
49
90
|
this.isInitLegend = true;
|
|
@@ -63,19 +104,37 @@ const modules = {
|
|
|
63
104
|
|
|
64
105
|
groups.forEach((group) => {
|
|
65
106
|
group.slice().reverse().forEach((sId) => {
|
|
66
|
-
|
|
67
|
-
|
|
107
|
+
const series = seriesList[sId];
|
|
108
|
+
|
|
109
|
+
if (series && series.showLegend) {
|
|
110
|
+
if (this.useTable) {
|
|
111
|
+
this.addLegendWithValues(series);
|
|
112
|
+
} else {
|
|
113
|
+
this.addLegend(series);
|
|
114
|
+
}
|
|
68
115
|
}
|
|
69
116
|
});
|
|
70
117
|
});
|
|
71
118
|
|
|
72
119
|
Object.values(seriesList).forEach((series) => {
|
|
73
|
-
if (
|
|
120
|
+
if (series.isExistGrp || !series.showLegend) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (this.useTable) {
|
|
125
|
+
this.addLegendWithValues(series);
|
|
126
|
+
} else {
|
|
74
127
|
this.addLegend(series);
|
|
75
128
|
}
|
|
76
129
|
});
|
|
77
130
|
},
|
|
78
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Add Legend with Color Information
|
|
134
|
+
* Only Heatmap chart
|
|
135
|
+
*
|
|
136
|
+
* @returns {undefined}
|
|
137
|
+
*/
|
|
79
138
|
addColorLegendList() {
|
|
80
139
|
const seriesList = this.seriesList;
|
|
81
140
|
|
|
@@ -120,6 +179,31 @@ const modules = {
|
|
|
120
179
|
});
|
|
121
180
|
},
|
|
122
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Get Container DOM by Event Object
|
|
184
|
+
* @param e Event
|
|
185
|
+
*
|
|
186
|
+
* @returns {Element}
|
|
187
|
+
*/
|
|
188
|
+
getContainerDOM(e) {
|
|
189
|
+
let targetDOM = null;
|
|
190
|
+
const type = e.target.dataset.type;
|
|
191
|
+
|
|
192
|
+
const childTypes = ['name', 'color', 'min', 'max', 'avg', 'total', 'last'];
|
|
193
|
+
|
|
194
|
+
if (type === 'container') {
|
|
195
|
+
targetDOM = e.target;
|
|
196
|
+
} else if (childTypes.includes(type)) {
|
|
197
|
+
targetDOM = e.target.parentElement;
|
|
198
|
+
|
|
199
|
+
if (!targetDOM?.series) {
|
|
200
|
+
targetDOM = targetDOM.parentElement;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return targetDOM;
|
|
205
|
+
},
|
|
206
|
+
|
|
123
207
|
/**
|
|
124
208
|
* Initialize legend event
|
|
125
209
|
*
|
|
@@ -129,6 +213,14 @@ const modules = {
|
|
|
129
213
|
if (this.isInitLegend) {
|
|
130
214
|
return;
|
|
131
215
|
}
|
|
216
|
+
|
|
217
|
+
const classList = {
|
|
218
|
+
container: `ev-chart-legend${this.useTable ? '--table__container' : '-container'}`,
|
|
219
|
+
color: `ev-chart-legend${this.useTable ? '--table__color' : '-color'}`,
|
|
220
|
+
name: `ev-chart-legend${this.useTable ? '--table__name' : '-name'}`,
|
|
221
|
+
value: `ev-chart-legend${this.useTable ? '--table__value' : '-value'}`,
|
|
222
|
+
};
|
|
223
|
+
|
|
132
224
|
/**
|
|
133
225
|
* callback for legendBoxDOM to show/hide clicked series
|
|
134
226
|
*
|
|
@@ -136,22 +228,19 @@ const modules = {
|
|
|
136
228
|
*/
|
|
137
229
|
this.onLegendBoxClick = (e) => {
|
|
138
230
|
const opt = this.options.legend;
|
|
139
|
-
const type = e.target.dataset.type;
|
|
140
231
|
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
targetDOM = e.target;
|
|
144
|
-
} else if (type === 'name' || type === 'color') {
|
|
145
|
-
targetDOM = e.target.parentElement;
|
|
146
|
-
} else {
|
|
232
|
+
const targetDOM = this.getContainerDOM(e);
|
|
233
|
+
if (!targetDOM) {
|
|
147
234
|
return;
|
|
148
235
|
}
|
|
149
236
|
|
|
150
|
-
const
|
|
151
|
-
const nameDOM = targetDOM?.getElementsByClassName('ev-chart-legend-name')[0];
|
|
152
|
-
const isActive = !colorDOM?.className.includes('inactive');
|
|
153
|
-
const series = nameDOM?.series;
|
|
237
|
+
const series = targetDOM?.series;
|
|
154
238
|
|
|
239
|
+
const colorDOM = targetDOM?.getElementsByClassName(classList.color)[0];
|
|
240
|
+
const nameDOM = targetDOM?.getElementsByClassName(classList.name)[0];
|
|
241
|
+
const valueDOMList = targetDOM?.getElementsByClassName(classList.value);
|
|
242
|
+
|
|
243
|
+
const isActive = !targetDOM?.className.includes('inactive');
|
|
155
244
|
if (isActive && this.seriesInfo.count === 1) {
|
|
156
245
|
return;
|
|
157
246
|
}
|
|
@@ -162,9 +251,14 @@ const modules = {
|
|
|
162
251
|
|
|
163
252
|
if (isActive) {
|
|
164
253
|
this.seriesInfo.count--;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
254
|
+
|
|
255
|
+
const inactiveColor = opt.inactive;
|
|
256
|
+
colorDOM.style.backgroundColor = inactiveColor;
|
|
257
|
+
colorDOM.style.borderColor = inactiveColor;
|
|
258
|
+
nameDOM.style.color = inactiveColor;
|
|
259
|
+
valueDOMList?.forEach((dom) => {
|
|
260
|
+
dom.style.color = inactiveColor;
|
|
261
|
+
});
|
|
168
262
|
} else {
|
|
169
263
|
this.seriesInfo.count++;
|
|
170
264
|
|
|
@@ -184,11 +278,14 @@ const modules = {
|
|
|
184
278
|
}
|
|
185
279
|
|
|
186
280
|
nameDOM.style.color = opt.color;
|
|
281
|
+
valueDOMList?.forEach((dom) => {
|
|
282
|
+
const style = opt.table?.columns[dom.dataset.type]?.style;
|
|
283
|
+
dom.style.color = style?.color ? style.color : opt.color;
|
|
284
|
+
});
|
|
187
285
|
}
|
|
188
286
|
|
|
189
287
|
series.show = !series.show;
|
|
190
|
-
|
|
191
|
-
nameDOM.classList.toggle('inactive');
|
|
288
|
+
targetDOM.classList.toggle('inactive');
|
|
192
289
|
|
|
193
290
|
this.update({
|
|
194
291
|
updateSeries: false,
|
|
@@ -202,36 +299,20 @@ const modules = {
|
|
|
202
299
|
* @returns {undefined}
|
|
203
300
|
*/
|
|
204
301
|
this.onLegendBoxOver = (e) => {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
let targetDOM;
|
|
208
|
-
if (type === 'container') {
|
|
209
|
-
targetDOM = e.target;
|
|
210
|
-
} else if (type === 'name' || type === 'color') {
|
|
211
|
-
targetDOM = e.target.parentElement;
|
|
212
|
-
} else {
|
|
302
|
+
const targetDOM = this.getContainerDOM(e);
|
|
303
|
+
if (!targetDOM) {
|
|
213
304
|
return;
|
|
214
305
|
}
|
|
215
|
-
const nameDOM = targetDOM.getElementsByClassName('ev-chart-legend-name')[0];
|
|
216
|
-
const targetId = nameDOM.series.sId;
|
|
217
|
-
const selectSeriesOption = this.options.selectSeries;
|
|
218
|
-
const selectedList = this.defaultSelectInfo?.seriesId ?? [];
|
|
219
|
-
|
|
220
|
-
Object.values(this.seriesList).forEach((series) => {
|
|
221
|
-
series.state = series.sId === targetId
|
|
222
|
-
|| (selectSeriesOption.use && selectedList.includes(targetId))
|
|
223
|
-
? 'highlight' : 'downplay';
|
|
224
|
-
});
|
|
225
306
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
hitInfo = { sId: targetId, type: this.options.type };
|
|
229
|
-
}
|
|
307
|
+
const targetId = targetDOM?.series?.sId;
|
|
308
|
+
const legendHitInfo = { sId: targetId, type: this.options.type };
|
|
230
309
|
|
|
231
310
|
this.update({
|
|
232
311
|
updateSeries: false,
|
|
233
312
|
updateSelTip: { update: false, keepDomain: false },
|
|
234
|
-
hitInfo
|
|
313
|
+
hitInfo: {
|
|
314
|
+
legend: legendHitInfo,
|
|
315
|
+
},
|
|
235
316
|
});
|
|
236
317
|
};
|
|
237
318
|
|
|
@@ -241,20 +322,12 @@ const modules = {
|
|
|
241
322
|
* @returns {undefined}
|
|
242
323
|
*/
|
|
243
324
|
this.onLegendBoxLeave = () => {
|
|
244
|
-
const selectSeriesOption = this.options.selectSeries;
|
|
245
|
-
const selectedList = this.defaultSelectInfo?.seriesId ?? [];
|
|
246
|
-
Object.values(this.seriesList).forEach((series) => {
|
|
247
|
-
if (selectSeriesOption.use && selectedList.length) {
|
|
248
|
-
series.state = selectedList.includes(series.sId)
|
|
249
|
-
? 'highlight' : 'downplay';
|
|
250
|
-
} else {
|
|
251
|
-
series.state = 'normal';
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
|
|
255
325
|
this.update({
|
|
256
326
|
updateSeries: false,
|
|
257
327
|
updateSelTip: { update: false, keepDomain: false },
|
|
328
|
+
hitInfo: {
|
|
329
|
+
legend: null,
|
|
330
|
+
},
|
|
258
331
|
});
|
|
259
332
|
};
|
|
260
333
|
|
|
@@ -265,10 +338,15 @@ const modules = {
|
|
|
265
338
|
this.initResizeEvent();
|
|
266
339
|
},
|
|
267
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Init Event on Color Legend
|
|
343
|
+
* Only Heatmap
|
|
344
|
+
*/
|
|
268
345
|
initEventForColorLegend() {
|
|
269
346
|
if (this.isInitLegend) {
|
|
270
347
|
return;
|
|
271
348
|
}
|
|
349
|
+
|
|
272
350
|
/**
|
|
273
351
|
* callback for legendBoxDOM to show/hide clicked series
|
|
274
352
|
*
|
|
@@ -277,21 +355,16 @@ const modules = {
|
|
|
277
355
|
this.onLegendBoxClick = (e) => {
|
|
278
356
|
const opt = this.options.legend;
|
|
279
357
|
const series = Object.values(this.seriesList)[0];
|
|
280
|
-
const type = e.target.dataset.type;
|
|
281
358
|
|
|
282
|
-
|
|
283
|
-
if (
|
|
284
|
-
targetDOM = e.target;
|
|
285
|
-
} else if (type === 'name' || type === 'color') {
|
|
286
|
-
targetDOM = e.target.parentElement;
|
|
287
|
-
} else {
|
|
359
|
+
const targetDOM = this.getContainerDOM(e);
|
|
360
|
+
if (!targetDOM) {
|
|
288
361
|
return;
|
|
289
362
|
}
|
|
290
363
|
|
|
291
364
|
const colorDOM = targetDOM?.getElementsByClassName('ev-chart-legend-color')[0];
|
|
292
365
|
const nameDOM = targetDOM?.getElementsByClassName('ev-chart-legend-name')[0];
|
|
366
|
+
const targetId = targetDOM?.series?.cId;
|
|
293
367
|
const isActive = !colorDOM?.className.includes('inactive');
|
|
294
|
-
const targetId = nameDOM.series.cId;
|
|
295
368
|
const activeCount = series.colorState.filter(colorItem => colorItem.show).length;
|
|
296
369
|
|
|
297
370
|
if (isActive && activeCount === 1) {
|
|
@@ -307,7 +380,7 @@ const modules = {
|
|
|
307
380
|
colorDOM.style.borderColor = opt.inactive;
|
|
308
381
|
nameDOM.style.color = opt.inactive;
|
|
309
382
|
} else {
|
|
310
|
-
colorDOM.style.backgroundColor =
|
|
383
|
+
colorDOM.style.backgroundColor = targetDOM?.series?.color;
|
|
311
384
|
nameDOM.style.color = opt.color;
|
|
312
385
|
}
|
|
313
386
|
|
|
@@ -324,25 +397,21 @@ const modules = {
|
|
|
324
397
|
updateSelTip: { update: true, keepDomain: true },
|
|
325
398
|
});
|
|
326
399
|
};
|
|
400
|
+
|
|
327
401
|
/**
|
|
328
402
|
* callback for legendBoxDOM hovering
|
|
329
403
|
*
|
|
330
404
|
* @returns {undefined}
|
|
331
405
|
*/
|
|
332
406
|
this.onLegendBoxOver = (e) => {
|
|
333
|
-
const
|
|
334
|
-
const series = Object.values(this.seriesList)[0];
|
|
407
|
+
const series = Object.values(this.seriesList)?.[0];
|
|
335
408
|
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
targetDOM = e.target;
|
|
339
|
-
} else if (type === 'name' || type === 'color') {
|
|
340
|
-
targetDOM = e.target.parentElement;
|
|
341
|
-
} else {
|
|
409
|
+
const targetDOM = this.getContainerDOM(e);
|
|
410
|
+
if (!targetDOM) {
|
|
342
411
|
return;
|
|
343
412
|
}
|
|
344
|
-
|
|
345
|
-
const targetId =
|
|
413
|
+
|
|
414
|
+
const targetId = targetDOM?.series?.cId;
|
|
346
415
|
|
|
347
416
|
series.colorState.forEach((colorItem) => {
|
|
348
417
|
colorItem.state = colorItem.id === targetId ? 'highlight' : 'downplay';
|
|
@@ -370,6 +439,7 @@ const modules = {
|
|
|
370
439
|
updateSelTip: { update: false, keepDomain: false },
|
|
371
440
|
});
|
|
372
441
|
};
|
|
442
|
+
|
|
373
443
|
this.legendBoxDOM.addEventListener('click', this.onLegendBoxClick);
|
|
374
444
|
this.legendBoxDOM.addEventListener('mouseover', this.onLegendBoxOver);
|
|
375
445
|
this.legendBoxDOM.addEventListener('mouseleave', this.onLegendBoxLeave);
|
|
@@ -431,6 +501,7 @@ const modules = {
|
|
|
431
501
|
*/
|
|
432
502
|
updateLegend() {
|
|
433
503
|
this.resetLegend();
|
|
504
|
+
|
|
434
505
|
if (this.isHeatMapType) {
|
|
435
506
|
this.addColorLegendList();
|
|
436
507
|
} else {
|
|
@@ -438,21 +509,80 @@ const modules = {
|
|
|
438
509
|
}
|
|
439
510
|
},
|
|
440
511
|
|
|
512
|
+
/**
|
|
513
|
+
* To update value text on legend table
|
|
514
|
+
* Only chartOption > legend > table > use : true
|
|
515
|
+
*
|
|
516
|
+
* @returns {undefined}
|
|
517
|
+
*/
|
|
518
|
+
updateLegendTableValues() {
|
|
519
|
+
const columns = this.options?.legend?.table?.columns;
|
|
520
|
+
const aggregations = this.getAggregations();
|
|
521
|
+
const rowDOMList = this.legendBoxDOM?.getElementsByClassName('ev-chart-legend--table__row');
|
|
522
|
+
|
|
523
|
+
rowDOMList.forEach((row) => {
|
|
524
|
+
const valueDOMList = row?.getElementsByClassName('ev-chart-legend--table__value');
|
|
525
|
+
|
|
526
|
+
valueDOMList.forEach((dom) => {
|
|
527
|
+
const key = dom.dataset.type;
|
|
528
|
+
if (key === 'name') {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const seriesId = row.series.sId;
|
|
533
|
+
const value = +aggregations?.[seriesId]?.[key];
|
|
534
|
+
dom.textContent = this.getFormattedValue(columns[key], value);
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
},
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Force Update Legend. Remove and Create
|
|
541
|
+
*
|
|
542
|
+
* @returns {undefined}
|
|
543
|
+
*/
|
|
544
|
+
forceUpdateLegend() {
|
|
545
|
+
this.destroyLegend();
|
|
546
|
+
this.initLegend();
|
|
547
|
+
},
|
|
548
|
+
|
|
441
549
|
/**
|
|
442
550
|
* To update legend, remove all of legendBoxDOM's children
|
|
443
551
|
*
|
|
444
552
|
* @returns {undefined}
|
|
445
553
|
*/
|
|
446
554
|
resetLegend() {
|
|
447
|
-
const
|
|
555
|
+
const legendBoxDOM = this.legendBoxDOM;
|
|
448
556
|
|
|
449
|
-
if (!
|
|
557
|
+
if (!legendBoxDOM) {
|
|
450
558
|
return;
|
|
451
559
|
}
|
|
452
560
|
|
|
453
|
-
while (
|
|
454
|
-
|
|
561
|
+
while (legendBoxDOM.hasChildNodes()) {
|
|
562
|
+
legendBoxDOM.removeChild(legendBoxDOM.firstChild);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
this.seriesInfo.count = 0;
|
|
566
|
+
},
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* To update legend, remove all of legendBoxDOM's children
|
|
570
|
+
*
|
|
571
|
+
* @returns {undefined}
|
|
572
|
+
*/
|
|
573
|
+
destroyLegend() {
|
|
574
|
+
const legendDOM = this.legendDOM;
|
|
575
|
+
|
|
576
|
+
if (!legendDOM) {
|
|
577
|
+
return;
|
|
455
578
|
}
|
|
579
|
+
|
|
580
|
+
legendDOM.remove();
|
|
581
|
+
|
|
582
|
+
this.legendDOM = null;
|
|
583
|
+
this.legendBoxDOM = null;
|
|
584
|
+
this.resizeDOM = null;
|
|
585
|
+
this.isInitLegend = false;
|
|
456
586
|
this.seriesInfo.count = 0;
|
|
457
587
|
},
|
|
458
588
|
|
|
@@ -467,7 +597,9 @@ const modules = {
|
|
|
467
597
|
const colorDOM = document.createElement('span');
|
|
468
598
|
const nameDOM = document.createElement('div');
|
|
469
599
|
|
|
470
|
-
containerDOM.className =
|
|
600
|
+
containerDOM.className = `ev-chart-legend-container ${!series.show ? ' inactive' : ''}`;
|
|
601
|
+
containerDOM.series = series;
|
|
602
|
+
|
|
471
603
|
colorDOM.className = 'ev-chart-legend-color';
|
|
472
604
|
|
|
473
605
|
if (series.type === 'line' && series.point && !series.fill) {
|
|
@@ -475,10 +607,12 @@ const modules = {
|
|
|
475
607
|
}
|
|
476
608
|
|
|
477
609
|
nameDOM.className = 'ev-chart-legend-name';
|
|
478
|
-
nameDOM.series = series;
|
|
479
610
|
|
|
611
|
+
// set series color
|
|
480
612
|
let seriesColor;
|
|
481
|
-
if (
|
|
613
|
+
if (!series.show) {
|
|
614
|
+
seriesColor = opt.inactive;
|
|
615
|
+
} else if (typeof series.color !== 'string') {
|
|
482
616
|
seriesColor = series.color[series.color.length - 1][1];
|
|
483
617
|
} else {
|
|
484
618
|
seriesColor = series.color;
|
|
@@ -486,7 +620,7 @@ const modules = {
|
|
|
486
620
|
|
|
487
621
|
if (series.type === 'line' && series.fill) {
|
|
488
622
|
colorDOM.style.height = '8px';
|
|
489
|
-
colorDOM.style.backgroundColor = `${seriesColor}80
|
|
623
|
+
colorDOM.style.backgroundColor = series.show ? `${seriesColor}80` : opt.inactive;
|
|
490
624
|
colorDOM.style.border = `1px solid ${seriesColor}`;
|
|
491
625
|
} else {
|
|
492
626
|
colorDOM.style.backgroundColor = seriesColor;
|
|
@@ -515,7 +649,130 @@ const modules = {
|
|
|
515
649
|
containerDOM.dataset.type = 'container';
|
|
516
650
|
|
|
517
651
|
this.legendBoxDOM.appendChild(containerDOM);
|
|
518
|
-
|
|
652
|
+
if (series.show) {
|
|
653
|
+
this.seriesInfo.count++;
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Add Legend Items With aggregation Values
|
|
659
|
+
* Only chartOption > legend > table > use : true
|
|
660
|
+
* @param series
|
|
661
|
+
*/
|
|
662
|
+
addLegendWithValues(series) {
|
|
663
|
+
const opt = this.options.legend;
|
|
664
|
+
const columns = opt?.table?.columns;
|
|
665
|
+
|
|
666
|
+
const aggregations = this.getAggregations()?.[series?.sId];
|
|
667
|
+
if (!aggregations || !columns) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// create row
|
|
672
|
+
const rowDOM = document.createElement('tr');
|
|
673
|
+
rowDOM.className = `ev-chart-legend--table__row ${!series.show ? ' inactive' : ''}`;
|
|
674
|
+
Util.setDOMStyle(rowDOM, opt.table?.style?.row);
|
|
675
|
+
rowDOM.series = series;
|
|
676
|
+
rowDOM.dataset.type = 'container';
|
|
677
|
+
|
|
678
|
+
// create td - color
|
|
679
|
+
const colorWrapperDOM = document.createElement('td');
|
|
680
|
+
colorWrapperDOM.className = 'ev-chart-legend--table__color-wrapper';
|
|
681
|
+
colorWrapperDOM.dataset.type = 'color';
|
|
682
|
+
|
|
683
|
+
const colorDOM = document.createElement('div');
|
|
684
|
+
colorDOM.className = 'ev-chart-legend--table__color';
|
|
685
|
+
colorDOM.dataset.type = 'color';
|
|
686
|
+
|
|
687
|
+
// set series color
|
|
688
|
+
let seriesColor;
|
|
689
|
+
if (!series.show) {
|
|
690
|
+
seriesColor = opt.inactive;
|
|
691
|
+
} else if (typeof series.color !== 'string') {
|
|
692
|
+
seriesColor = series.color[series.color.length - 1][1];
|
|
693
|
+
} else {
|
|
694
|
+
seriesColor = series.color;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
switch (series.type) {
|
|
698
|
+
case 'line': {
|
|
699
|
+
if (series.fill) {
|
|
700
|
+
colorDOM.style.backgroundColor = `${seriesColor}80`;
|
|
701
|
+
colorDOM.style.border = `1px solid ${seriesColor}`;
|
|
702
|
+
} else {
|
|
703
|
+
if (series.point) {
|
|
704
|
+
colorDOM.className += ' ev-chart-legend--table__color--point-line';
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
colorDOM.className += ' ev-chart-legend--table__color--line';
|
|
708
|
+
colorDOM.style.backgroundColor = seriesColor;
|
|
709
|
+
}
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
case 'bar':
|
|
714
|
+
case 'pie':
|
|
715
|
+
default: {
|
|
716
|
+
colorDOM.style.height = '10px';
|
|
717
|
+
colorDOM.style.backgroundColor = seriesColor;
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
if (series.type === 'line' && series.fill) {
|
|
723
|
+
colorDOM.style.height = '8px';
|
|
724
|
+
colorDOM.style.backgroundColor = series.show ? `${seriesColor}80` : opt.inactive;
|
|
725
|
+
colorDOM.style.border = `1px solid ${seriesColor}`;
|
|
726
|
+
} else {
|
|
727
|
+
colorDOM.style.backgroundColor = seriesColor;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
colorWrapperDOM.appendChild(colorDOM);
|
|
731
|
+
rowDOM.appendChild(colorWrapperDOM);
|
|
732
|
+
|
|
733
|
+
// create td - name
|
|
734
|
+
const nameDOM = document.createElement('td');
|
|
735
|
+
nameDOM.className = 'ev-chart-legend--table__name';
|
|
736
|
+
nameDOM.style.color = series.show ? opt.color : opt.inactive;
|
|
737
|
+
nameDOM.textContent = series.name;
|
|
738
|
+
nameDOM.setAttribute('title', series.name);
|
|
739
|
+
nameDOM.dataset.type = 'name';
|
|
740
|
+
Util.setDOMStyle(nameDOM, columns?.name?.style);
|
|
741
|
+
|
|
742
|
+
if (!series.show) {
|
|
743
|
+
nameDOM.style.color = opt.inactive;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
rowDOM.appendChild(nameDOM);
|
|
747
|
+
|
|
748
|
+
// create td - values
|
|
749
|
+
const columnKeyList = Object.keys(columns);
|
|
750
|
+
columnKeyList?.forEach((key) => {
|
|
751
|
+
if (key === 'name') {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
if (columns[key].use) {
|
|
756
|
+
const formattedTxt = this.getFormattedValue(columns[key], +aggregations[key]);
|
|
757
|
+
const valueDOM = document.createElement('td');
|
|
758
|
+
valueDOM.className = 'ev-chart-legend--table__value';
|
|
759
|
+
valueDOM.style.color = series.show ? opt.color : opt.inactive;
|
|
760
|
+
valueDOM.textContent = formattedTxt;
|
|
761
|
+
valueDOM.dataset.type = key.toString();
|
|
762
|
+
Util.setDOMStyle(valueDOM, columns[key]?.style);
|
|
763
|
+
|
|
764
|
+
if (!series.show) {
|
|
765
|
+
valueDOM.style.color = opt.inactive;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
rowDOM.appendChild(valueDOM);
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
this.legendTableDOM.appendChild(rowDOM);
|
|
773
|
+
if (series.show) {
|
|
774
|
+
this.seriesInfo.count++;
|
|
775
|
+
}
|
|
519
776
|
},
|
|
520
777
|
|
|
521
778
|
/**
|
|
@@ -684,6 +941,7 @@ const modules = {
|
|
|
684
941
|
}
|
|
685
942
|
}
|
|
686
943
|
},
|
|
944
|
+
|
|
687
945
|
/**
|
|
688
946
|
* When user moves resizeDOM, this function will change css
|
|
689
947
|
*
|
|
@@ -863,6 +1121,28 @@ const modules = {
|
|
|
863
1121
|
legendStyle.height = '0';
|
|
864
1122
|
wrapperStyle.padding = `${title}px 0 0 0`;
|
|
865
1123
|
},
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Get formatted value by formatter function
|
|
1127
|
+
* Only chartOption > legend > table > use : true
|
|
1128
|
+
* @param formatter
|
|
1129
|
+
* @param decimalPoint
|
|
1130
|
+
* @param value
|
|
1131
|
+
* @returns {string}
|
|
1132
|
+
*/
|
|
1133
|
+
getFormattedValue({ formatter, decimalPoint }, value) {
|
|
1134
|
+
let formattedTxt;
|
|
1135
|
+
if (formatter) {
|
|
1136
|
+
formattedTxt = formatter(value);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
if (!formatter || typeof formattedTxt !== 'string') {
|
|
1140
|
+
formattedTxt = Util.labelSignFormat(value, decimalPoint);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
return formattedTxt;
|
|
1144
|
+
},
|
|
1145
|
+
|
|
866
1146
|
};
|
|
867
1147
|
|
|
868
1148
|
export default modules;
|
|
@@ -47,6 +47,10 @@ const modules = {
|
|
|
47
47
|
radius -= pieOption.pieStroke.lineWidth;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
if (radius < 0) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
pie.or = radius;
|
|
51
55
|
if (ix < pieDataSet.length - 1) {
|
|
52
56
|
pie.ir = outerRadius - (((outerRadius - innerRadius) / pieDataSet.length) * (ix + 1));
|
|
@@ -77,7 +81,9 @@ const modules = {
|
|
|
77
81
|
ctx.stroke();
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
const { selectInfo, legendHitInfo } = hitInfo;
|
|
85
|
+
series.isSelect = selectInfo?.sId === slice.id;
|
|
86
|
+
series.isDownplay = (legendHitInfo && legendHitInfo.sId !== slice.id);
|
|
81
87
|
series.type = isDoughnut ? 'doughnut' : 'pie';
|
|
82
88
|
series.centerX = centerX;
|
|
83
89
|
series.centerY = centerY;
|
|
@@ -138,6 +144,10 @@ const modules = {
|
|
|
138
144
|
radius -= pieOption.pieStroke.lineWidth;
|
|
139
145
|
}
|
|
140
146
|
|
|
147
|
+
if (radius < 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
141
151
|
pie.or = radius;
|
|
142
152
|
if (ix < pieDataSet.length - 1) {
|
|
143
153
|
pie.ir = outerRadius - (((outerRadius - innerRadius) / pieDataSet.length) * (ix + 1));
|
|
@@ -175,7 +185,9 @@ const modules = {
|
|
|
175
185
|
ctx.stroke();
|
|
176
186
|
}
|
|
177
187
|
|
|
178
|
-
|
|
188
|
+
const { selectInfo, legendHitInfo } = hitInfo;
|
|
189
|
+
series.isSelect = selectInfo?.sId === slice.id;
|
|
190
|
+
series.isDownplay = (legendHitInfo && legendHitInfo.sId !== slice.id);
|
|
179
191
|
series.type = 'sunburst';
|
|
180
192
|
series.centerX = centerX;
|
|
181
193
|
series.centerY = centerY;
|