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,479 @@
|
|
|
1
|
+
export default class EvChartZoom {
|
|
2
|
+
constructor(
|
|
3
|
+
evChartInfo,
|
|
4
|
+
evChartClone,
|
|
5
|
+
evChartZoomOptions,
|
|
6
|
+
evChartToolbarRef,
|
|
7
|
+
isExecuteZoom,
|
|
8
|
+
brushIdx,
|
|
9
|
+
emitFunc,
|
|
10
|
+
) {
|
|
11
|
+
this.isExecuteZoom = isExecuteZoom;
|
|
12
|
+
this.evChartProps = evChartInfo.props;
|
|
13
|
+
this.evChartCloneData = evChartClone.data;
|
|
14
|
+
this.brushIdx = brushIdx;
|
|
15
|
+
|
|
16
|
+
this.setEvChartZoomOptions(evChartZoomOptions);
|
|
17
|
+
this.setIcon(evChartToolbarRef);
|
|
18
|
+
|
|
19
|
+
const cloneLabelsLastIdx = evChartClone.data[0].labels.length - 1;
|
|
20
|
+
this.cloneLabelsLastIdx = cloneLabelsLastIdx;
|
|
21
|
+
|
|
22
|
+
this.isAnimationFinish = true;
|
|
23
|
+
|
|
24
|
+
this.zoomAreaMemory = {
|
|
25
|
+
previous: [],
|
|
26
|
+
current: [[0, cloneLabelsLastIdx]],
|
|
27
|
+
latest: [],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
if (emitFunc) {
|
|
31
|
+
this.emitFunc = emitFunc;
|
|
32
|
+
|
|
33
|
+
emitFunc.updateZoomStartIdx(0);
|
|
34
|
+
emitFunc.updateZoomEndIdx(cloneLabelsLastIdx);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.wrapWheelMoveZoomArea = this.wheelMoveZoomArea.bind(this);
|
|
38
|
+
this.evChartDomContainers = this.drawAnimationCanvas(evChartInfo.dom);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setEvChartZoomOptions(options) {
|
|
42
|
+
this.evChartZoomOptions = options;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setIcon(evChartToolbarRef) {
|
|
46
|
+
if (!evChartToolbarRef) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const dragZoomIcon = evChartToolbarRef.querySelector('.dragZoom');
|
|
51
|
+
|
|
52
|
+
this.resetIcon = evChartToolbarRef.querySelector('.reset');
|
|
53
|
+
this.previousIcon = evChartToolbarRef.querySelector('.previous');
|
|
54
|
+
this.latestIcon = evChartToolbarRef.querySelector('.latest');
|
|
55
|
+
this.dragZoomIcon = dragZoomIcon;
|
|
56
|
+
|
|
57
|
+
this.iconStyle(dragZoomIcon, 'enable');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
drawAnimationCanvas(evChartDom) {
|
|
61
|
+
evChartDom.forEach((dom) => {
|
|
62
|
+
const animationCanvas = document.createElement('canvas');
|
|
63
|
+
animationCanvas.setAttribute('style', 'display: block;');
|
|
64
|
+
animationCanvas.setAttribute('class', 'animation-canvas');
|
|
65
|
+
animationCanvas.style.position = 'absolute';
|
|
66
|
+
|
|
67
|
+
dom.appendChild(animationCanvas);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return evChartDom;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setEventListener(isUseZoomMode) {
|
|
74
|
+
const toggleEventListener = isUseZoomMode ? 'addEventListener' : 'removeEventListener';
|
|
75
|
+
this.isUseZoomMode = isUseZoomMode;
|
|
76
|
+
|
|
77
|
+
this.evChartDomContainers.forEach((dom) => {
|
|
78
|
+
dom[toggleEventListener]('wheel', this.wrapWheelMoveZoomArea);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
wheelMoveZoomArea(e) {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
const [zoomStartIdx, zoomEndIdx] = this.zoomAreaMemory.current[0];
|
|
85
|
+
|
|
86
|
+
if (zoomStartIdx === zoomEndIdx) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let zoomMoveStartIdx;
|
|
91
|
+
let zoomMoveEndIdx;
|
|
92
|
+
if (e.deltaY > 0) {
|
|
93
|
+
if (!zoomStartIdx) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
zoomMoveStartIdx = zoomStartIdx - 1;
|
|
98
|
+
zoomMoveEndIdx = zoomEndIdx - 1;
|
|
99
|
+
} else {
|
|
100
|
+
if (zoomEndIdx === this.cloneLabelsLastIdx) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
zoomMoveStartIdx = zoomStartIdx + 1;
|
|
105
|
+
zoomMoveEndIdx = zoomEndIdx + 1;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.isUseToolbar = true;
|
|
109
|
+
this.executeZoom(zoomMoveStartIdx, zoomMoveEndIdx);
|
|
110
|
+
this.zoomAreaMemory.current[0] = [zoomMoveStartIdx, zoomMoveEndIdx];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
clickMoveZoomArea(direction) {
|
|
114
|
+
if (!this.zoomAreaMemory[direction].length) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const [zoomStartIdx, zoomEndIdx] = this.zoomAreaMemory[direction].pop();
|
|
119
|
+
|
|
120
|
+
this.isUseToolbar = true;
|
|
121
|
+
this.executeZoom(zoomStartIdx, zoomEndIdx);
|
|
122
|
+
this.setZoomAreaMemory(zoomStartIdx, zoomEndIdx, direction === 'previous' ? 'latest' : 'previous');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
dragZoom({ data: zoomInfoData, range: { dragSelectionInfo } }) {
|
|
126
|
+
const {
|
|
127
|
+
dragXsp,
|
|
128
|
+
dragXep,
|
|
129
|
+
exceptAxesYChartWidth,
|
|
130
|
+
chartTitle,
|
|
131
|
+
} = dragSelectionInfo;
|
|
132
|
+
const { options: evChartOptions, data: evChartData } = this.evChartProps;
|
|
133
|
+
|
|
134
|
+
const dragChartIdx = evChartOptions.length > 1 ? evChartOptions.findIndex(
|
|
135
|
+
option => (option?.title?.text ?? '') === chartTitle,
|
|
136
|
+
) : 0;
|
|
137
|
+
|
|
138
|
+
if (evChartOptions[dragChartIdx].axesX[0].type === 'time') {
|
|
139
|
+
const zoomSeries = zoomInfoData[0].items;
|
|
140
|
+
const zoomStartDate = zoomSeries[0].x;
|
|
141
|
+
const zoomEndDate = zoomSeries[zoomSeries.length - 1].x;
|
|
142
|
+
const currentChartDataLabels = evChartData[dragChartIdx].labels;
|
|
143
|
+
const cloneChartDataLabels = this.evChartCloneData[dragChartIdx].labels;
|
|
144
|
+
const [currentZoomStartIdx, currentZoomEndIdx] = this.zoomAreaMemory.current[0];
|
|
145
|
+
|
|
146
|
+
let newZoomStartIdx = cloneChartDataLabels.findIndex(
|
|
147
|
+
label => +label.$d === +zoomStartDate.$d,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
let newZoomEndIdx = cloneChartDataLabels.findLastIndex(
|
|
151
|
+
label => +label.$d === +zoomEndDate.$d,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const calculateAxesXPosition = (zoomIdx) => {
|
|
155
|
+
const axesXInterval = exceptAxesYChartWidth / (currentChartDataLabels.length - 1);
|
|
156
|
+
|
|
157
|
+
return axesXInterval * (zoomIdx - currentZoomStartIdx);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
let newDragStartAxesX = calculateAxesXPosition(newZoomStartIdx);
|
|
161
|
+
|
|
162
|
+
if (newZoomStartIdx === newZoomEndIdx) {
|
|
163
|
+
// drag 영역에 한 포인트만 있을 경우
|
|
164
|
+
if (newDragStartAxesX - dragXsp >= dragXep - newDragStartAxesX) {
|
|
165
|
+
newZoomStartIdx -= 1;
|
|
166
|
+
} else {
|
|
167
|
+
newZoomEndIdx += 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (newZoomStartIdx === currentZoomStartIdx && newZoomEndIdx === currentZoomEndIdx) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (newZoomStartIdx - newZoomEndIdx === -1) {
|
|
176
|
+
newDragStartAxesX = calculateAxesXPosition(newZoomStartIdx);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const newDragEndAxesX = calculateAxesXPosition(newZoomEndIdx);
|
|
180
|
+
|
|
181
|
+
this.dragZoomAnimation(
|
|
182
|
+
dragSelectionInfo,
|
|
183
|
+
newZoomStartIdx,
|
|
184
|
+
newZoomEndIdx,
|
|
185
|
+
newDragStartAxesX,
|
|
186
|
+
newDragEndAxesX,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
dragZoomAnimation(
|
|
192
|
+
dragSelectionInfo,
|
|
193
|
+
newZoomStartIdx,
|
|
194
|
+
newZoomEndIdx,
|
|
195
|
+
newDragStartAxesX,
|
|
196
|
+
newDragEndAxesX,
|
|
197
|
+
) {
|
|
198
|
+
const {
|
|
199
|
+
chartRange,
|
|
200
|
+
exceptAxesYChartWidth,
|
|
201
|
+
exceptAxesXChartHeight,
|
|
202
|
+
} = dragSelectionInfo;
|
|
203
|
+
const pixelRatio = window.devicePixelRatio || 1;
|
|
204
|
+
|
|
205
|
+
const displayAnimaionCanvas = Array.from(this.evChartDomContainers).map((container) => {
|
|
206
|
+
const animationCanvas = container.querySelector('.animation-canvas');
|
|
207
|
+
const displayCanvas = container.children[0];
|
|
208
|
+
|
|
209
|
+
return [displayCanvas, animationCanvas];
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
for (let idx = 0; idx < displayAnimaionCanvas.length; idx++) {
|
|
213
|
+
const [displayCanvas, animationCanvas] = displayAnimaionCanvas[idx];
|
|
214
|
+
|
|
215
|
+
const animationCtx = animationCanvas.getContext('2d');
|
|
216
|
+
|
|
217
|
+
animationCanvas.style.top = `${chartRange.y1}px`;
|
|
218
|
+
animationCanvas.style.left = `${chartRange.x1}px`;
|
|
219
|
+
|
|
220
|
+
animationCanvas.width = exceptAxesYChartWidth * pixelRatio;
|
|
221
|
+
animationCanvas.style.width = `${exceptAxesYChartWidth}px`;
|
|
222
|
+
animationCanvas.height = exceptAxesXChartHeight * pixelRatio;
|
|
223
|
+
animationCanvas.style.height = `${exceptAxesXChartHeight}px`;
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
if (animationCanvas.style.display === 'none') {
|
|
227
|
+
animationCanvas.style.display = 'block';
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
this.isAnimationFinish = false;
|
|
231
|
+
this.isUseToolbar = true;
|
|
232
|
+
this.executeDragZoomAnimation(
|
|
233
|
+
displayCanvas,
|
|
234
|
+
animationCtx,
|
|
235
|
+
dragSelectionInfo,
|
|
236
|
+
newDragStartAxesX,
|
|
237
|
+
newDragEndAxesX,
|
|
238
|
+
).then((isAnimationFinish) => {
|
|
239
|
+
animationCanvas.style.display = 'none';
|
|
240
|
+
|
|
241
|
+
if (isAnimationFinish && idx === displayAnimaionCanvas.length - 1) {
|
|
242
|
+
this.isAnimationFinish = isAnimationFinish;
|
|
243
|
+
this.executeZoom(newZoomStartIdx, newZoomEndIdx);
|
|
244
|
+
this.setZoomAreaMemory(newZoomStartIdx, newZoomEndIdx);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
executeZoom(zoomStartIdx, zoomEndIdx) {
|
|
251
|
+
if (this.isExecuteZoom) {
|
|
252
|
+
this.isExecuteZoom.value = true;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
for (let idx = 0; idx < this.evChartCloneData.length; idx++) {
|
|
256
|
+
const {
|
|
257
|
+
data: cloneData,
|
|
258
|
+
labels: cloneLabels,
|
|
259
|
+
series: cloneSeries,
|
|
260
|
+
} = this.evChartCloneData[idx];
|
|
261
|
+
const evChartData = this.evChartProps.data[idx];
|
|
262
|
+
|
|
263
|
+
const cloneSeriesNames = Object.keys(cloneSeries);
|
|
264
|
+
|
|
265
|
+
for (let jdx = 0; jdx < cloneSeriesNames.length; jdx++) {
|
|
266
|
+
const cloneSeriesName = cloneSeriesNames[jdx];
|
|
267
|
+
|
|
268
|
+
evChartData.data[cloneSeriesName] = cloneData[cloneSeriesName].filter(
|
|
269
|
+
(d, dataIdx) => zoomStartIdx <= dataIdx && zoomEndIdx >= dataIdx,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
evChartData.labels = cloneLabels.filter(
|
|
274
|
+
(l, labelIdx) => zoomStartIdx <= labelIdx && zoomEndIdx >= labelIdx,
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (!this.brushIdx.isUseButton && !this.brushIdx.isUseScroll) {
|
|
279
|
+
this.brushIdx.start = zoomStartIdx;
|
|
280
|
+
this.brushIdx.end = zoomEndIdx;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (this.emitFunc) {
|
|
284
|
+
this.emitFunc.updateZoomStartIdx(zoomStartIdx);
|
|
285
|
+
this.emitFunc.updateZoomEndIdx(zoomEndIdx);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
updateEvChartCloneData(evChartClone, isUseZoomMode) {
|
|
290
|
+
const cloneLabelsLastIdx = evChartClone.data[0].labels.length - 1;
|
|
291
|
+
this.cloneLabelsLastIdx = cloneLabelsLastIdx;
|
|
292
|
+
this.evChartCloneData = evChartClone.data;
|
|
293
|
+
|
|
294
|
+
if (this.dragZoomIcon) {
|
|
295
|
+
this.dragZoomIcon.classList.remove('active');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
this.zoomAreaMemory = {
|
|
299
|
+
previous: [],
|
|
300
|
+
current: [[0, cloneLabelsLastIdx]],
|
|
301
|
+
latest: [],
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
if (this.emitFunc) {
|
|
305
|
+
this.emitFunc.updateZoomStartIdx(0);
|
|
306
|
+
this.emitFunc.updateZoomEndIdx(cloneLabelsLastIdx);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
this.setIconStyle(isUseZoomMode);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
setZoomAreaMemory(zoomStartIdx, zoomEndIdx, direction) {
|
|
313
|
+
const { previous, current, latest } = this.zoomAreaMemory;
|
|
314
|
+
const currentZoomArea = current.pop();
|
|
315
|
+
const { bufferMemoryCnt } = this.evChartZoomOptions.zoom;
|
|
316
|
+
|
|
317
|
+
if (direction) {
|
|
318
|
+
if (previous.length >= bufferMemoryCnt) {
|
|
319
|
+
previous.splice(0, previous.length - bufferMemoryCnt + 1);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
this.zoomAreaMemory[direction].push(currentZoomArea);
|
|
323
|
+
} else {
|
|
324
|
+
previous.push(currentZoomArea);
|
|
325
|
+
latest.length = 0;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
current.push([zoomStartIdx, zoomEndIdx]);
|
|
329
|
+
|
|
330
|
+
this.setIconStyle(this.isUseZoomMode);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
executeDragZoomAnimation(
|
|
334
|
+
displayCanvas,
|
|
335
|
+
animationCtx,
|
|
336
|
+
dragSelectionInfo,
|
|
337
|
+
newDragStartAxesX,
|
|
338
|
+
newDragEndAxesX,
|
|
339
|
+
) {
|
|
340
|
+
const {
|
|
341
|
+
chartRange,
|
|
342
|
+
exceptAxesYChartWidth,
|
|
343
|
+
exceptAxesXChartHeight,
|
|
344
|
+
} = dragSelectionInfo;
|
|
345
|
+
|
|
346
|
+
let leftDx = 0;
|
|
347
|
+
let centerDx = newDragStartAxesX;
|
|
348
|
+
let centerDWidth = newDragEndAxesX - newDragStartAxesX;
|
|
349
|
+
let rightDx = newDragEndAxesX;
|
|
350
|
+
|
|
351
|
+
let globalAlpha = 1;
|
|
352
|
+
const globalAlphaSensitivity = 0.0015;
|
|
353
|
+
|
|
354
|
+
let evChartOpacity = 0.5;
|
|
355
|
+
const evChartMinOpacity = 0.1;
|
|
356
|
+
const evChartOpacitySensitivity = 0.05;
|
|
357
|
+
|
|
358
|
+
const zoomSpeed = 50;
|
|
359
|
+
const leftSpeed = Math.ceil(
|
|
360
|
+
zoomSpeed * (newDragStartAxesX / exceptAxesYChartWidth),
|
|
361
|
+
);
|
|
362
|
+
const rightSpeed = Math.ceil(
|
|
363
|
+
zoomSpeed * ((exceptAxesYChartWidth - newDragEndAxesX) / exceptAxesYChartWidth),
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
const animate = (responseFinishStatus) => {
|
|
367
|
+
animationCtx.clearRect(0, 0, exceptAxesYChartWidth, exceptAxesXChartHeight);
|
|
368
|
+
|
|
369
|
+
if (centerDx <= 0 && centerDWidth >= exceptAxesYChartWidth) {
|
|
370
|
+
displayCanvas.style.opacity = 'initial';
|
|
371
|
+
return responseFinishStatus(true);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (evChartOpacity >= evChartMinOpacity) {
|
|
375
|
+
displayCanvas.style.opacity = evChartOpacity;
|
|
376
|
+
evChartOpacity -= evChartOpacitySensitivity;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
animationCtx.globalAlpha = globalAlpha;
|
|
380
|
+
|
|
381
|
+
// 줌 영역 왼쪽
|
|
382
|
+
animationCtx.drawImage(
|
|
383
|
+
displayCanvas,
|
|
384
|
+
chartRange.x1,
|
|
385
|
+
chartRange.y1,
|
|
386
|
+
newDragStartAxesX,
|
|
387
|
+
exceptAxesXChartHeight,
|
|
388
|
+
leftDx,
|
|
389
|
+
0,
|
|
390
|
+
newDragStartAxesX,
|
|
391
|
+
exceptAxesXChartHeight,
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
// 줌 영역
|
|
395
|
+
animationCtx.drawImage(
|
|
396
|
+
displayCanvas,
|
|
397
|
+
chartRange.x1 + newDragStartAxesX,
|
|
398
|
+
chartRange.y1,
|
|
399
|
+
newDragEndAxesX - newDragStartAxesX,
|
|
400
|
+
exceptAxesXChartHeight,
|
|
401
|
+
centerDx,
|
|
402
|
+
0,
|
|
403
|
+
centerDWidth,
|
|
404
|
+
exceptAxesXChartHeight,
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
// 줌 영역 오른쪽
|
|
408
|
+
animationCtx.drawImage(
|
|
409
|
+
displayCanvas,
|
|
410
|
+
chartRange.x1 + newDragEndAxesX,
|
|
411
|
+
chartRange.y1,
|
|
412
|
+
exceptAxesYChartWidth,
|
|
413
|
+
exceptAxesXChartHeight,
|
|
414
|
+
rightDx,
|
|
415
|
+
0,
|
|
416
|
+
exceptAxesYChartWidth,
|
|
417
|
+
exceptAxesXChartHeight,
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
globalAlpha -= globalAlphaSensitivity;
|
|
421
|
+
leftDx -= leftSpeed;
|
|
422
|
+
centerDx -= leftSpeed;
|
|
423
|
+
centerDWidth += (leftSpeed + rightSpeed);
|
|
424
|
+
rightDx += rightSpeed;
|
|
425
|
+
|
|
426
|
+
return requestAnimationFrame(() => animate(responseFinishStatus));
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
return new Promise(response => animate(response));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
setIconStyle(isUseZoomMode) {
|
|
433
|
+
const toggleIconStyle = (icon, condition) => {
|
|
434
|
+
if (condition) {
|
|
435
|
+
this.iconStyle(icon, 'enable');
|
|
436
|
+
} else {
|
|
437
|
+
this.iconStyle(icon, 'disable');
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
if (isUseZoomMode && this.dragZoomIcon.classList.contains('active')) {
|
|
442
|
+
const { previous, latest } = this.zoomAreaMemory;
|
|
443
|
+
|
|
444
|
+
toggleIconStyle(this.previousIcon, previous.length);
|
|
445
|
+
toggleIconStyle(this.latestIcon, latest.length);
|
|
446
|
+
this.iconStyle(this.resetIcon, 'enable');
|
|
447
|
+
} else {
|
|
448
|
+
toggleIconStyle(this.resetIcon);
|
|
449
|
+
toggleIconStyle(this.previousIcon);
|
|
450
|
+
toggleIconStyle(this.latestIcon);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
iconStyle(icon, mode) {
|
|
455
|
+
if (!icon) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const [opacity, pointerEvents] = mode === 'enable' ? [1, 'initial'] : [0.5, 'none'];
|
|
460
|
+
|
|
461
|
+
icon.style.opacity = opacity;
|
|
462
|
+
icon.style.pointerEvents = pointerEvents;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
initZoom() {
|
|
466
|
+
if (!this.isAnimationFinish) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const [currentZoomStartIdx, currentZoomEndIdx] = this.zoomAreaMemory.current[0];
|
|
471
|
+
const cloneLabelsLastIdx = this.cloneLabelsLastIdx;
|
|
472
|
+
|
|
473
|
+
if (currentZoomStartIdx !== 0 || currentZoomEndIdx !== cloneLabelsLastIdx) {
|
|
474
|
+
this.isUseToolbar = true;
|
|
475
|
+
this.executeZoom(0, cloneLabelsLastIdx);
|
|
476
|
+
this.setZoomAreaMemory(0, cloneLabelsLastIdx);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
@@ -47,6 +47,7 @@ class Line {
|
|
|
47
47
|
ctx, chartRect,
|
|
48
48
|
labelOffset, axesSteps,
|
|
49
49
|
selectLabel, selectSeries, legendHitInfo,
|
|
50
|
+
isBrush,
|
|
50
51
|
} = param;
|
|
51
52
|
|
|
52
53
|
// about selectLabel
|
|
@@ -178,7 +179,7 @@ class Line {
|
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
// Draw points
|
|
181
|
-
if (this.point || useSelectLabel) {
|
|
182
|
+
if (!isBrush && (this.point || useSelectLabel)) {
|
|
182
183
|
ctx.strokeStyle = Util.colorStringToRgba(mainColor, mainColorOpacity);
|
|
183
184
|
const focusStyle = Util.colorStringToRgba(pointFillColor, 1);
|
|
184
185
|
const blurStyle = Util.colorStringToRgba(pointFillColor, pointFillColorOpacity);
|
|
@@ -40,11 +40,11 @@ class Scatter {
|
|
|
40
40
|
const chartRect = param.chartRect;
|
|
41
41
|
const labelOffset = param.labelOffset;
|
|
42
42
|
const axesSteps = param.axesSteps;
|
|
43
|
+
const displayOverflow = param.displayOverflow;
|
|
43
44
|
|
|
44
45
|
let x;
|
|
45
46
|
let y;
|
|
46
47
|
let aliasPixel;
|
|
47
|
-
|
|
48
48
|
const minmaxX = axesSteps.x[this.xAxisIndex];
|
|
49
49
|
const minmaxY = axesSteps.y[this.yAxisIndex];
|
|
50
50
|
|
|
@@ -53,6 +53,13 @@ class Scatter {
|
|
|
53
53
|
const xsp = chartRect.x1 + labelOffset.left;
|
|
54
54
|
const ysp = chartRect.y2 - labelOffset.bottom;
|
|
55
55
|
|
|
56
|
+
if (displayOverflow) {
|
|
57
|
+
this.data = this.data.map(val => ({
|
|
58
|
+
...val,
|
|
59
|
+
y: val.y > minmaxY.graphMax ? minmaxY.graphMax : val.y,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
this.data.forEach((item) => {
|
|
57
64
|
x = Canvas.calculateX(item.x, minmaxX.graphMin, minmaxX.graphMax, xArea, xsp);
|
|
58
65
|
y = Canvas.calculateY(item.y, minmaxY.graphMin, minmaxY.graphMax, yArea, ysp);
|
|
@@ -62,7 +69,6 @@ class Scatter {
|
|
|
62
69
|
x += aliasPixel;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
|
|
66
72
|
item.xp = x; // eslint-disable-line
|
|
67
73
|
item.yp = y; // eslint-disable-line
|
|
68
74
|
|
|
@@ -18,49 +18,57 @@ const modules = {
|
|
|
18
18
|
let maxArgs;
|
|
19
19
|
let isExistSelectedLabel;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const executeDrawTip = (tipOpt) => {
|
|
22
|
+
tipLocationInfo.forEach((tipInfo) => {
|
|
23
|
+
if (tipInfo && !isExistSelectedLabel) {
|
|
24
|
+
const seriesInfo = this.seriesList[tipInfo?.sId];
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if (!seriesInfo?.show) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const selArgs = this.calculateTipInfo(
|
|
31
|
+
seriesInfo,
|
|
32
|
+
'sel',
|
|
33
|
+
tipInfo,
|
|
34
|
+
);
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'sel',
|
|
35
|
-
tipLocationInfo,
|
|
36
|
-
);
|
|
36
|
+
if (selArgs) {
|
|
37
|
+
let isSamePos = false;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
if (maxTipOpt.use && maxArgs?.dp === selArgs.dp) {
|
|
40
|
+
isSamePos = true;
|
|
41
|
+
}
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
if (tipOpt.showTextTip || tipOpt.showTip) {
|
|
44
|
+
if (tipOpt.tipText === 'label') {
|
|
45
|
+
const axisOpt = isHorizontal ? opt.axesY[0] : opt.axesX[0];
|
|
46
|
+
const label = selArgs.label;
|
|
47
|
+
selArgs.text = axisOpt.type === 'time' ? dayjs(label).format(axisOpt.timeFormat) : label;
|
|
48
|
+
} else {
|
|
49
|
+
selArgs.text = numberWithComma(selArgs.value);
|
|
50
|
+
}
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const axisOpt = isHorizontal ? opt.axesY[0] : opt.axesX[0];
|
|
48
|
-
const label = selArgs.label;
|
|
49
|
-
selArgs.text = axisOpt.type === 'time' ? dayjs(label).format(axisOpt.timeFormat) : label;
|
|
50
|
-
} else {
|
|
51
|
-
selArgs.text = numberWithComma(selArgs.value);
|
|
52
|
-
}
|
|
52
|
+
this.drawTextTip({ opt: tipOpt, tipType: 'sel', seriesOpt: seriesInfo, isSamePos, ...selArgs });
|
|
53
|
+
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
if (tipOpt.showIndicator) {
|
|
56
|
+
this.drawFixedIndicator({ opt: tipOpt, seriesOpt: seriesInfo, ...selArgs });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
if (tipInfo && tipInfo?.label && tipInfo?.label === 0) {
|
|
61
|
+
this.lastHitInfo = tipInfo;
|
|
62
|
+
}
|
|
59
63
|
}
|
|
60
|
-
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
61
66
|
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
if (tipLocationInfo) {
|
|
68
|
+
if (selTipOpt.use) {
|
|
69
|
+
executeDrawTip(selTipOpt);
|
|
70
|
+
} else if (labelTipOpt.use) {
|
|
71
|
+
executeDrawTip(labelTipOpt);
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
|
|
@@ -538,14 +538,43 @@ const modules = {
|
|
|
538
538
|
return findInfo;
|
|
539
539
|
},
|
|
540
540
|
|
|
541
|
-
getItem(
|
|
542
|
-
const
|
|
541
|
+
getItem(selectedInfo, useApproximate = false) {
|
|
542
|
+
const { seriesID, dataIndex } = selectedInfo;
|
|
543
543
|
|
|
544
|
-
|
|
545
|
-
|
|
544
|
+
let itemPosition;
|
|
545
|
+
if ('seriesID' in selectedInfo) {
|
|
546
|
+
const dataInfo = this.getDataByValues(seriesID, dataIndex);
|
|
547
|
+
|
|
548
|
+
if (!dataInfo || !dataInfo?.xp || !dataInfo?.yp) {
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
itemPosition = [this.getItemByPosition([dataInfo.xp, dataInfo.yp], useApproximate)];
|
|
553
|
+
} else {
|
|
554
|
+
const seriesList = Object.entries(this.seriesList);
|
|
555
|
+
let firShowSeriesID;
|
|
556
|
+
|
|
557
|
+
for (let i = 0; i < seriesList.length; i++) {
|
|
558
|
+
const [id, info] = seriesList[i];
|
|
559
|
+
|
|
560
|
+
if (info.show) {
|
|
561
|
+
firShowSeriesID = id;
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
itemPosition = dataIndex.map((idx) => {
|
|
567
|
+
const dataInfo = this.getDataByValues(firShowSeriesID, idx);
|
|
568
|
+
|
|
569
|
+
if (!dataInfo || !dataInfo?.xp || !dataInfo?.yp) {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
return this.getItemByPosition([dataInfo.xp, dataInfo.yp], useApproximate);
|
|
574
|
+
});
|
|
546
575
|
}
|
|
547
576
|
|
|
548
|
-
return
|
|
577
|
+
return itemPosition;
|
|
549
578
|
},
|
|
550
579
|
|
|
551
580
|
/**
|