evui 3.3.2 → 3.3.6
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 +736 -657
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +736 -657
- 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/button/Button.vue +16 -0
- package/src/components/chart/Chart.vue +13 -5
- package/src/components/chart/chart.core.js +25 -1
- package/src/components/chart/element/element.tip.js +53 -26
- package/src/components/chart/model/model.store.js +89 -31
- package/src/components/chart/plugins/plugins.interaction.js +25 -126
- package/src/components/chart/uses.js +9 -2
- package/src/components/grid/Grid.vue +5 -2
- package/src/components/grid/uses.js +38 -36
- package/src/components/message/Message.vue +3 -2
- package/src/components/messageBox/MessageBox.vue +38 -6
- package/src/components/notification/Notification.vue +3 -2
- package/src/components/treeGrid/TreeGrid.vue +6 -4
- package/src/components/treeGrid/uses.js +41 -35
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<button
|
|
3
|
+
ref="buttonRef"
|
|
3
4
|
class="ev-button"
|
|
4
5
|
:class="{
|
|
5
6
|
disabled,
|
|
@@ -17,6 +18,8 @@
|
|
|
17
18
|
</template>
|
|
18
19
|
|
|
19
20
|
<script>
|
|
21
|
+
import { onMounted, ref } from 'vue';
|
|
22
|
+
|
|
20
23
|
export default {
|
|
21
24
|
name: 'EvButton',
|
|
22
25
|
props: {
|
|
@@ -52,6 +55,19 @@ export default {
|
|
|
52
55
|
emits: {
|
|
53
56
|
click: null,
|
|
54
57
|
},
|
|
58
|
+
setup(props) {
|
|
59
|
+
const buttonRef = ref(null);
|
|
60
|
+
|
|
61
|
+
onMounted(() => {
|
|
62
|
+
if (props.autoFocus) {
|
|
63
|
+
buttonRef.value.focus();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
buttonRef,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
55
71
|
};
|
|
56
72
|
</script>
|
|
57
73
|
|
|
@@ -16,6 +16,10 @@ import { onMounted, onBeforeUnmount, watch, onDeactivated } from 'vue';
|
|
|
16
16
|
export default {
|
|
17
17
|
name: 'EvChart',
|
|
18
18
|
props: {
|
|
19
|
+
selectedItem: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: null,
|
|
22
|
+
},
|
|
19
23
|
options: {
|
|
20
24
|
type: Object,
|
|
21
25
|
default: () => ({}),
|
|
@@ -33,6 +37,7 @@ import { onMounted, onBeforeUnmount, watch, onDeactivated } from 'vue';
|
|
|
33
37
|
'click',
|
|
34
38
|
'dbl-click',
|
|
35
39
|
'drag-select',
|
|
40
|
+
'update:selectedItem',
|
|
36
41
|
],
|
|
37
42
|
setup(props) {
|
|
38
43
|
let evChart = {};
|
|
@@ -40,6 +45,7 @@ import { onMounted, onBeforeUnmount, watch, onDeactivated } from 'vue';
|
|
|
40
45
|
|
|
41
46
|
const {
|
|
42
47
|
eventListeners,
|
|
48
|
+
selectInfo,
|
|
43
49
|
getNormalizedData,
|
|
44
50
|
getNormalizedOptions,
|
|
45
51
|
} = useModel();
|
|
@@ -60,6 +66,7 @@ import { onMounted, onBeforeUnmount, watch, onDeactivated } from 'vue';
|
|
|
60
66
|
normalizedData,
|
|
61
67
|
normalizedOptions,
|
|
62
68
|
eventListeners,
|
|
69
|
+
selectInfo,
|
|
63
70
|
);
|
|
64
71
|
};
|
|
65
72
|
|
|
@@ -93,6 +100,12 @@ import { onMounted, onBeforeUnmount, watch, onDeactivated } from 'vue';
|
|
|
93
100
|
updateSelTip: { update: true, keepDomain: false },
|
|
94
101
|
});
|
|
95
102
|
}, { deep: true });
|
|
103
|
+
|
|
104
|
+
await watch(() => props.selectedItem, (newValue) => {
|
|
105
|
+
if (newValue?.seriesID && !isNaN(newValue?.dataIndex)) {
|
|
106
|
+
evChart.selectItemByData(newValue);
|
|
107
|
+
}
|
|
108
|
+
}, { deep: true });
|
|
96
109
|
});
|
|
97
110
|
|
|
98
111
|
onBeforeUnmount(() => {
|
|
@@ -120,16 +133,11 @@ import { onMounted, onBeforeUnmount, watch, onDeactivated } from 'vue';
|
|
|
120
133
|
}
|
|
121
134
|
}, props.resizeTimeout);
|
|
122
135
|
|
|
123
|
-
const selectItemByLabel = (label) => {
|
|
124
|
-
evChart.selectItemByLabel(label);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
136
|
return {
|
|
128
137
|
wrapper,
|
|
129
138
|
wrapperStyle,
|
|
130
139
|
onResize,
|
|
131
140
|
redraw,
|
|
132
|
-
selectItemByLabel,
|
|
133
141
|
};
|
|
134
142
|
},
|
|
135
143
|
};
|
|
@@ -13,7 +13,7 @@ import Pie from './plugins/plugins.pie';
|
|
|
13
13
|
import Tip from './element/element.tip';
|
|
14
14
|
|
|
15
15
|
class EvChart {
|
|
16
|
-
constructor(target, data, options, listeners) {
|
|
16
|
+
constructor(target, data, options, listeners, defaultSelectInfo) {
|
|
17
17
|
Object.keys(Model).forEach(key => Object.assign(this, Model[key]));
|
|
18
18
|
Object.assign(this, Title);
|
|
19
19
|
Object.assign(this, Legend);
|
|
@@ -63,6 +63,8 @@ class EvChart {
|
|
|
63
63
|
charts: { pie: [], bar: [], line: [], scatter: [] },
|
|
64
64
|
count: 0,
|
|
65
65
|
};
|
|
66
|
+
|
|
67
|
+
this.defaultSelectInfo = defaultSelectInfo;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
/**
|
|
@@ -199,6 +201,26 @@ class EvChart {
|
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Draw Tip with hitInfo and defaultSelectInfo
|
|
206
|
+
* @param hitInfo
|
|
207
|
+
*/
|
|
208
|
+
drawTip(hitInfo) {
|
|
209
|
+
let tipLocationInfo;
|
|
210
|
+
|
|
211
|
+
if (hitInfo) {
|
|
212
|
+
tipLocationInfo = hitInfo;
|
|
213
|
+
} else if (this.lastHitInfo) {
|
|
214
|
+
tipLocationInfo = this.lastHitInfo;
|
|
215
|
+
} else if (this.defaultSelectInfo) {
|
|
216
|
+
tipLocationInfo = this.getItem(this.defaultSelectInfo, false);
|
|
217
|
+
} else {
|
|
218
|
+
tipLocationInfo = null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
this.drawTips(tipLocationInfo);
|
|
222
|
+
}
|
|
223
|
+
|
|
202
224
|
/**
|
|
203
225
|
* Create axes
|
|
204
226
|
* @param {string} dir axis direction
|
|
@@ -690,6 +712,8 @@ class EvChart {
|
|
|
690
712
|
this.overlayCanvas.removeEventListener('mouseleave', this.onMouseLeave);
|
|
691
713
|
this.overlayCanvas.removeEventListener('dblclick', this.onDblClick);
|
|
692
714
|
this.overlayCanvas.removeEventListener('click', this.onClick);
|
|
715
|
+
this.overlayCanvas.removeEventListener('mousedown', this.onMouseDown);
|
|
716
|
+
this.overlayCanvas.removeEventListener('wheel', this.onWheel);
|
|
693
717
|
}
|
|
694
718
|
|
|
695
719
|
if (this.options.tooltip.use) {
|
|
@@ -1,52 +1,74 @@
|
|
|
1
1
|
import { numberWithComma } from '@/common/utils';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
2
3
|
import Canvas from '../helpers/helpers.canvas';
|
|
3
4
|
|
|
4
5
|
const modules = {
|
|
5
6
|
/**
|
|
6
|
-
* Draw TextTip with
|
|
7
|
-
* @param {object} [
|
|
7
|
+
* Draw TextTip with tip's locationInfo
|
|
8
|
+
* @param {object} [tipLocationInfo=undefined] tip location information
|
|
8
9
|
*
|
|
9
10
|
* @returns {undefined}
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
drawTips(tipLocationInfo) {
|
|
12
13
|
const opt = this.options;
|
|
13
14
|
const isHorizontal = !!opt.horizontal;
|
|
14
15
|
const maxTipOpt = opt.maxTip;
|
|
15
|
-
const
|
|
16
|
+
const selTipOpt = opt.selectItem;
|
|
17
|
+
let maxArgs;
|
|
16
18
|
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
const selSID = (hitInfo && hitInfo.sId ? hitInfo.sId : this.lastHitInfo?.sId) ?? maxSID;
|
|
20
|
-
|
|
21
|
-
const maxArgs = this.calculateTipInfo(this.seriesList[maxSID], 'max', null);
|
|
22
|
-
const selArgs = this.calculateTipInfo(this.seriesList[selSID], 'sel', hitInfo);
|
|
23
|
-
|
|
24
|
-
if (maxTipOpt.use && maxArgs) {
|
|
25
|
-
this.drawTextTip({ opt: maxTipOpt, tipType: 'max', ...maxArgs });
|
|
19
|
+
if (selTipOpt.use && tipLocationInfo) {
|
|
20
|
+
const seriesInfo = this.seriesList[tipLocationInfo?.sId];
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
22
|
+
if (!seriesInfo?.show) {
|
|
23
|
+
return;
|
|
30
24
|
}
|
|
31
25
|
|
|
32
|
-
|
|
26
|
+
const selArgs = this.calculateTipInfo(
|
|
27
|
+
seriesInfo,
|
|
28
|
+
'sel',
|
|
29
|
+
tipLocationInfo,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (selArgs) {
|
|
33
33
|
let isSamePos = false;
|
|
34
34
|
|
|
35
|
-
if (maxTipOpt.use && maxArgs
|
|
35
|
+
if (maxTipOpt.use && maxArgs?.dp === selArgs.dp) {
|
|
36
36
|
isSamePos = true;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
if (
|
|
40
|
-
|
|
39
|
+
if (selTipOpt.showTextTip || selTipOpt.showTip) {
|
|
40
|
+
if (selTipOpt.tipText === 'label') {
|
|
41
|
+
const axisOpt = isHorizontal ? opt.axesY[0] : opt.axesX[0];
|
|
42
|
+
const label = selArgs.label;
|
|
43
|
+
selArgs.text = axisOpt.type === 'time' ? dayjs(label).format(axisOpt.timeFormat) : label;
|
|
44
|
+
} else {
|
|
45
|
+
selArgs.text = numberWithComma(selArgs.value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.drawTextTip({ opt: selTipOpt, tipType: 'sel', isSamePos, ...selArgs });
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
if (
|
|
44
|
-
this.drawFixedIndicator({ opt:
|
|
51
|
+
if (selTipOpt.showIndicator) {
|
|
52
|
+
this.drawFixedIndicator({ opt: selTipOpt, ...selArgs });
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
|
|
48
|
-
if (
|
|
49
|
-
this.lastHitInfo =
|
|
56
|
+
if (tipLocationInfo && tipLocationInfo.label !== null) {
|
|
57
|
+
this.lastHitInfo = tipLocationInfo;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (maxTipOpt.use) {
|
|
62
|
+
const maxSID = this.minMax[isHorizontal ? 'x' : 'y'][0].maxSID;
|
|
63
|
+
maxArgs = this.calculateTipInfo(this.seriesList[maxSID], 'max', null);
|
|
64
|
+
|
|
65
|
+
if (maxTipOpt.use && maxArgs) {
|
|
66
|
+
maxArgs.text = numberWithComma(maxArgs.value);
|
|
67
|
+
this.drawTextTip({ opt: maxTipOpt, tipType: 'max', ...maxArgs });
|
|
68
|
+
|
|
69
|
+
if (maxTipOpt.showIndicator) {
|
|
70
|
+
this.drawFixedIndicator({ opt: maxTipOpt, ...maxArgs });
|
|
71
|
+
}
|
|
50
72
|
}
|
|
51
73
|
}
|
|
52
74
|
},
|
|
@@ -104,19 +126,24 @@ const modules = {
|
|
|
104
126
|
}
|
|
105
127
|
|
|
106
128
|
let value = isHorizontal ? series.minMax.maxX : series.minMax.maxY;
|
|
107
|
-
|
|
129
|
+
let label;
|
|
108
130
|
if (tipType === 'sel') {
|
|
109
131
|
if (hitInfo && hitInfo.value !== null) {
|
|
110
132
|
value = hitInfo.useStack ? hitInfo.acc : hitInfo.value;
|
|
133
|
+
label = hitInfo.label;
|
|
111
134
|
lastTip.value = value;
|
|
135
|
+
lastTip.label = label;
|
|
112
136
|
} else if (lastTip.value !== null) {
|
|
113
137
|
value = lastTip.value;
|
|
138
|
+
label = lastTip.label;
|
|
114
139
|
} else if (lastTip.pos !== null) {
|
|
115
140
|
const item = type === 'bar'
|
|
116
141
|
? this.getItemByLabelIndex(lastTip.pos) : this.getItemByLabel(lastTip.pos);
|
|
117
142
|
|
|
118
143
|
value = item.useStack ? item.acc : item.value;
|
|
144
|
+
label = item.label;
|
|
119
145
|
lastTip.value = value;
|
|
146
|
+
lastTip.label = label;
|
|
120
147
|
}
|
|
121
148
|
}
|
|
122
149
|
|
|
@@ -145,7 +172,7 @@ const modules = {
|
|
|
145
172
|
}
|
|
146
173
|
|
|
147
174
|
const sizeObj = { xArea, yArea, graphX, graphY, xsp, xep, ysp };
|
|
148
|
-
const dataObj = { dp, value,
|
|
175
|
+
const dataObj = { dp, value, label, type };
|
|
149
176
|
|
|
150
177
|
return { ...sizeObj, ...dataObj };
|
|
151
178
|
},
|
|
@@ -387,43 +387,16 @@ const modules = {
|
|
|
387
387
|
},
|
|
388
388
|
|
|
389
389
|
/**
|
|
390
|
-
* Get graph
|
|
391
|
-
* @param {number}
|
|
392
|
-
*
|
|
393
|
-
* @returns {object} graph item
|
|
394
|
-
*/
|
|
395
|
-
getItemByLabelIndex(pos) {
|
|
396
|
-
if (pos < 0) {
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
return this.getItem(pos);
|
|
401
|
-
},
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Get graph item by label
|
|
405
|
-
* @param {any} label label value for searching graph item
|
|
390
|
+
* Get graph items for each series by label index
|
|
391
|
+
* @param {number} labelIndex label index
|
|
406
392
|
*
|
|
407
393
|
* @returns {object} graph item
|
|
408
394
|
*/
|
|
409
|
-
|
|
410
|
-
if (
|
|
395
|
+
getItemByLabelIndex(labelIndex) {
|
|
396
|
+
if (labelIndex < 0) {
|
|
411
397
|
return false;
|
|
412
398
|
}
|
|
413
399
|
|
|
414
|
-
const labels = this.data.labels;
|
|
415
|
-
const labelIndex = labels && labels.indexOf ? labels.indexOf(label) : -1;
|
|
416
|
-
|
|
417
|
-
return this.getItem(labelIndex);
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Get graph items for each series by label index
|
|
422
|
-
* @param {number} labelIndex label index
|
|
423
|
-
*
|
|
424
|
-
* @returns {object} graph item
|
|
425
|
-
*/
|
|
426
|
-
getItem(labelIndex) {
|
|
427
400
|
const sIds = Object.keys(this.seriesList);
|
|
428
401
|
const isHorizontal = !!this.options.horizontal;
|
|
429
402
|
|
|
@@ -479,6 +452,91 @@ const modules = {
|
|
|
479
452
|
return findInfo;
|
|
480
453
|
},
|
|
481
454
|
|
|
455
|
+
getItem({ seriesID, dataIndex }, useApproximate = false) {
|
|
456
|
+
const dataInfo = this.getDataByValues(seriesID, dataIndex);
|
|
457
|
+
return this.getItemByPosition([dataInfo.xp, dataInfo.yp], useApproximate);
|
|
458
|
+
},
|
|
459
|
+
/**
|
|
460
|
+
*
|
|
461
|
+
* @param seriesID
|
|
462
|
+
* @param dataIndex
|
|
463
|
+
* @returns {*}
|
|
464
|
+
*/
|
|
465
|
+
getDataByValues(seriesID, dataIndex) {
|
|
466
|
+
const series = this.seriesList[seriesID];
|
|
467
|
+
if (!series || isNaN(dataIndex) || dataIndex < 0 || series?.data.length <= dataIndex) {
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return series.data[dataIndex];
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Find graph item by position x and y
|
|
476
|
+
* @param {array} offset position x and y
|
|
477
|
+
* @param {boolean} useApproximate if it's true. it'll look for closed item on mouse position
|
|
478
|
+
*
|
|
479
|
+
* @returns {object} clicked item information
|
|
480
|
+
*/
|
|
481
|
+
getItemByPosition(offset, useApproximate = false) {
|
|
482
|
+
const sIds = Object.keys(this.seriesList);
|
|
483
|
+
const isHorizontal = !!this.options.horizontal;
|
|
484
|
+
|
|
485
|
+
let maxl = null;
|
|
486
|
+
let maxp = null;
|
|
487
|
+
let maxg = null;
|
|
488
|
+
let maxSID = '';
|
|
489
|
+
let acc = 0;
|
|
490
|
+
let useStack = false;
|
|
491
|
+
let maxIndex = null;
|
|
492
|
+
|
|
493
|
+
for (let ix = 0; ix < sIds.length; ix++) {
|
|
494
|
+
const sId = sIds[ix];
|
|
495
|
+
const series = this.seriesList[sId];
|
|
496
|
+
const findFn = useApproximate ? series.findApproximateData : series.findGraphData;
|
|
497
|
+
|
|
498
|
+
if (findFn) {
|
|
499
|
+
const item = findFn.call(series, offset, isHorizontal);
|
|
500
|
+
const data = item.data;
|
|
501
|
+
const index = item.index;
|
|
502
|
+
|
|
503
|
+
if (data) {
|
|
504
|
+
const ldata = isHorizontal ? data.y : data.x;
|
|
505
|
+
const lp = isHorizontal ? data.yp : data.xp;
|
|
506
|
+
|
|
507
|
+
if (ldata !== null && ldata !== undefined) {
|
|
508
|
+
const g = isHorizontal ? data.o || data.x : data.o || data.y;
|
|
509
|
+
|
|
510
|
+
if (series.stackIndex) {
|
|
511
|
+
acc += !isNaN(data.o) ? data.o : 0;
|
|
512
|
+
useStack = true;
|
|
513
|
+
} else {
|
|
514
|
+
acc += data.y;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (maxg === null || maxg <= g) {
|
|
518
|
+
maxg = g;
|
|
519
|
+
maxSID = sId;
|
|
520
|
+
maxl = ldata;
|
|
521
|
+
maxp = lp;
|
|
522
|
+
maxIndex = index;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return {
|
|
530
|
+
label: maxl,
|
|
531
|
+
pos: maxp,
|
|
532
|
+
value: maxg === null ? 0 : maxg,
|
|
533
|
+
sId: maxSID,
|
|
534
|
+
acc,
|
|
535
|
+
useStack,
|
|
536
|
+
maxIndex,
|
|
537
|
+
};
|
|
538
|
+
},
|
|
539
|
+
|
|
482
540
|
/**
|
|
483
541
|
* Create min/max information for all of data
|
|
484
542
|
* @property seriesList
|
|
@@ -101,7 +101,7 @@ const modules = {
|
|
|
101
101
|
|
|
102
102
|
if (selectItem.use) {
|
|
103
103
|
const offset = this.getMousePosition(e);
|
|
104
|
-
const hitInfo = this.
|
|
104
|
+
const hitInfo = this.getItemByPosition(offset, selectItem.useApproximateValue);
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
if (hitInfo.label !== null) {
|
|
@@ -125,13 +125,18 @@ const modules = {
|
|
|
125
125
|
const args = { e };
|
|
126
126
|
if (this.options.selectItem.use) {
|
|
127
127
|
const offset = this.getMousePosition(e);
|
|
128
|
-
const hitInfo = this.
|
|
128
|
+
const hitInfo = this.getItemByPosition(offset, false);
|
|
129
129
|
|
|
130
130
|
if (hitInfo.label !== null) {
|
|
131
131
|
this.render(hitInfo);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
({
|
|
134
|
+
({
|
|
135
|
+
label: args.label,
|
|
136
|
+
value: args.value,
|
|
137
|
+
sId: args.seriesId,
|
|
138
|
+
maxIndex: args.dataIndex,
|
|
139
|
+
} = hitInfo);
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
if (typeof this.listeners.click === 'function') {
|
|
@@ -155,15 +160,17 @@ const modules = {
|
|
|
155
160
|
}
|
|
156
161
|
};
|
|
157
162
|
|
|
158
|
-
|
|
159
|
-
this.
|
|
160
|
-
const isTooltipVisible = this.tooltipDOM.style.display === 'block';
|
|
163
|
+
this.onWheel = (e) => {
|
|
164
|
+
const isTooltipVisible = this.tooltipDOM.style.display === 'block';
|
|
161
165
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
if (isTooltipVisible) {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
this.tooltipBodyDOM.scrollTop += e.deltaY;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
if (this.options?.tooltip?.useScrollbar) {
|
|
173
|
+
this.overlayCanvas.addEventListener('wheel', this.onWheel, { passive: false });
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
this.overlayCanvas.addEventListener('mousemove', this.onMouseMove);
|
|
@@ -398,130 +405,22 @@ const modules = {
|
|
|
398
405
|
},
|
|
399
406
|
|
|
400
407
|
/**
|
|
401
|
-
* Find clicked graph item on mouse position
|
|
402
|
-
* @param {array} offset return value from getMousePosition()
|
|
403
|
-
* @param {boolean} useApproximate if it's true. it'll look for closed item on mouse position
|
|
404
|
-
*
|
|
405
|
-
* @returns {object} clicked item information
|
|
406
|
-
*/
|
|
407
|
-
findClickedData(offset, useApproximate) {
|
|
408
|
-
const sIds = Object.keys(this.seriesList);
|
|
409
|
-
const isHorizontal = !!this.options.horizontal;
|
|
410
|
-
|
|
411
|
-
let maxl = null;
|
|
412
|
-
let maxp = null;
|
|
413
|
-
let maxg = null;
|
|
414
|
-
let maxSID = '';
|
|
415
|
-
let acc = 0;
|
|
416
|
-
let useStack = false;
|
|
417
|
-
let maxIndex = null;
|
|
418
|
-
|
|
419
|
-
for (let ix = 0; ix < sIds.length; ix++) {
|
|
420
|
-
const sId = sIds[ix];
|
|
421
|
-
const series = this.seriesList[sId];
|
|
422
|
-
const findFn = useApproximate ? series.findApproximateData : series.findGraphData;
|
|
423
|
-
|
|
424
|
-
if (findFn) {
|
|
425
|
-
const item = findFn.call(series, offset, isHorizontal);
|
|
426
|
-
const data = item.data;
|
|
427
|
-
const index = item.index;
|
|
428
|
-
|
|
429
|
-
if (data) {
|
|
430
|
-
const ldata = isHorizontal ? data.y : data.x;
|
|
431
|
-
const lp = isHorizontal ? data.yp : data.xp;
|
|
432
|
-
|
|
433
|
-
if (ldata !== null && ldata !== undefined) {
|
|
434
|
-
const g = isHorizontal ? data.o || data.x : data.o || data.y;
|
|
435
|
-
|
|
436
|
-
if (series.stackIndex) {
|
|
437
|
-
acc += !isNaN(data.o) ? data.o : 0;
|
|
438
|
-
useStack = true;
|
|
439
|
-
} else {
|
|
440
|
-
acc += data.y;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (maxg === null || maxg <= g) {
|
|
444
|
-
maxg = g;
|
|
445
|
-
maxSID = sId;
|
|
446
|
-
maxl = ldata;
|
|
447
|
-
maxp = lp;
|
|
448
|
-
maxIndex = index;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
return {
|
|
456
|
-
label: maxl,
|
|
457
|
-
pos: maxp,
|
|
458
|
-
value: maxg === null ? 0 : maxg,
|
|
459
|
-
sId: maxSID,
|
|
460
|
-
acc,
|
|
461
|
-
useStack,
|
|
462
|
-
maxIndex,
|
|
463
|
-
};
|
|
464
|
-
},
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Find graph item by label entered from user
|
|
468
|
-
* @param {any} label label value
|
|
469
408
|
*
|
|
470
|
-
* @
|
|
409
|
+
* @param targetInfo
|
|
410
|
+
* @returns {boolean}
|
|
471
411
|
*/
|
|
472
|
-
|
|
473
|
-
|
|
412
|
+
selectItemByData(targetInfo) {
|
|
413
|
+
this.defaultSelectInfo = targetInfo;
|
|
414
|
+
const foundInfo = this.getItem(targetInfo, false);
|
|
474
415
|
|
|
475
|
-
if (
|
|
476
|
-
this.render(
|
|
416
|
+
if (foundInfo) {
|
|
417
|
+
this.render(foundInfo);
|
|
477
418
|
} else {
|
|
478
419
|
return false;
|
|
479
420
|
}
|
|
480
421
|
|
|
481
422
|
return true;
|
|
482
423
|
},
|
|
483
|
-
findHitItem2(offset) {
|
|
484
|
-
const mouseX = offset[0];
|
|
485
|
-
const mouseY = offset[1];
|
|
486
|
-
|
|
487
|
-
const width = this.chartRect.chartWidth;
|
|
488
|
-
const height = this.chartRect.chartHeight;
|
|
489
|
-
const centerX = (width / 2) + this.chartRect.padding.left;
|
|
490
|
-
const centerY = (height / 2) + this.chartRect.padding.top;
|
|
491
|
-
|
|
492
|
-
const dx = mouseX - centerX;
|
|
493
|
-
const dy = mouseY - centerY;
|
|
494
|
-
|
|
495
|
-
let angle;
|
|
496
|
-
angle = ((Math.atan2(-dy, -dx) * 180) / Math.PI) - 90;
|
|
497
|
-
angle = angle < 0 ? 360 + angle : angle;
|
|
498
|
-
const rad = ((angle * Math.PI) / 180) + (1.5 * Math.PI);
|
|
499
|
-
const distance = Math.round(Math.sqrt((dx ** 2) + (dy ** 2)));
|
|
500
|
-
|
|
501
|
-
const graphData = this.graphData;
|
|
502
|
-
let gdata;
|
|
503
|
-
let dsIndex = null;
|
|
504
|
-
let sId = null;
|
|
505
|
-
|
|
506
|
-
for (let ix = 0, ixLen = graphData.length; ix < ixLen; ix++) {
|
|
507
|
-
gdata = graphData[ix];
|
|
508
|
-
if (distance > gdata.ir && distance < gdata.or) {
|
|
509
|
-
dsIndex = ix;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
if (graphData[dsIndex]) {
|
|
514
|
-
for (let ix = 0, ixLen = graphData[dsIndex].data.length; ix < ixLen; ix++) {
|
|
515
|
-
gdata = graphData[dsIndex].data[ix];
|
|
516
|
-
|
|
517
|
-
if (rad > gdata.sa && rad < gdata.ea) {
|
|
518
|
-
sId = gdata.id;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
return { dsIndex, sId };
|
|
524
|
-
},
|
|
525
424
|
|
|
526
425
|
/**
|
|
527
426
|
* Find items by series within a range
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, computed, getCurrentInstance, nextTick } from 'vue';
|
|
2
|
-
import { defaultsDeep } from 'lodash-es';
|
|
2
|
+
import { cloneDeep, defaultsDeep } from 'lodash-es';
|
|
3
3
|
import { getQuantity } from '@/common/utils';
|
|
4
4
|
|
|
5
5
|
const DEFAULT_OPTIONS = {
|
|
@@ -73,6 +73,7 @@ const DEFAULT_OPTIONS = {
|
|
|
73
73
|
selectItem: {
|
|
74
74
|
use: false,
|
|
75
75
|
showTextTip: false,
|
|
76
|
+
tipText: 'value',
|
|
76
77
|
showTip: false,
|
|
77
78
|
showIndicator: false,
|
|
78
79
|
fixedPosTop: false,
|
|
@@ -97,7 +98,7 @@ const DEFAULT_DATA = {
|
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
export const useModel = () => {
|
|
100
|
-
const { emit } = getCurrentInstance();
|
|
101
|
+
const { props, emit } = getCurrentInstance();
|
|
101
102
|
|
|
102
103
|
const getNormalizedOptions = (options) => {
|
|
103
104
|
const normalizedOptions = defaultsDeep({}, options, DEFAULT_OPTIONS);
|
|
@@ -110,9 +111,14 @@ export const useModel = () => {
|
|
|
110
111
|
};
|
|
111
112
|
const getNormalizedData = data => defaultsDeep(data, DEFAULT_DATA);
|
|
112
113
|
|
|
114
|
+
const selectInfo = cloneDeep(props.selectedItem);
|
|
115
|
+
|
|
113
116
|
const eventListeners = {
|
|
114
117
|
click: async (e) => {
|
|
115
118
|
await nextTick();
|
|
119
|
+
if (e.label) {
|
|
120
|
+
emit('update:selectedItem', { seriesID: e.seriesId, dataIndex: e.dataIndex });
|
|
121
|
+
}
|
|
116
122
|
emit('click', e);
|
|
117
123
|
},
|
|
118
124
|
'dbl-click': async (e) => {
|
|
@@ -127,6 +133,7 @@ export const useModel = () => {
|
|
|
127
133
|
|
|
128
134
|
return {
|
|
129
135
|
eventListeners,
|
|
136
|
+
selectInfo,
|
|
130
137
|
getNormalizedData,
|
|
131
138
|
getNormalizedOptions,
|
|
132
139
|
};
|
|
@@ -471,7 +471,7 @@ export default {
|
|
|
471
471
|
setStore(props.rows);
|
|
472
472
|
});
|
|
473
473
|
onActivated(() => {
|
|
474
|
-
|
|
474
|
+
onResize();
|
|
475
475
|
});
|
|
476
476
|
const ROW_INDEX = 0;
|
|
477
477
|
const ROW_CHECK_INDEX = 1;
|
|
@@ -584,7 +584,10 @@ export default {
|
|
|
584
584
|
watch(
|
|
585
585
|
() => filterInfo.searchValue,
|
|
586
586
|
(value) => {
|
|
587
|
-
|
|
587
|
+
const searchValue = value?.value ?? value;
|
|
588
|
+
if (searchValue) {
|
|
589
|
+
onSearch(searchValue);
|
|
590
|
+
}
|
|
588
591
|
}, { immediate: true },
|
|
589
592
|
);
|
|
590
593
|
const isFilterButton = field => filterInfo.isFiltering && field !== 'db-icon' && field !== 'user-icon';
|