evui 3.3.39 → 3.3.40
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 +2445 -188
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +2445 -188
- 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 +69 -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/scale/scale.js +8 -3
- package/src/components/chart/style/chart.scss +14 -0
- package/src/components/chart/uses.js +319 -5
- package/src/components/chartBrush/ChartBrush.vue +298 -0
- package/src/components/chartBrush/chartBrush.core.js +453 -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,453 @@
|
|
|
1
|
+
import { throttle, debounce } from 'lodash-es';
|
|
2
|
+
|
|
3
|
+
export default class EvChartBrush {
|
|
4
|
+
constructor(evChart, evChartData, evChartBrushOptions, brushIdx, evChartBrushRef) {
|
|
5
|
+
this.evChart = evChart;
|
|
6
|
+
this.evChartData = evChartData;
|
|
7
|
+
this.evChartBrushOptions = evChartBrushOptions;
|
|
8
|
+
this.evChartBrushRef = evChartBrushRef;
|
|
9
|
+
|
|
10
|
+
this.brushIdx = brushIdx;
|
|
11
|
+
if (evChartBrushOptions.value.useDebounce) {
|
|
12
|
+
this.debounceBrushIdx = { start: brushIdx.start, end: brushIdx.end };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
init(isResize) {
|
|
17
|
+
if (this.brushIdx.start > this.brushIdx.end) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const existedBrushCanvas = this.evChartBrushRef.value.querySelector('.brush-canvas');
|
|
22
|
+
|
|
23
|
+
if (!existedBrushCanvas) {
|
|
24
|
+
const brushCanvas = document.createElement('canvas');
|
|
25
|
+
|
|
26
|
+
brushCanvas.setAttribute('class', 'brush-canvas');
|
|
27
|
+
brushCanvas.setAttribute('style', 'display: block; z-index: 1;');
|
|
28
|
+
|
|
29
|
+
const evChartBrushContainer = this.evChartBrushRef.value.querySelector('.ev-chart-brush-container');
|
|
30
|
+
|
|
31
|
+
if (evChartBrushContainer) {
|
|
32
|
+
this.brushCanvas = brushCanvas;
|
|
33
|
+
evChartBrushContainer.appendChild(brushCanvas);
|
|
34
|
+
this.evChartBrushContainer = evChartBrushContainer;
|
|
35
|
+
|
|
36
|
+
this.drawBrushRect({ brushCanvas });
|
|
37
|
+
this.addEvent(brushCanvas);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
this.drawBrushRect({ brushCanvas: existedBrushCanvas, isResize });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
drawBrushRect({ brushCanvas, isResize, isDebounce }) {
|
|
45
|
+
const { chartRect, labelOffset } = this.evChart;
|
|
46
|
+
if (!chartRect && !labelOffset) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const evChartRange = {
|
|
51
|
+
x1: chartRect.x1 + labelOffset.left,
|
|
52
|
+
x2: chartRect.x2 - labelOffset.right,
|
|
53
|
+
y1: chartRect.y1 + labelOffset.top,
|
|
54
|
+
y2: chartRect.y2 - labelOffset.bottom,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const pixelRatio = window.devicePixelRatio || 1;
|
|
58
|
+
const brushButtonWidth = 6;
|
|
59
|
+
const brushCanvasWidth = evChartRange.x2 - evChartRange.x1 + brushButtonWidth;
|
|
60
|
+
const brushCanvasHeight = evChartRange.y2 - evChartRange.y1;
|
|
61
|
+
|
|
62
|
+
const isEqualWidth = brushCanvas.width === Math.floor(brushCanvasWidth * pixelRatio);
|
|
63
|
+
|
|
64
|
+
if (isResize && isEqualWidth) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!isDebounce && this.debounceBrushIdx) {
|
|
69
|
+
this.debounceBrushIdx.start = this.brushIdx.start;
|
|
70
|
+
this.debounceBrushIdx.end = this.brushIdx.end;
|
|
71
|
+
}
|
|
72
|
+
const brushIdx = this.debounceBrushIdx ?? this.brushIdx;
|
|
73
|
+
|
|
74
|
+
const labelEndIdx = this.evChartData.value.labels.length - 1;
|
|
75
|
+
this.labelEndIdx = labelEndIdx;
|
|
76
|
+
const axesXInterval = (evChartRange.x2 - evChartRange.x1) / labelEndIdx;
|
|
77
|
+
const brushRectX = brushIdx.start * axesXInterval * pixelRatio;
|
|
78
|
+
const brushRectWidth = (
|
|
79
|
+
brushCanvasWidth - (
|
|
80
|
+
labelEndIdx - (brushIdx.end - brushIdx.start)
|
|
81
|
+
) * axesXInterval
|
|
82
|
+
) * pixelRatio;
|
|
83
|
+
const brushRectHeight = this.evChartBrushOptions.value.height - evChartRange.y1;
|
|
84
|
+
const brushButtonLeftXPos = brushRectX;
|
|
85
|
+
const brushButtonRightXPos = brushRectX + brushRectWidth;
|
|
86
|
+
|
|
87
|
+
if (!brushCanvas.style.position) {
|
|
88
|
+
brushCanvas.style.position = 'absolute';
|
|
89
|
+
brushCanvas.style.top = `${evChartRange.y1}px`;
|
|
90
|
+
brushCanvas.style.left = `${evChartRange.x1 - (brushButtonWidth / 2)}px`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!isEqualWidth) {
|
|
94
|
+
brushCanvas.width = (brushCanvasWidth * pixelRatio);
|
|
95
|
+
brushCanvas.style.width = `${brushCanvasWidth}px`;
|
|
96
|
+
brushCanvas.height = brushCanvasHeight * pixelRatio;
|
|
97
|
+
brushCanvas.style.height = `${brushCanvasHeight}px`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const ctx = brushCanvas.getContext('2d');
|
|
101
|
+
|
|
102
|
+
ctx.clearRect(
|
|
103
|
+
0,
|
|
104
|
+
0,
|
|
105
|
+
brushCanvasWidth * pixelRatio,
|
|
106
|
+
brushCanvasHeight * pixelRatio,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
ctx.fillStyle = this.evChartBrushOptions.value.selection.fillColor;
|
|
110
|
+
ctx.globalAlpha = this.evChartBrushOptions.value.selection.opacity;
|
|
111
|
+
ctx.fillRect(brushRectX, 0, brushRectWidth, brushRectHeight);
|
|
112
|
+
ctx.fillRect(brushButtonLeftXPos, 0, brushButtonWidth, brushRectHeight);
|
|
113
|
+
ctx.fillRect(brushButtonRightXPos - brushButtonWidth, 0, brushButtonWidth, brushRectHeight);
|
|
114
|
+
|
|
115
|
+
this.evChartBrushPos = {
|
|
116
|
+
leftX: brushButtonLeftXPos / pixelRatio,
|
|
117
|
+
rightX: brushButtonRightXPos / pixelRatio,
|
|
118
|
+
buttonWidth: brushButtonWidth,
|
|
119
|
+
axesXInterval,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
addEvent() {
|
|
124
|
+
let mousePosition;
|
|
125
|
+
|
|
126
|
+
this.onMouseDown = (e) => {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
|
|
129
|
+
if (mousePosition.isInsideButton) {
|
|
130
|
+
this.clickBrushInsideX = -1;
|
|
131
|
+
} else if (mousePosition.isInsideBrush) {
|
|
132
|
+
this.clickBrushInsideX = e.offsetX;
|
|
133
|
+
} else if (mousePosition.isOutsideBrush) {
|
|
134
|
+
this.teleportBrush(e);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const onMouseMove = (e) => {
|
|
139
|
+
if (this.clickBrushInsideX) {
|
|
140
|
+
this.mouseDownAndMove(e);
|
|
141
|
+
} else {
|
|
142
|
+
mousePosition = this.getMousePosition(e);
|
|
143
|
+
|
|
144
|
+
this.changeCursor(mousePosition);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
this.onMouseMove = throttle(onMouseMove, 5);
|
|
148
|
+
|
|
149
|
+
this.onWheel = (e) => {
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
|
|
152
|
+
this.updateBrushIdx(e.deltaY > 0 ? 'movedown' : 'moveup');
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
this.onMouseUp = () => {
|
|
156
|
+
this.initEventState();
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
this.onMouseLeave = () => {
|
|
160
|
+
if (this.clickBrushInsideX) {
|
|
161
|
+
this.initEventState();
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const onWheelDebounce = () => {
|
|
166
|
+
this.initEventState();
|
|
167
|
+
};
|
|
168
|
+
this.onWheelDebounce = debounce(onWheelDebounce, 100);
|
|
169
|
+
|
|
170
|
+
this.setEventListener('addEventListener');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
getMousePosition(e) {
|
|
174
|
+
const calDisToCurMouseX = xPos => Math.abs(this.evChartBrushPos[xPos] - e.offsetX);
|
|
175
|
+
const buttonType = calDisToCurMouseX('rightX') > calDisToCurMouseX('leftX') ? 'leftX' : 'rightX';
|
|
176
|
+
|
|
177
|
+
this.curBrushButtonType = buttonType;
|
|
178
|
+
|
|
179
|
+
const isMoveRight = xPos => e.offsetX > this.evChartBrushPos[xPos];
|
|
180
|
+
const isMoveLeft = xPos => e.offsetX < this.evChartBrushPos[xPos];
|
|
181
|
+
|
|
182
|
+
const isOutsideBrush = isMoveLeft('leftX') || isMoveRight('rightX');
|
|
183
|
+
const isInsideBrush = isMoveRight('leftX') && isMoveLeft('rightX');
|
|
184
|
+
|
|
185
|
+
const isInsideButton = e.offsetX + this.evChartBrushPos.buttonWidth
|
|
186
|
+
>= this.evChartBrushPos[buttonType]
|
|
187
|
+
&& e.offsetX - this.evChartBrushPos.buttonWidth
|
|
188
|
+
<= this.evChartBrushPos[buttonType];
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
isInsideButton,
|
|
192
|
+
isInsideBrush,
|
|
193
|
+
isOutsideBrush,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
destroy() {
|
|
198
|
+
if (this.brushCanvas) {
|
|
199
|
+
this.setEventListener('removeEventListener');
|
|
200
|
+
|
|
201
|
+
this.brushCanvas = null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const evChartBrushContainer = this.evChartBrushContainer;
|
|
205
|
+
while (evChartBrushContainer.hasChildNodes()) {
|
|
206
|
+
evChartBrushContainer.removeChild(evChartBrushContainer.firstChild);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @param {string} type eventListener setting type.
|
|
212
|
+
*
|
|
213
|
+
* @returns {undefined}
|
|
214
|
+
*/
|
|
215
|
+
setEventListener(type) {
|
|
216
|
+
this.brushCanvas[type]('mousemove', this.onMouseMove);
|
|
217
|
+
this.brushCanvas[type]('mousedown', this.onMouseDown);
|
|
218
|
+
this.brushCanvas[type]('mouseup', this.onMouseUp);
|
|
219
|
+
this.brushCanvas[type]('mouseleave', this.onMouseLeave);
|
|
220
|
+
this.brushCanvas[type]('wheel', this.onWheel);
|
|
221
|
+
this.brushCanvas[type]('wheel', this.onWheelDebounce);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
removeBrushWrapper() {
|
|
225
|
+
if (this.evChartBrushRef.value) {
|
|
226
|
+
const evChartBrushWrapper = this.evChartBrushRef.value.querySelector('.ev-chart-brush-wrapper');
|
|
227
|
+
|
|
228
|
+
if (evChartBrushWrapper) {
|
|
229
|
+
this.evChartBrushRef.value.removeChild(evChartBrushWrapper);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
removeBrushCanvas() {
|
|
235
|
+
if (this.evChartBrushContainer) {
|
|
236
|
+
const brushCanvas = this.evChartBrushContainer.querySelector('.brush-canvas');
|
|
237
|
+
|
|
238
|
+
if (brushCanvas) {
|
|
239
|
+
this.evChartBrushContainer.removeChild(brushCanvas);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
teleportBrush(e) {
|
|
245
|
+
const brushIdx = this.debounceBrushIdx ?? this.brushIdx;
|
|
246
|
+
|
|
247
|
+
const middle = (brushIdx.end - brushIdx.start) / 2;
|
|
248
|
+
let left;
|
|
249
|
+
let right;
|
|
250
|
+
let clickIdx;
|
|
251
|
+
|
|
252
|
+
if (middle > 0.5) {
|
|
253
|
+
if ((brushIdx.end - brushIdx.start) % 2 === 0) {
|
|
254
|
+
clickIdx = Math.round(e.offsetX / this.evChartBrushPos.axesXInterval);
|
|
255
|
+
|
|
256
|
+
left = Math.ceil(middle);
|
|
257
|
+
right = Math.floor(middle);
|
|
258
|
+
} else {
|
|
259
|
+
clickIdx = Math.ceil(e.offsetX / this.evChartBrushPos.axesXInterval);
|
|
260
|
+
|
|
261
|
+
left = Math.ceil(middle);
|
|
262
|
+
right = Math.floor(middle);
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
clickIdx = Math.floor(e.offsetX / this.evChartBrushPos.axesXInterval);
|
|
266
|
+
|
|
267
|
+
if (
|
|
268
|
+
e.offsetX - (clickIdx * this.evChartBrushPos.axesXInterval)
|
|
269
|
+
> (this.evChartBrushPos.axesXInterval / 2)
|
|
270
|
+
) {
|
|
271
|
+
left = Math.floor(middle);
|
|
272
|
+
right = Math.ceil(middle);
|
|
273
|
+
} else {
|
|
274
|
+
left = Math.ceil(middle);
|
|
275
|
+
right = Math.floor(middle);
|
|
276
|
+
|
|
277
|
+
if (middle < 1) {
|
|
278
|
+
clickIdx += 1;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (clickIdx - left <= 0) {
|
|
284
|
+
brushIdx.start = 0;
|
|
285
|
+
brushIdx.end = right + left;
|
|
286
|
+
} else if (clickIdx + right >= this.labelEndIdx) {
|
|
287
|
+
brushIdx.start = this.labelEndIdx - right - left;
|
|
288
|
+
brushIdx.end = this.labelEndIdx;
|
|
289
|
+
} else {
|
|
290
|
+
brushIdx.start = clickIdx - left;
|
|
291
|
+
brushIdx.end = clickIdx + right;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
this.brushIdx.isUseScroll = true;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
changeCursor(mousePosition) {
|
|
298
|
+
if (mousePosition.isOutsideBrush) {
|
|
299
|
+
this.brushCanvas.style.cursor = 'pointer';
|
|
300
|
+
} else if (mousePosition.isInsideBrush) {
|
|
301
|
+
if (mousePosition.isInsideButton) {
|
|
302
|
+
this.brushCanvas.style.cursor = 'ew-resize';
|
|
303
|
+
} else {
|
|
304
|
+
this.brushCanvas.style.cursor = 'grab';
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
mouseDownAndMove(e) {
|
|
310
|
+
const moveSensitive = this.evChartBrushPos.axesXInterval / 3;
|
|
311
|
+
let mode;
|
|
312
|
+
|
|
313
|
+
if (e.offsetX > this.beforeMouseXPos) {
|
|
314
|
+
// 오른쪽 이동
|
|
315
|
+
if (this.clickBrushInsideX > 0) {
|
|
316
|
+
if (this.clickBrushInsideX < e.offsetX - moveSensitive) {
|
|
317
|
+
mode = 'moveup';
|
|
318
|
+
this.clickBrushInsideX = e.offsetX + moveSensitive;
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
const isMoveRight = e.offsetX - this.evChartBrushPos[this.curBrushButtonType]
|
|
322
|
+
> moveSensitive;
|
|
323
|
+
|
|
324
|
+
if (isMoveRight) {
|
|
325
|
+
mode = this.curBrushButtonType === 'leftX' ? 'decrease' : 'increase';
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
} else if (e.offsetX < this.beforeMouseXPos) {
|
|
329
|
+
// 왼쪽 이동
|
|
330
|
+
if (this.clickBrushInsideX > 0) {
|
|
331
|
+
if (this.clickBrushInsideX > e.offsetX + moveSensitive) {
|
|
332
|
+
mode = 'movedown';
|
|
333
|
+
this.clickBrushInsideX = e.offsetX - moveSensitive;
|
|
334
|
+
}
|
|
335
|
+
} else {
|
|
336
|
+
const isMoveLeft = this.evChartBrushPos[this.curBrushButtonType] - e.offsetX
|
|
337
|
+
> moveSensitive;
|
|
338
|
+
|
|
339
|
+
if (isMoveLeft) {
|
|
340
|
+
mode = this.curBrushButtonType === 'leftX' ? 'increase' : 'decrease';
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (mode) {
|
|
346
|
+
this.updateBrushIdx(mode);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
this.beforeMouseXPos = e.offsetX;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* @param {string} mode determines how to update the brush index value.
|
|
354
|
+
*
|
|
355
|
+
* @returns {undefined}
|
|
356
|
+
*/
|
|
357
|
+
updateBrushIdx(mode) {
|
|
358
|
+
const brushIdx = this.debounceBrushIdx ?? this.brushIdx;
|
|
359
|
+
|
|
360
|
+
switch (mode) {
|
|
361
|
+
case 'moveup':
|
|
362
|
+
if (brushIdx.end === this.labelEndIdx) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
brushIdx.start += 1;
|
|
367
|
+
brushIdx.end += 1;
|
|
368
|
+
|
|
369
|
+
this.brushIdx.isUseScroll = true;
|
|
370
|
+
break;
|
|
371
|
+
case 'movedown':
|
|
372
|
+
if (!brushIdx.start) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
brushIdx.start -= 1;
|
|
377
|
+
brushIdx.end -= 1;
|
|
378
|
+
|
|
379
|
+
this.brushIdx.isUseScroll = true;
|
|
380
|
+
break;
|
|
381
|
+
case 'increase':
|
|
382
|
+
if (this.curBrushButtonType === 'leftX') {
|
|
383
|
+
if (!brushIdx.start) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
brushIdx.start -= 1;
|
|
388
|
+
} else {
|
|
389
|
+
if (brushIdx.end === this.labelEndIdx) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
brushIdx.end += 1;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
this.brushIdx.isUseButton = true;
|
|
397
|
+
break;
|
|
398
|
+
case 'decrease':
|
|
399
|
+
if (brushIdx.start === brushIdx.end - 1) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (this.curBrushButtonType === 'leftX') {
|
|
404
|
+
brushIdx.start += 1;
|
|
405
|
+
} else {
|
|
406
|
+
brushIdx.end -= 1;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
this.brushIdx.isUseButton = true;
|
|
410
|
+
break;
|
|
411
|
+
default:
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if (mode && this.debounceBrushIdx) {
|
|
416
|
+
this.drawBrushRect({
|
|
417
|
+
brushCanvas: this.brushCanvas,
|
|
418
|
+
isResize: false,
|
|
419
|
+
isDebounce: true,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* @param {boolean} isUpdateBrushIdx to initialize state after update brush index value
|
|
426
|
+
*
|
|
427
|
+
* @returns {undefined}
|
|
428
|
+
*/
|
|
429
|
+
initEventState() {
|
|
430
|
+
const promise = new Promise((resolve) => {
|
|
431
|
+
if (
|
|
432
|
+
this.debounceBrushIdx
|
|
433
|
+
&& (this.brushIdx.isUseButton || this.brushIdx.isUseScroll)
|
|
434
|
+
) {
|
|
435
|
+
this.brushIdx.start = this.debounceBrushIdx.start;
|
|
436
|
+
this.brushIdx.end = this.debounceBrushIdx.end;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
resolve(true);
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
promise.then((isUpdateBrushIdx) => {
|
|
443
|
+
if (isUpdateBrushIdx) {
|
|
444
|
+
this.clickBrushInsideX = null;
|
|
445
|
+
this.beforeMouseXPos = null;
|
|
446
|
+
this.curBrushButtonType = null;
|
|
447
|
+
|
|
448
|
+
this.brushIdx.isUseButton = false;
|
|
449
|
+
this.brushIdx.isUseScroll = false;
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defaultsDeep } from 'lodash-es';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_OPTIONS = {
|
|
4
|
+
show: true,
|
|
5
|
+
useDebounce: true,
|
|
6
|
+
chartIdx: 0,
|
|
7
|
+
height: 100,
|
|
8
|
+
showLabel: false,
|
|
9
|
+
selection: {
|
|
10
|
+
fillColor: '#38ACEC',
|
|
11
|
+
opacity: 0.65,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
16
|
+
export const useBrushModel = () => {
|
|
17
|
+
const getNormalizedBrushOptions = options => defaultsDeep({}, options, DEFAULT_OPTIONS);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
getNormalizedBrushOptions,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-if="zoomOptions.toolbar.show"
|
|
4
|
+
ref="evChartToolbarRef"
|
|
5
|
+
>
|
|
6
|
+
<ev-chart-toolbar
|
|
7
|
+
:toolbar="zoomOptions.toolbar"
|
|
8
|
+
@on-click-toolbar="onClickToolbar"
|
|
9
|
+
/>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div
|
|
13
|
+
ref="evChartGroupRef"
|
|
14
|
+
class="ev-chart-group__wrapper"
|
|
15
|
+
>
|
|
16
|
+
<slot />
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { onMounted, watch, provide, toRef, computed } from 'vue';
|
|
22
|
+
import evChartToolbar from '../chart/ChartToolbar';
|
|
23
|
+
import { useGroupModel } from './uses';
|
|
24
|
+
import { useZoomModel } from '../chart/uses';
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
name: 'EvChartGroup',
|
|
28
|
+
components: {
|
|
29
|
+
evChartToolbar,
|
|
30
|
+
},
|
|
31
|
+
props: {
|
|
32
|
+
options: {
|
|
33
|
+
type: Object,
|
|
34
|
+
default: () => ({}),
|
|
35
|
+
},
|
|
36
|
+
zoomStartIdx: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: 0,
|
|
39
|
+
},
|
|
40
|
+
zoomEndIdx: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 0,
|
|
43
|
+
},
|
|
44
|
+
groupSelectedLabel: {
|
|
45
|
+
type: Object,
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
emits: [
|
|
50
|
+
'update:zoomStartIdx',
|
|
51
|
+
'update:zoomEndIdx',
|
|
52
|
+
],
|
|
53
|
+
setup(props) {
|
|
54
|
+
const {
|
|
55
|
+
getNormalizedOptions,
|
|
56
|
+
isExecuteZoom,
|
|
57
|
+
brushSeries,
|
|
58
|
+
evChartGroupRef,
|
|
59
|
+
} = useGroupModel();
|
|
60
|
+
|
|
61
|
+
const normalizedOptions = getNormalizedOptions(props.options);
|
|
62
|
+
provide('isExecuteZoom', isExecuteZoom);
|
|
63
|
+
provide('isChartGroup', true);
|
|
64
|
+
provide('brushSeries', brushSeries);
|
|
65
|
+
|
|
66
|
+
const groupSelectedLabel = computed(() => props.groupSelectedLabel);
|
|
67
|
+
provide('groupSelectedLabel', groupSelectedLabel);
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
evChartZoomOptions,
|
|
71
|
+
evChartInfo,
|
|
72
|
+
evChartToolbarRef,
|
|
73
|
+
evChartClone,
|
|
74
|
+
brushIdx,
|
|
75
|
+
|
|
76
|
+
createEvChartZoom,
|
|
77
|
+
setOptionsForUseZoom,
|
|
78
|
+
setDataForUseZoom,
|
|
79
|
+
controlZoomIdx,
|
|
80
|
+
onClickToolbar,
|
|
81
|
+
} = useZoomModel(
|
|
82
|
+
normalizedOptions,
|
|
83
|
+
{ wrapper: null, evChartGroupRef },
|
|
84
|
+
groupSelectedLabel,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
provide('evChartClone', evChartClone);
|
|
88
|
+
provide('evChartInfo', evChartInfo);
|
|
89
|
+
provide('brushIdx', brushIdx);
|
|
90
|
+
|
|
91
|
+
onMounted(() => {
|
|
92
|
+
createEvChartZoom();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
watch(() => evChartInfo.props.data, (evChartProps) => {
|
|
96
|
+
setDataForUseZoom(evChartProps);
|
|
97
|
+
}, { deep: true });
|
|
98
|
+
|
|
99
|
+
watch(() => props.options, (zoomOptions) => {
|
|
100
|
+
const newOpt = getNormalizedOptions(zoomOptions);
|
|
101
|
+
|
|
102
|
+
setOptionsForUseZoom(newOpt);
|
|
103
|
+
}, { deep: true });
|
|
104
|
+
|
|
105
|
+
watch(() => [props.zoomStartIdx, props.zoomEndIdx], ([zoomStartIdx, zoomEndIdx]) => {
|
|
106
|
+
if (brushIdx.isUseButton || brushIdx.isUseScroll) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
controlZoomIdx(zoomStartIdx, zoomEndIdx);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
evChartGroupRef,
|
|
115
|
+
evChartToolbarRef,
|
|
116
|
+
zoomOptions: toRef(evChartZoomOptions, 'zoom'),
|
|
117
|
+
onClickToolbar,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<style lang="scss" scoped>
|
|
124
|
+
@import 'style/chartGroup.scss';
|
|
125
|
+
</style>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ref, reactive } from 'vue';
|
|
2
|
+
import { defaultsDeep } from 'lodash-es';
|
|
3
|
+
|
|
4
|
+
const DEFAULT_OPTIONS = {
|
|
5
|
+
zoom: {
|
|
6
|
+
bufferMemoryCnt: 100,
|
|
7
|
+
toolbar: {
|
|
8
|
+
show: false,
|
|
9
|
+
items: {
|
|
10
|
+
previous: {
|
|
11
|
+
icon: 'ev-icon-allow2-left',
|
|
12
|
+
size: 'medium',
|
|
13
|
+
title: 'Previous',
|
|
14
|
+
},
|
|
15
|
+
latest: {
|
|
16
|
+
icon: 'ev-icon-allow2-right',
|
|
17
|
+
size: 'medium',
|
|
18
|
+
title: 'Latest',
|
|
19
|
+
},
|
|
20
|
+
reset: {
|
|
21
|
+
icon: 'ev-icon-redo',
|
|
22
|
+
size: 'medium',
|
|
23
|
+
title: 'Reset',
|
|
24
|
+
},
|
|
25
|
+
dragZoom: {
|
|
26
|
+
icon: 'ev-icon-zoomin',
|
|
27
|
+
size: 'medium',
|
|
28
|
+
title: 'Drag Zoom',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
36
|
+
export const useGroupModel = () => {
|
|
37
|
+
const isExecuteZoom = ref(false);
|
|
38
|
+
const evChartGroupRef = ref();
|
|
39
|
+
const brushSeries = reactive({ list: [], chartIdx: null });
|
|
40
|
+
const getNormalizedOptions = options => defaultsDeep({}, options, DEFAULT_OPTIONS);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
getNormalizedOptions,
|
|
44
|
+
isExecuteZoom,
|
|
45
|
+
brushSeries,
|
|
46
|
+
evChartGroupRef,
|
|
47
|
+
};
|
|
48
|
+
};
|
package/src/main.js
CHANGED
|
@@ -27,6 +27,8 @@ import EvTree from '@/components/tree/';
|
|
|
27
27
|
import EvTimePicker from '@/components/timePicker/';
|
|
28
28
|
import EvGrid from '@/components/grid/';
|
|
29
29
|
import EvChart from '@/components/chart/';
|
|
30
|
+
import EvChartGroup from '@/components/chartGroup/';
|
|
31
|
+
import EvChartBrush from '@/components/chartBrush/';
|
|
30
32
|
import EvTreeGrid from '@/components/treeGrid/';
|
|
31
33
|
import EvPagination from '@/components/pagination/';
|
|
32
34
|
import { version } from '../package.json';
|
|
@@ -58,6 +60,8 @@ const components = [
|
|
|
58
60
|
EvTimePicker,
|
|
59
61
|
EvGrid,
|
|
60
62
|
EvChart,
|
|
63
|
+
EvChartGroup,
|
|
64
|
+
EvChartBrush,
|
|
61
65
|
EvMessage,
|
|
62
66
|
EvNotification,
|
|
63
67
|
EvMessageBox,
|