evui 3.3.39 → 3.3.41
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 +2477 -197
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +2477 -197
- 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 +95 -5
- package/src/components/chart/ChartToolbar.vue +52 -0
- package/src/components/chart/chart.core.js +71 -27
- package/src/components/chart/chartZoom.core.js +479 -0
- package/src/components/chart/element/element.line.js +2 -1
- package/src/components/chart/element/element.scatter.js +8 -2
- package/src/components/chart/element/element.tip.js +41 -33
- package/src/components/chart/model/model.store.js +34 -5
- package/src/components/chart/plugins/plugins.interaction.js +28 -4
- package/src/components/chart/plugins/plugins.legend.js +11 -1
- package/src/components/chart/plugins/plugins.title.js +13 -8
- package/src/components/chart/scale/scale.js +8 -3
- package/src/components/chart/style/chart.scss +14 -0
- package/src/components/chart/uses.js +329 -6
- package/src/components/chartBrush/ChartBrush.vue +298 -0
- package/src/components/chartBrush/chartBrush.core.js +458 -0
- package/src/components/chartBrush/index.js +9 -0
- package/src/components/chartBrush/uses.js +22 -0
- package/src/components/chartGroup/ChartGroup.vue +125 -0
- package/src/components/chartGroup/index.js +9 -0
- package/src/components/chartGroup/style/chartGroup.scss +5 -0
- package/src/components/chartGroup/uses.js +48 -0
- package/src/components/pagination/pageButton.vue +1 -0
- package/src/main.js +4 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-if="evChartBrushOptions.show"
|
|
4
|
+
ref="evChartBrushRef"
|
|
5
|
+
v-resize="onResize"
|
|
6
|
+
:style="evChartBrushStyle"
|
|
7
|
+
class="ev-chart-brush"
|
|
8
|
+
/>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import { inject, watch, computed, onMounted, onBeforeUnmount, onDeactivated, onUpdated } from 'vue';
|
|
13
|
+
import { cloneDeep, debounce, isEqual } from 'lodash-es';
|
|
14
|
+
import EvChart from '../chart/chart.core';
|
|
15
|
+
import { useModel, useWrapper } from '../chart/uses';
|
|
16
|
+
import EvChartBrush from './chartBrush.core';
|
|
17
|
+
import { useBrushModel } from './uses';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: 'EvChartBrush',
|
|
21
|
+
props: {
|
|
22
|
+
options: {
|
|
23
|
+
type: Object,
|
|
24
|
+
default: () => ({}),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
setup(props) {
|
|
28
|
+
let evChart = null;
|
|
29
|
+
let evChartBrush = null;
|
|
30
|
+
|
|
31
|
+
const injectEvChartClone = inject('evChartClone', { data: [] });
|
|
32
|
+
const injectEvChartInfo = inject('evChartInfo', { props: { options: [] } });
|
|
33
|
+
const injectBrushIdx = inject('brushIdx', {
|
|
34
|
+
start: 0,
|
|
35
|
+
end: -1,
|
|
36
|
+
isUseButton: false,
|
|
37
|
+
isUseScroll: false,
|
|
38
|
+
});
|
|
39
|
+
const injectBrushSeries = inject('brushSeries', { list: [], chartIdx: null });
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
getNormalizedBrushOptions,
|
|
43
|
+
} = useBrushModel();
|
|
44
|
+
|
|
45
|
+
const evChartBrushOptions = computed(() => getNormalizedBrushOptions(props.options));
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
eventListeners,
|
|
49
|
+
selectItemInfo,
|
|
50
|
+
selectLabelInfo,
|
|
51
|
+
selectSeriesInfo,
|
|
52
|
+
getNormalizedData,
|
|
53
|
+
getNormalizedOptions,
|
|
54
|
+
} = useModel();
|
|
55
|
+
|
|
56
|
+
const evChartData = computed(() => getNormalizedData(
|
|
57
|
+
(injectEvChartClone.data ?? [])[evChartBrushOptions.value.chartIdx]),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const evChartOption = computed(() => {
|
|
61
|
+
const chartOption = injectEvChartInfo.props.options[evChartBrushOptions.value.chartIdx];
|
|
62
|
+
|
|
63
|
+
const option = {
|
|
64
|
+
...chartOption,
|
|
65
|
+
brush: {
|
|
66
|
+
use: true,
|
|
67
|
+
...evChartBrushOptions.value,
|
|
68
|
+
},
|
|
69
|
+
height: evChartBrushOptions.value.height,
|
|
70
|
+
zoom: {
|
|
71
|
+
use: false,
|
|
72
|
+
},
|
|
73
|
+
dragSelection: {
|
|
74
|
+
use: false,
|
|
75
|
+
},
|
|
76
|
+
title: {
|
|
77
|
+
show: false,
|
|
78
|
+
},
|
|
79
|
+
tooltip: {
|
|
80
|
+
use: false,
|
|
81
|
+
},
|
|
82
|
+
legend: {
|
|
83
|
+
show: false,
|
|
84
|
+
},
|
|
85
|
+
selectLabel: {
|
|
86
|
+
use: false,
|
|
87
|
+
},
|
|
88
|
+
selectSeries: {
|
|
89
|
+
use: false,
|
|
90
|
+
},
|
|
91
|
+
axesX: [{
|
|
92
|
+
...chartOption?.axesX?.[0],
|
|
93
|
+
title: {
|
|
94
|
+
use: false,
|
|
95
|
+
},
|
|
96
|
+
}],
|
|
97
|
+
axesY: [{
|
|
98
|
+
...chartOption?.axesY?.[0],
|
|
99
|
+
title: {
|
|
100
|
+
use: false,
|
|
101
|
+
},
|
|
102
|
+
}],
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return getNormalizedOptions(option);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const {
|
|
109
|
+
wrapper: evChartBrushRef,
|
|
110
|
+
wrapperStyle: evChartBrushStyle,
|
|
111
|
+
} = useWrapper(
|
|
112
|
+
evChartOption.value,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
watch(() => injectBrushSeries.list, () => {
|
|
116
|
+
if (
|
|
117
|
+
evChartBrushRef.value
|
|
118
|
+
&& injectBrushSeries.chartIdx === evChartBrushOptions.value.chartIdx
|
|
119
|
+
) {
|
|
120
|
+
evChart.seriesList = injectBrushSeries.list[evChartBrushOptions.value.chartIdx];
|
|
121
|
+
|
|
122
|
+
evChart.update({
|
|
123
|
+
updateSeries: false,
|
|
124
|
+
updateSelTip: { update: false, keepDomain: false },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
watch(evChartOption, (newOpt, prevOpt) => {
|
|
130
|
+
if (newOpt.brush.chartIdx <= injectEvChartClone.data?.length - 1) {
|
|
131
|
+
if (evChartBrush && !isEqual(prevOpt.brush, newOpt.brush)) {
|
|
132
|
+
evChartBrush.removeBrushWrapper();
|
|
133
|
+
} else if (evChart && !isEqual(newOpt, prevOpt)) {
|
|
134
|
+
evChart.options = cloneDeep(newOpt);
|
|
135
|
+
|
|
136
|
+
evChart.update({
|
|
137
|
+
updateSeries: false,
|
|
138
|
+
updateSelTip: { update: false, keepDomain: false },
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
evChart.data = cloneDeep(evChartData.value);
|
|
143
|
+
|
|
144
|
+
evChart.update({
|
|
145
|
+
updateSeries: true,
|
|
146
|
+
updateSelTip: { update: false, keepDomain: false },
|
|
147
|
+
updateData: false,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
evChartBrush.removeBrushCanvas();
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
watch(() => injectEvChartClone.data, (newData) => {
|
|
155
|
+
if (evChart) {
|
|
156
|
+
const data = newData[evChartBrushOptions.value.chartIdx];
|
|
157
|
+
|
|
158
|
+
if (data) {
|
|
159
|
+
const isUpdateSeries = !isEqual(data.series, evChart.data.series);
|
|
160
|
+
|
|
161
|
+
const seriesList = injectBrushSeries.list[evChartBrushOptions.value.chartIdx];
|
|
162
|
+
|
|
163
|
+
if (seriesList) {
|
|
164
|
+
Object.keys(data.series).forEach((series) => {
|
|
165
|
+
data.series[series].show = seriesList[series].show;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
evChart.data = cloneDeep(data);
|
|
170
|
+
|
|
171
|
+
evChart.update({
|
|
172
|
+
updateSeries: isUpdateSeries,
|
|
173
|
+
updateSelTip: { update: false, keepDomain: false },
|
|
174
|
+
updateData: false,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const createChart = () => {
|
|
181
|
+
let selected;
|
|
182
|
+
if (evChartOption.value.selectLabel.use) {
|
|
183
|
+
selected = selectLabelInfo;
|
|
184
|
+
} else if (evChartOption.value.selectSeries.use) {
|
|
185
|
+
selected = selectSeriesInfo;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
evChart = new EvChart(
|
|
189
|
+
evChartBrushRef.value,
|
|
190
|
+
evChartData.value,
|
|
191
|
+
evChartOption.value,
|
|
192
|
+
eventListeners,
|
|
193
|
+
selectItemInfo,
|
|
194
|
+
selected,
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const createChartBrush = () => {
|
|
199
|
+
evChartBrush = new EvChartBrush(
|
|
200
|
+
evChart,
|
|
201
|
+
evChartData,
|
|
202
|
+
evChartBrushOptions,
|
|
203
|
+
injectBrushIdx,
|
|
204
|
+
evChartBrushRef,
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const drawChart = () => {
|
|
209
|
+
if (evChart) {
|
|
210
|
+
evChart.init();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const drawChartBrush = (isResize) => {
|
|
215
|
+
if (evChartBrush) {
|
|
216
|
+
evChartBrush.init(isResize);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
watch(() => [injectBrushIdx.start, injectBrushIdx.end], () => {
|
|
221
|
+
if (
|
|
222
|
+
evChartBrushRef.value
|
|
223
|
+
&& evChartBrushOptions.value.chartIdx <= injectEvChartClone.data?.length - 1
|
|
224
|
+
) {
|
|
225
|
+
drawChartBrush();
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
onMounted(async () => {
|
|
230
|
+
if (evChartBrushOptions.value.show) {
|
|
231
|
+
await createChart();
|
|
232
|
+
await drawChart();
|
|
233
|
+
createChartBrush();
|
|
234
|
+
drawChartBrush();
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
onUpdated(async () => {
|
|
239
|
+
if (evChartBrushOptions.value.show) {
|
|
240
|
+
if (evChartBrushOptions.value.chartIdx <= injectEvChartClone.data?.length - 1) {
|
|
241
|
+
const seriesList = injectBrushSeries.list[evChartBrushOptions.value.chartIdx];
|
|
242
|
+
|
|
243
|
+
if (seriesList) {
|
|
244
|
+
Object.keys(evChartData.value.series).forEach((series) => {
|
|
245
|
+
evChartData.value.series[series].show = seriesList[series].show;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
await createChart();
|
|
250
|
+
await drawChart();
|
|
251
|
+
createChartBrush();
|
|
252
|
+
drawChartBrush();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
onBeforeUnmount(() => {
|
|
258
|
+
if (evChart && 'destroy' in evChart) {
|
|
259
|
+
evChart.destroy();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (evChartBrush) {
|
|
263
|
+
evChartBrush.destroy();
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
onDeactivated(() => {
|
|
268
|
+
if (evChart && 'hideTooltip' in evChart) {
|
|
269
|
+
evChart.hideTooltip();
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @param {boolean} isResizeDone resizing complete status
|
|
275
|
+
*
|
|
276
|
+
* @returns {undefined}
|
|
277
|
+
*/
|
|
278
|
+
const onResize = debounce(() => {
|
|
279
|
+
if (evChart && 'resize' in evChart) {
|
|
280
|
+
const resize = new Promise(resolve => evChart.resize(resolve));
|
|
281
|
+
|
|
282
|
+
resize.then((isResizeDone) => {
|
|
283
|
+
if (isResizeDone) {
|
|
284
|
+
drawChartBrush(isResizeDone);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}, 0);
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
evChartBrushOptions,
|
|
292
|
+
evChartBrushRef,
|
|
293
|
+
evChartBrushStyle,
|
|
294
|
+
onResize,
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
</script>
|