evui 3.3.25 → 3.3.26
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 +150 -97
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +150 -97
- 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.core.js +10 -2
- package/src/components/chart/element/element.pie.js +4 -1
- package/src/components/chart/plugins/plugins.interaction.js +101 -51
- package/src/components/chart/plugins/plugins.legend.gradient.js +10 -10
- package/src/components/chart/plugins/plugins.pie.js +3 -1
- package/src/components/treeGrid/uses.js +6 -4
package/package.json
CHANGED
|
@@ -122,14 +122,21 @@ class EvChart {
|
|
|
122
122
|
initRect() {
|
|
123
123
|
const opt = this.options;
|
|
124
124
|
if (opt.title.show) {
|
|
125
|
-
this.
|
|
125
|
+
if (!this.isInitTitle) {
|
|
126
|
+
this.initTitle();
|
|
127
|
+
}
|
|
128
|
+
|
|
126
129
|
this.showTitle();
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
if (opt.legend.show) {
|
|
130
|
-
this.
|
|
133
|
+
if (!this.isInitLegend) {
|
|
134
|
+
this.initLegend();
|
|
135
|
+
}
|
|
136
|
+
|
|
131
137
|
this.setLegendPosition();
|
|
132
138
|
}
|
|
139
|
+
|
|
133
140
|
this.chartRect = this.getChartRect();
|
|
134
141
|
}
|
|
135
142
|
|
|
@@ -755,6 +762,7 @@ class EvChart {
|
|
|
755
762
|
this.bufferCtx.restore();
|
|
756
763
|
this.bufferCtx.save();
|
|
757
764
|
|
|
765
|
+
this.initRect();
|
|
758
766
|
this.initScale();
|
|
759
767
|
this.chartRect = this.getChartRect();
|
|
760
768
|
this.drawChart();
|
|
@@ -150,7 +150,10 @@ class Pie {
|
|
|
150
150
|
|
|
151
151
|
let formattedTxt;
|
|
152
152
|
if (formatter) {
|
|
153
|
-
formattedTxt = formatter(
|
|
153
|
+
formattedTxt = formatter({
|
|
154
|
+
value,
|
|
155
|
+
percentage: this.data.percentage,
|
|
156
|
+
});
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
if (!formatter || typeof formattedTxt !== 'string') {
|
|
@@ -17,32 +17,15 @@ const modules = {
|
|
|
17
17
|
if (this.dragInfo?.isMove) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
+
|
|
20
21
|
const { indicator, tooltip, type } = this.options;
|
|
21
22
|
const offset = this.getMousePosition(e);
|
|
22
23
|
const hitInfo = this.findHitItem(offset);
|
|
24
|
+
|
|
23
25
|
if (tooltip?.showAllValueInRange && hitInfo?.items) {
|
|
24
|
-
|
|
25
|
-
const hitItemId = Object.keys(hitInfo.items)[0];
|
|
26
|
-
const hitItemData = isHorizontal
|
|
27
|
-
? hitInfo.items?.[hitItemId]?.data?.y : hitInfo.items?.[hitItemId]?.data?.x;
|
|
28
|
-
const sIds = Object.keys(this.seriesList);
|
|
29
|
-
for (let ix = 0; ix < sIds.length; ix++) {
|
|
30
|
-
const sId = sIds[ix];
|
|
31
|
-
const series = this.seriesList[sId];
|
|
32
|
-
const hasData = series.data.find(data =>
|
|
33
|
-
(isHorizontal ? data.y : data?.x === hitItemData));
|
|
34
|
-
if (hasData && !hitInfo.items[sId] && series?.show) {
|
|
35
|
-
const item = {};
|
|
36
|
-
item.color = series.color;
|
|
37
|
-
item.hit = false;
|
|
38
|
-
item.name = series.name;
|
|
39
|
-
item.axis = { x: series.xAxisIndex, y: series.yAxisIndex };
|
|
40
|
-
item.index = isHorizontal ? series.yAxisIndex : series.xAxisIndex;
|
|
41
|
-
item.data = hasData;
|
|
42
|
-
hitInfo.items[sId] = item;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
26
|
+
this.addNotHitInfo(hitInfo);
|
|
45
27
|
}
|
|
28
|
+
|
|
46
29
|
const ctx = this.overlayCtx;
|
|
47
30
|
|
|
48
31
|
this.overlayClear();
|
|
@@ -376,10 +359,6 @@ const modules = {
|
|
|
376
359
|
const items = {};
|
|
377
360
|
const isHorizontal = !!this.options.horizontal;
|
|
378
361
|
const ctx = this.tooltipCtx;
|
|
379
|
-
const tooltipOpt = this.options.tooltip;
|
|
380
|
-
const tooltipValueFormatter = typeof tooltipOpt.formatter === 'function'
|
|
381
|
-
? tooltipOpt.formatter
|
|
382
|
-
: tooltipOpt.formatter?.value;
|
|
383
362
|
|
|
384
363
|
let hitId = null;
|
|
385
364
|
let maxs = '';
|
|
@@ -414,31 +393,11 @@ const modules = {
|
|
|
414
393
|
item.axis = { x: series.xAxisIndex, y: series.yAxisIndex };
|
|
415
394
|
items[sId] = item;
|
|
416
395
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
name: sName,
|
|
423
|
-
});
|
|
424
|
-
} else if (this.options.type === 'heatMap') {
|
|
425
|
-
formattedTxt = tooltipValueFormatter({
|
|
426
|
-
x: item.data.x,
|
|
427
|
-
y: item.data.y,
|
|
428
|
-
value: gdata > -1 ? gdata : 'error',
|
|
429
|
-
});
|
|
430
|
-
} else {
|
|
431
|
-
formattedTxt = tooltipValueFormatter({
|
|
432
|
-
x: this.options.horizontal ? gdata : item.data.x,
|
|
433
|
-
y: this.options.horizontal ? item.data.y : gdata,
|
|
434
|
-
name: sName,
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
if (!tooltipValueFormatter || typeof formattedTxt !== 'string') {
|
|
440
|
-
formattedTxt = numberWithComma(gdata);
|
|
441
|
-
}
|
|
396
|
+
const formattedTxt = this.getFormattedTooltipValue({
|
|
397
|
+
seriesName: sName,
|
|
398
|
+
value: gdata,
|
|
399
|
+
itemData: item.data,
|
|
400
|
+
});
|
|
442
401
|
|
|
443
402
|
item.data.formatted = formattedTxt;
|
|
444
403
|
|
|
@@ -470,6 +429,97 @@ const modules = {
|
|
|
470
429
|
return { items, hitId, maxTip: [maxs, maxv], maxHighlight };
|
|
471
430
|
},
|
|
472
431
|
|
|
432
|
+
/**
|
|
433
|
+
* get formatted value for tooltip
|
|
434
|
+
* @param seriesName
|
|
435
|
+
* @param value
|
|
436
|
+
* @param x
|
|
437
|
+
* @param y
|
|
438
|
+
* @returns {string}
|
|
439
|
+
*/
|
|
440
|
+
getFormattedTooltipValue({ seriesName, value, itemData }) {
|
|
441
|
+
const tooltipOpt = this.options.tooltip;
|
|
442
|
+
const tooltipValueFormatter = typeof tooltipOpt.formatter === 'function'
|
|
443
|
+
? tooltipOpt.formatter
|
|
444
|
+
: tooltipOpt.formatter?.value;
|
|
445
|
+
|
|
446
|
+
let formattedTxt = value;
|
|
447
|
+
if (tooltipValueFormatter) {
|
|
448
|
+
if (this.options.type === 'pie') {
|
|
449
|
+
formattedTxt = tooltipValueFormatter({
|
|
450
|
+
value,
|
|
451
|
+
name: seriesName,
|
|
452
|
+
percentage: itemData.percentage,
|
|
453
|
+
});
|
|
454
|
+
} else if (this.options.type === 'heatMap') {
|
|
455
|
+
formattedTxt = tooltipValueFormatter({
|
|
456
|
+
x: itemData.x,
|
|
457
|
+
y: itemData.y,
|
|
458
|
+
value: value > -1 ? value : 'error',
|
|
459
|
+
});
|
|
460
|
+
} else {
|
|
461
|
+
formattedTxt = tooltipValueFormatter({
|
|
462
|
+
x: this.options.horizontal ? value : itemData.x,
|
|
463
|
+
y: this.options.horizontal ? itemData.y : value,
|
|
464
|
+
name: seriesName,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (value && (!tooltipValueFormatter || typeof formattedTxt !== 'string')) {
|
|
470
|
+
if (this.options.type === 'heatMap') {
|
|
471
|
+
formattedTxt = value < 0 ? 'error' : numberWithComma(value);
|
|
472
|
+
} else {
|
|
473
|
+
formattedTxt = numberWithComma(value);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return formattedTxt;
|
|
478
|
+
},
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* add not hit info
|
|
482
|
+
* @param hitInfo
|
|
483
|
+
*/
|
|
484
|
+
addNotHitInfo(hitInfo) {
|
|
485
|
+
const isHorizontal = !!this.options.horizontal;
|
|
486
|
+
|
|
487
|
+
const hitItemId = Object.keys(hitInfo.items)[0];
|
|
488
|
+
const hitItemData = isHorizontal
|
|
489
|
+
? hitInfo.items?.[hitItemId]?.data?.y : hitInfo.items?.[hitItemId]?.data?.x;
|
|
490
|
+
|
|
491
|
+
const sIds = Object.keys(this.seriesList);
|
|
492
|
+
for (let ix = 0; ix < sIds.length; ix++) {
|
|
493
|
+
const sId = sIds[ix];
|
|
494
|
+
const series = this.seriesList[sId];
|
|
495
|
+
|
|
496
|
+
const hasData = series.data.find(data => (
|
|
497
|
+
isHorizontal
|
|
498
|
+
? data?.y === hitItemData
|
|
499
|
+
: data?.x === hitItemData
|
|
500
|
+
),
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
if (hasData && !hitInfo.items[sId] && series?.show) {
|
|
504
|
+
const item = {};
|
|
505
|
+
item.color = series.color;
|
|
506
|
+
item.hit = false;
|
|
507
|
+
item.name = series.name;
|
|
508
|
+
item.axis = { x: series.xAxisIndex, y: series.yAxisIndex };
|
|
509
|
+
item.index = isHorizontal ? series.yAxisIndex : series.xAxisIndex;
|
|
510
|
+
item.data = hasData;
|
|
511
|
+
item.data.formatted = this.getFormattedTooltipValue({
|
|
512
|
+
seriesName: series.name,
|
|
513
|
+
value: hasData.o,
|
|
514
|
+
x: hasData.x,
|
|
515
|
+
y: hasData.y,
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
hitInfo.items[sId] = item;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
|
|
473
523
|
/**
|
|
474
524
|
*
|
|
475
525
|
* @param targetInfo {object} '{ dataIndex: number, seriesID: string }'
|
|
@@ -695,7 +745,7 @@ const modules = {
|
|
|
695
745
|
}
|
|
696
746
|
|
|
697
747
|
const sId = Object.keys(this.seriesList)[0];
|
|
698
|
-
const { xMin, xMax, yMin, yMax } = this.seriesList[sId].findSelectionRange(range);
|
|
748
|
+
const { xMin, xMax, yMin, yMax } = this.seriesList[sId].findSelectionRange(range) ?? {};
|
|
699
749
|
|
|
700
750
|
return {
|
|
701
751
|
xMin: xMin ?? dataRangeX.graphMin,
|
|
@@ -183,9 +183,7 @@ const modules = {
|
|
|
183
183
|
this.onLegendBoxLeave = () => {
|
|
184
184
|
this.legendDragInfo.dragging = false;
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
const targetDOM = lineDOM.getElementsByClassName('ev-chart-legend-thumb')[0];
|
|
188
|
-
this.clearOverlay(targetDOM);
|
|
186
|
+
this.clearOverlay();
|
|
189
187
|
|
|
190
188
|
const seriesList = Object.values(this.seriesList);
|
|
191
189
|
if (!seriesList.length) {
|
|
@@ -256,7 +254,7 @@ const modules = {
|
|
|
256
254
|
|
|
257
255
|
clearOverlay() {
|
|
258
256
|
const targetDOM = this.containerDOM.getElementsByClassName('ev-chart-legend-line')[0];
|
|
259
|
-
const overlayDOM = targetDOM
|
|
257
|
+
const overlayDOM = targetDOM?.getElementsByClassName('ev-chart-legend-overlay')[0];
|
|
260
258
|
if (overlayDOM) {
|
|
261
259
|
targetDOM.removeChild(overlayDOM);
|
|
262
260
|
|
|
@@ -307,13 +305,15 @@ const modules = {
|
|
|
307
305
|
|
|
308
306
|
overlayDOM.appendChild(tooltipDOM);
|
|
309
307
|
overlayDOM.appendChild(itemDOM);
|
|
310
|
-
targetDOM
|
|
308
|
+
targetDOM?.appendChild(overlayDOM);
|
|
311
309
|
|
|
312
|
-
const thumbDOM = targetDOM
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
labelDOM
|
|
316
|
-
|
|
310
|
+
const thumbDOM = targetDOM?.getElementsByClassName('ev-chart-legend-thumb')[0];
|
|
311
|
+
if (thumbDOM) {
|
|
312
|
+
const labels = thumbDOM.children;
|
|
313
|
+
labels.forEach((labelDOM) => {
|
|
314
|
+
labelDOM.style.opacity = 0.2;
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
317
|
},
|
|
318
318
|
|
|
319
319
|
createLegendHandle(type) {
|
|
@@ -21,6 +21,7 @@ const modules = {
|
|
|
21
21
|
let startAngle = 1.5 * Math.PI;
|
|
22
22
|
let endAngle;
|
|
23
23
|
let series;
|
|
24
|
+
let percentage;
|
|
24
25
|
|
|
25
26
|
const centerX = chartRect.width / 2;
|
|
26
27
|
const centerY = chartRect.height / 2;
|
|
@@ -57,6 +58,7 @@ const modules = {
|
|
|
57
58
|
for (let jx = 0; jx < pie.data.length; jx++) {
|
|
58
59
|
slice = pie.data[jx];
|
|
59
60
|
value = slice.value;
|
|
61
|
+
percentage = (value / pie.total) * 100;
|
|
60
62
|
sliceAngle = 2 * Math.PI * (value / pie.total);
|
|
61
63
|
endAngle = startAngle + sliceAngle;
|
|
62
64
|
|
|
@@ -83,7 +85,7 @@ const modules = {
|
|
|
83
85
|
series.doughnutHoleSize = radius * (pieOption.doughnutHoleSize ?? 0);
|
|
84
86
|
series.startAngle = startAngle;
|
|
85
87
|
series.endAngle = endAngle;
|
|
86
|
-
series.data = { o: value };
|
|
88
|
+
series.data = { o: value, percentage };
|
|
87
89
|
|
|
88
90
|
series.draw(ctx, strokeOptions);
|
|
89
91
|
startAngle += sliceAngle;
|
|
@@ -360,10 +360,12 @@ export const clickEvent = (params) => {
|
|
|
360
360
|
const getClickedRowData = (event, row) => {
|
|
361
361
|
const tagName = event.target.tagName.toLowerCase();
|
|
362
362
|
let cellInfo = {};
|
|
363
|
-
if (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
363
|
+
if (event.target.offsetParent) {
|
|
364
|
+
if (tagName === 'td') {
|
|
365
|
+
cellInfo = event.target.dataset;
|
|
366
|
+
} else {
|
|
367
|
+
cellInfo = event.target.closest('td').dataset;
|
|
368
|
+
}
|
|
367
369
|
}
|
|
368
370
|
return {
|
|
369
371
|
event,
|