evui 3.4.206 → 3.4.208
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/README.md +18 -33
- package/dist/404.html +44 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.js +22645 -0
- package/dist/index.umd.cjs +28 -0
- package/dist/style.css +1 -0
- package/package.json +46 -43
- package/dist/evui.common.js +0 -63678
- package/dist/evui.common.js.map +0 -1
- package/dist/evui.umd.js +0 -63688
- package/dist/evui.umd.js.map +0 -1
- package/dist/evui.umd.min.js +0 -2
- package/dist/evui.umd.min.js.map +0 -1
- package/dist/img/EVUI.b82ee81a.svg +0 -293
- package/src/assets/logo.png +0 -0
- package/src/common/emitter.js +0 -20
- package/src/common/utils.bignumber.js +0 -67
- package/src/common/utils.debounce.js +0 -223
- package/src/common/utils.js +0 -151
- package/src/common/utils.table.js +0 -78
- package/src/common/utils.throttle.js +0 -83
- package/src/common/utils.tree.js +0 -18
- package/src/components/button/Button.vue +0 -195
- package/src/components/button/index.js +0 -7
- package/src/components/buttonGroup/ButtonGroup.vue +0 -11
- package/src/components/buttonGroup/index.js +0 -7
- package/src/components/calendar/Calendar.vue +0 -725
- package/src/components/calendar/index.js +0 -7
- package/src/components/calendar/uses.js +0 -1410
- package/src/components/chart/Chart.vue +0 -363
- package/src/components/chart/ChartToolbar.vue +0 -52
- package/src/components/chart/chart.core.js +0 -1170
- package/src/components/chart/chartZoom.core.js +0 -540
- package/src/components/chart/element/element.bar.js +0 -672
- package/src/components/chart/element/element.bar.time.js +0 -166
- package/src/components/chart/element/element.heatmap.js +0 -743
- package/src/components/chart/element/element.line.js +0 -611
- package/src/components/chart/element/element.pie.js +0 -197
- package/src/components/chart/element/element.scatter.js +0 -320
- package/src/components/chart/element/element.tip.js +0 -717
- package/src/components/chart/helpers/helpers.canvas.js +0 -265
- package/src/components/chart/helpers/helpers.constant.js +0 -235
- package/src/components/chart/helpers/helpers.util.js +0 -400
- package/src/components/chart/index.js +0 -9
- package/src/components/chart/model/index.js +0 -50
- package/src/components/chart/model/model.series.js +0 -125
- package/src/components/chart/model/model.store.js +0 -1427
- package/src/components/chart/plugins/plugins.interaction.js +0 -1655
- package/src/components/chart/plugins/plugins.legend.gradient.js +0 -606
- package/src/components/chart/plugins/plugins.legend.js +0 -1543
- package/src/components/chart/plugins/plugins.pie.js +0 -254
- package/src/components/chart/plugins/plugins.scrollbar.js +0 -732
- package/src/components/chart/plugins/plugins.title.js +0 -61
- package/src/components/chart/plugins/plugins.tooltip.js +0 -1041
- package/src/components/chart/scale/scale.js +0 -951
- package/src/components/chart/scale/scale.linear.js +0 -268
- package/src/components/chart/scale/scale.logarithmic.js +0 -135
- package/src/components/chart/scale/scale.step.js +0 -430
- package/src/components/chart/scale/scale.time.category.js +0 -338
- package/src/components/chart/scale/scale.time.js +0 -49
- package/src/components/chart/style/chart.scss +0 -405
- package/src/components/chart/uses.js +0 -721
- package/src/components/chartBrush/ChartBrush.vue +0 -323
- package/src/components/chartBrush/chartBrush.core.js +0 -691
- package/src/components/chartBrush/index.js +0 -9
- package/src/components/chartBrush/uses.js +0 -23
- package/src/components/chartGroup/ChartGroup.vue +0 -144
- package/src/components/chartGroup/index.js +0 -9
- package/src/components/chartGroup/style/chartGroup.scss +0 -5
- package/src/components/chartGroup/uses.js +0 -53
- package/src/components/checkbox/Checkbox.vue +0 -229
- package/src/components/checkbox/index.js +0 -7
- package/src/components/checkboxGroup/CheckboxGroup.vue +0 -44
- package/src/components/checkboxGroup/index.js +0 -7
- package/src/components/contextMenu/ContextMenu.vue +0 -95
- package/src/components/contextMenu/MenuList.vue +0 -182
- package/src/components/contextMenu/index.js +0 -7
- package/src/components/contextMenu/uses.js +0 -223
- package/src/components/datePicker/DatePicker.vue +0 -504
- package/src/components/datePicker/index.js +0 -7
- package/src/components/datePicker/uses.js +0 -460
- package/src/components/grid/Grid.vue +0 -1535
- package/src/components/grid/GridColumnSetting.vue +0 -358
- package/src/components/grid/GridFilterSetting.vue +0 -323
- package/src/components/grid/GridPagination.vue +0 -75
- package/src/components/grid/GridSummary.vue +0 -314
- package/src/components/grid/GridToolbar.vue +0 -35
- package/src/components/grid/icon/icon-option-button.vue +0 -17
- package/src/components/grid/icon/icon-sort-button.vue +0 -67
- package/src/components/grid/index.js +0 -11
- package/src/components/grid/style/grid.scss +0 -417
- package/src/components/grid/uses.js +0 -1629
- package/src/components/icon/Icon.vue +0 -53
- package/src/components/icon/index.js +0 -8
- package/src/components/inputNumber/InputNumber.vue +0 -212
- package/src/components/inputNumber/index.js +0 -7
- package/src/components/inputNumber/uses.js +0 -217
- package/src/components/loading/Loading.vue +0 -125
- package/src/components/loading/index.js +0 -7
- package/src/components/menu/Menu.vue +0 -79
- package/src/components/menu/MenuItem.vue +0 -201
- package/src/components/menu/index.js +0 -7
- package/src/components/message/Message.vue +0 -229
- package/src/components/message/index.js +0 -34
- package/src/components/messageBox/MessageBox.vue +0 -358
- package/src/components/messageBox/index.js +0 -22
- package/src/components/notification/Notification.vue +0 -316
- package/src/components/notification/index.js +0 -49
- package/src/components/pagination/Pagination.vue +0 -317
- package/src/components/pagination/index.js +0 -7
- package/src/components/pagination/pageButton.vue +0 -31
- package/src/components/progress/Progress.vue +0 -139
- package/src/components/progress/index.js +0 -7
- package/src/components/radio/Radio.vue +0 -159
- package/src/components/radio/index.js +0 -7
- package/src/components/radioGroup/RadioGroup.vue +0 -41
- package/src/components/radioGroup/index.js +0 -7
- package/src/components/scheduler/Scheduler.vue +0 -149
- package/src/components/scheduler/index.js +0 -7
- package/src/components/scheduler/uses.js +0 -183
- package/src/components/select/Select.vue +0 -556
- package/src/components/select/index.js +0 -7
- package/src/components/select/uses.js +0 -379
- package/src/components/slider/Slider.vue +0 -505
- package/src/components/slider/index.js +0 -7
- package/src/components/slider/uses.js +0 -391
- package/src/components/tabPanel/TabPanel.vue +0 -74
- package/src/components/tabPanel/index.js +0 -7
- package/src/components/tabs/Tabs.vue +0 -517
- package/src/components/tabs/index.js +0 -7
- package/src/components/textField/TextField.vue +0 -399
- package/src/components/textField/index.js +0 -7
- package/src/components/timePicker/TimePicker.vue +0 -364
- package/src/components/timePicker/index.js +0 -7
- package/src/components/toggle/Toggle.vue +0 -115
- package/src/components/toggle/index.js +0 -7
- package/src/components/tree/Tree.vue +0 -338
- package/src/components/tree/TreeNode.vue +0 -293
- package/src/components/tree/index.js +0 -7
- package/src/components/treeGrid/TreeGrid.vue +0 -1074
- package/src/components/treeGrid/TreeGridNode.vue +0 -349
- package/src/components/treeGrid/TreeGridToolbar.vue +0 -35
- package/src/components/treeGrid/icon/icon-tree.png +0 -0
- package/src/components/treeGrid/index.js +0 -9
- package/src/components/treeGrid/style/treeGrid.scss +0 -277
- package/src/components/treeGrid/uses.js +0 -1178
- package/src/components/window/Window.vue +0 -329
- package/src/components/window/index.js +0 -7
- package/src/components/window/uses.js +0 -908
- package/src/directives/clickoutside.js +0 -90
- package/src/main.js +0 -120
- package/src/style/components/input.scss +0 -108
- package/src/style/functions.scss +0 -3
- package/src/style/index.scss +0 -6
- package/src/style/lib/fonts/EVUI.eot +0 -0
- package/src/style/lib/fonts/EVUI.svg +0 -293
- package/src/style/lib/fonts/EVUI.ttf +0 -0
- package/src/style/lib/fonts/EVUI.woff +0 -0
- package/src/style/lib/icon.css +0 -888
- package/src/style/mixins.scss +0 -94
- package/src/style/themes.scss +0 -69
- package/src/style/variables.scss +0 -22
|
@@ -1,691 +0,0 @@
|
|
|
1
|
-
import { throttle, debounce } from 'lodash-es';
|
|
2
|
-
|
|
3
|
-
const BRUSH_UPDATE_MODE = {
|
|
4
|
-
WHEEL: {
|
|
5
|
-
UP: 'MOVEUP_WHEEL',
|
|
6
|
-
DOWN: 'MOVEDOWN_WHEEL',
|
|
7
|
-
},
|
|
8
|
-
GRAB: {
|
|
9
|
-
UP: 'MOVEUP_GRAB',
|
|
10
|
-
DOWN: 'MOVEDOWN_GRAB',
|
|
11
|
-
},
|
|
12
|
-
BUTTON: {
|
|
13
|
-
INCREASE: 'INCREASE',
|
|
14
|
-
DECREASE: 'DECREASE',
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const BUTTON_TYPE = {
|
|
19
|
-
LEFT: 'leftX',
|
|
20
|
-
RIGHT: 'rightX',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default class EvChartBrush {
|
|
24
|
-
constructor(evChart, evChartData, evChartBrushOptions, brushIdx, evChartBrushRef) {
|
|
25
|
-
this.evChart = evChart;
|
|
26
|
-
this.evChartBrushOptions = evChartBrushOptions;
|
|
27
|
-
this.evChartBrushRef = evChartBrushRef;
|
|
28
|
-
this.evChartData = evChartData;
|
|
29
|
-
|
|
30
|
-
this.brushIdx = brushIdx;
|
|
31
|
-
if (evChartBrushOptions.value.useDebounce) {
|
|
32
|
-
this.debounceBrushIdx = { start: brushIdx.start, end: brushIdx.end };
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
init(isResize) {
|
|
37
|
-
if (this.brushIdx.start > this.brushIdx.end) {
|
|
38
|
-
this.removeBrushCanvas();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (this.evChartBrushRef?.value) {
|
|
43
|
-
const existedBrushCanvas = this.evChartBrushRef.value.querySelector('.brush-canvas');
|
|
44
|
-
|
|
45
|
-
if (!existedBrushCanvas) {
|
|
46
|
-
const brushCanvas = document.createElement('canvas');
|
|
47
|
-
|
|
48
|
-
brushCanvas.setAttribute('class', 'brush-canvas');
|
|
49
|
-
brushCanvas.setAttribute('style', 'display: block; z-index: 1;');
|
|
50
|
-
|
|
51
|
-
const evChartBrushContainer = this.evChartBrushRef.value.querySelector('.ev-chart-brush-container');
|
|
52
|
-
|
|
53
|
-
if (evChartBrushContainer) {
|
|
54
|
-
this.brushCanvas = brushCanvas;
|
|
55
|
-
evChartBrushContainer.appendChild(brushCanvas);
|
|
56
|
-
this.evChartBrushContainer = evChartBrushContainer;
|
|
57
|
-
|
|
58
|
-
this.drawBrushRect({ brushCanvas });
|
|
59
|
-
this.addEvent(brushCanvas);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
this.drawBrushRect({ brushCanvas: existedBrushCanvas, isResize });
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
drawBrushRect({ brushCanvas, isResize, isDebounce, mode, offsetX }) {
|
|
68
|
-
const { chartRect, labelOffset } = this.evChart;
|
|
69
|
-
if (!chartRect && !labelOffset) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const labelEndIdx = this.evChartData.value.labels.length - 1;
|
|
74
|
-
this.labelEndIdx = labelEndIdx;
|
|
75
|
-
|
|
76
|
-
const evChartRange = {
|
|
77
|
-
x1: chartRect.x1 + labelOffset.left,
|
|
78
|
-
x2: chartRect.x2 - labelOffset.right,
|
|
79
|
-
y1: chartRect.y1 + labelOffset.top,
|
|
80
|
-
y2: chartRect.y2 - labelOffset.bottom,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const canvasPosInfo = this.setCanvasWidthHeight(evChartRange, brushCanvas);
|
|
84
|
-
|
|
85
|
-
if (isResize && this.isEqualWidth) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (labelEndIdx >= 0) {
|
|
90
|
-
const brushPosInfo = this.setBrushXAndWidth(canvasPosInfo, offsetX, isDebounce, mode);
|
|
91
|
-
|
|
92
|
-
if (canvasPosInfo && brushPosInfo) {
|
|
93
|
-
this.drawBrush(canvasPosInfo, brushPosInfo, evChartRange, brushCanvas);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
setCanvasWidthHeight(evChartRange, brushCanvas) {
|
|
99
|
-
const brushButtonWidth = 6;
|
|
100
|
-
const brushCanvasWidth = evChartRange.x2 - evChartRange.x1 + brushButtonWidth;
|
|
101
|
-
const brushCanvasHeight = evChartRange.y2 - evChartRange.y1;
|
|
102
|
-
|
|
103
|
-
const axesXInterval = (evChartRange.x2 - evChartRange.x1) / this.labelEndIdx;
|
|
104
|
-
|
|
105
|
-
const pixelRatio = window.devicePixelRatio || 1;
|
|
106
|
-
|
|
107
|
-
this.isEqualWidth = brushCanvas.width === Math.floor(brushCanvasWidth * pixelRatio);
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
brushButtonWidth,
|
|
111
|
-
brushCanvasHeight,
|
|
112
|
-
brushCanvasWidth,
|
|
113
|
-
axesXInterval,
|
|
114
|
-
pixelRatio,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
setBrushXAndWidth(canvasPosInfo, offsetX = 0, isDebounce, mode) {
|
|
119
|
-
const {
|
|
120
|
-
brushButtonWidth,
|
|
121
|
-
brushCanvasWidth,
|
|
122
|
-
axesXInterval,
|
|
123
|
-
pixelRatio,
|
|
124
|
-
} = canvasPosInfo;
|
|
125
|
-
|
|
126
|
-
if (!isDebounce && this.debounceBrushIdx) {
|
|
127
|
-
this.debounceBrushIdx.start = this.brushIdx.start;
|
|
128
|
-
this.debounceBrushIdx.end = this.brushIdx.end;
|
|
129
|
-
}
|
|
130
|
-
const brushIdx = this.debounceBrushIdx ?? this.brushIdx;
|
|
131
|
-
|
|
132
|
-
switch (mode) {
|
|
133
|
-
case BRUSH_UPDATE_MODE.BUTTON.INCREASE:
|
|
134
|
-
case BRUSH_UPDATE_MODE.BUTTON.DECREASE:
|
|
135
|
-
this.brushRectWidth = brushCanvasWidth * pixelRatio;
|
|
136
|
-
|
|
137
|
-
if (this.curBrushButtonType === BUTTON_TYPE.LEFT) {
|
|
138
|
-
this.brushRectWidth = this.beforeBrushRectWidth
|
|
139
|
-
? this.beforeBrushRectWidth - offsetX : this.brushRectWidth - offsetX;
|
|
140
|
-
|
|
141
|
-
if (this.brushRectWidth <= brushButtonWidth) {
|
|
142
|
-
this.brushRectWidth = brushButtonWidth;
|
|
143
|
-
} else {
|
|
144
|
-
this.brushRectX = offsetX * pixelRatio;
|
|
145
|
-
this.beforeBrushRectX = this.brushRectX;
|
|
146
|
-
}
|
|
147
|
-
} else if (this.curBrushButtonType === BUTTON_TYPE.RIGHT) {
|
|
148
|
-
this.brushRectWidth = offsetX - this.beforeBrushRectX;
|
|
149
|
-
|
|
150
|
-
if (this.brushRectWidth <= brushButtonWidth) {
|
|
151
|
-
this.brushRectWidth = brushButtonWidth;
|
|
152
|
-
} else {
|
|
153
|
-
this.brushRectX = this.beforeBrushRectX;
|
|
154
|
-
this.beforeBrushRectWidth = this.brushRectWidth + this.brushRectX;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
break;
|
|
158
|
-
case BRUSH_UPDATE_MODE.GRAB.UP:
|
|
159
|
-
case BRUSH_UPDATE_MODE.GRAB.DOWN:
|
|
160
|
-
if (
|
|
161
|
-
(this.brushRectX <= 0 && mode === BRUSH_UPDATE_MODE.GRAB.DOWN)
|
|
162
|
-
|| (
|
|
163
|
-
this.brushRectX + this.brushRectWidth >= brushCanvasWidth
|
|
164
|
-
&& mode === BRUSH_UPDATE_MODE.GRAB.UP
|
|
165
|
-
)
|
|
166
|
-
) {
|
|
167
|
-
this.offsetXAndRectXInterval = null;
|
|
168
|
-
} else {
|
|
169
|
-
if (!this.offsetXAndRectXInterval) {
|
|
170
|
-
this.offsetXAndRectXInterval = offsetX - this.brushRectX;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
this.brushRectX = offsetX - this.offsetXAndRectXInterval;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
break;
|
|
177
|
-
default:
|
|
178
|
-
if (!offsetX) {
|
|
179
|
-
this.brushRectX = brushIdx.start * axesXInterval * pixelRatio;
|
|
180
|
-
this.brushRectWidth = (
|
|
181
|
-
brushCanvasWidth - (
|
|
182
|
-
this.labelEndIdx - (brushIdx.end - brushIdx.start)
|
|
183
|
-
) * axesXInterval
|
|
184
|
-
) * pixelRatio;
|
|
185
|
-
|
|
186
|
-
this.beforeBrushRectX = this.brushRectX;
|
|
187
|
-
this.beforeBrushRectWidth = this.brushRectWidth + this.brushRectX;
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
brushRectX: this.brushRectX,
|
|
194
|
-
brushRectWidth: this.brushRectWidth,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
drawBrush(canvasPosInfo, brushPosInfo, evChartRange, brushCanvas) {
|
|
199
|
-
const {
|
|
200
|
-
brushButtonWidth,
|
|
201
|
-
brushCanvasHeight,
|
|
202
|
-
brushCanvasWidth,
|
|
203
|
-
axesXInterval,
|
|
204
|
-
pixelRatio,
|
|
205
|
-
} = canvasPosInfo;
|
|
206
|
-
|
|
207
|
-
const {
|
|
208
|
-
brushRectX,
|
|
209
|
-
brushRectWidth,
|
|
210
|
-
} = brushPosInfo;
|
|
211
|
-
|
|
212
|
-
const {
|
|
213
|
-
height,
|
|
214
|
-
selection: {
|
|
215
|
-
fillColor,
|
|
216
|
-
opacity,
|
|
217
|
-
},
|
|
218
|
-
} = this.evChartBrushOptions.value;
|
|
219
|
-
|
|
220
|
-
const brushRectHeight = height - evChartRange.y1;
|
|
221
|
-
const brushButtonLeftXPos = brushRectX;
|
|
222
|
-
const brushButtonRightXPos = brushRectX + brushRectWidth;
|
|
223
|
-
|
|
224
|
-
if (!brushCanvas.style.position) {
|
|
225
|
-
brushCanvas.style.position = 'absolute';
|
|
226
|
-
brushCanvas.style.top = `${evChartRange.y1}px`;
|
|
227
|
-
brushCanvas.style.left = `${evChartRange.x1 - (brushButtonWidth / 2)}px`;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (!this.isEqualWidth) {
|
|
231
|
-
brushCanvas.width = (brushCanvasWidth * pixelRatio);
|
|
232
|
-
brushCanvas.style.width = `${brushCanvasWidth}px`;
|
|
233
|
-
brushCanvas.height = brushCanvasHeight * pixelRatio;
|
|
234
|
-
brushCanvas.style.height = `${brushCanvasHeight}px`;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const ctx = brushCanvas.getContext('2d');
|
|
238
|
-
|
|
239
|
-
ctx.clearRect(
|
|
240
|
-
0,
|
|
241
|
-
0,
|
|
242
|
-
brushCanvasWidth * pixelRatio,
|
|
243
|
-
brushCanvasHeight * pixelRatio,
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
ctx.fillStyle = fillColor;
|
|
247
|
-
ctx.globalAlpha = opacity;
|
|
248
|
-
ctx.fillRect(brushRectX, 0, brushRectWidth, brushRectHeight);
|
|
249
|
-
ctx.fillRect(brushButtonLeftXPos, 0, brushButtonWidth, brushRectHeight);
|
|
250
|
-
ctx.fillRect(brushButtonRightXPos - brushButtonWidth, 0, brushButtonWidth, brushRectHeight);
|
|
251
|
-
|
|
252
|
-
this.brushPosInfo = {
|
|
253
|
-
leftX: brushButtonLeftXPos / pixelRatio,
|
|
254
|
-
rightX: brushButtonRightXPos / pixelRatio,
|
|
255
|
-
buttonWidth: brushButtonWidth,
|
|
256
|
-
axesXInterval,
|
|
257
|
-
...canvasPosInfo,
|
|
258
|
-
...brushPosInfo,
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
addEvent() {
|
|
263
|
-
let mousePosition;
|
|
264
|
-
|
|
265
|
-
this.onMouseDown = (e) => {
|
|
266
|
-
e.preventDefault();
|
|
267
|
-
|
|
268
|
-
if (mousePosition.isInsideButton) {
|
|
269
|
-
this.clickBrushInsideX = -1;
|
|
270
|
-
} else if (mousePosition.isInsideBrush) {
|
|
271
|
-
this.clickBrushInsideX = e.offsetX;
|
|
272
|
-
} else if (mousePosition.isOutsideBrush) {
|
|
273
|
-
this.teleportBrush(e);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
const onMouseMove = (e) => {
|
|
278
|
-
if (this.clickBrushInsideX) {
|
|
279
|
-
this.mouseDownAndMove(e);
|
|
280
|
-
} else {
|
|
281
|
-
mousePosition = this.getMousePosition(e);
|
|
282
|
-
|
|
283
|
-
this.changeCursor(mousePosition);
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
this.onMouseMove = throttle(onMouseMove, 5);
|
|
287
|
-
|
|
288
|
-
this.onWheel = (e) => {
|
|
289
|
-
e.preventDefault();
|
|
290
|
-
|
|
291
|
-
const mode = e.deltaY > 0 ? BRUSH_UPDATE_MODE.WHEEL.DOWN : BRUSH_UPDATE_MODE.WHEEL.UP;
|
|
292
|
-
|
|
293
|
-
this.updateBrushIdx(mode);
|
|
294
|
-
|
|
295
|
-
if (this.debounceBrushIdx) {
|
|
296
|
-
this.drawBrushRect({
|
|
297
|
-
brushCanvas: this.brushCanvas,
|
|
298
|
-
isDebounce: true,
|
|
299
|
-
mode,
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
this.brushIdx.isUseScroll = true;
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
this.onMouseUp = () => {
|
|
307
|
-
this.initEventState();
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
this.onMouseLeave = () => {
|
|
311
|
-
if (this.clickBrushInsideX) {
|
|
312
|
-
this.initEventState();
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
const onWheelDebounce = () => {
|
|
317
|
-
this.initEventState();
|
|
318
|
-
};
|
|
319
|
-
this.onWheelDebounce = debounce(onWheelDebounce, 100);
|
|
320
|
-
|
|
321
|
-
this.setEventListener('addEventListener');
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
getMousePosition(e) {
|
|
325
|
-
const calDisToCurMouseX = xPos => Math.abs(this.brushPosInfo[xPos] - e.offsetX);
|
|
326
|
-
const buttonType = calDisToCurMouseX(BUTTON_TYPE.RIGHT) > calDisToCurMouseX(BUTTON_TYPE.LEFT)
|
|
327
|
-
? BUTTON_TYPE.LEFT : BUTTON_TYPE.RIGHT;
|
|
328
|
-
|
|
329
|
-
const isMoveRight = xPos => e.offsetX > this.brushPosInfo[xPos];
|
|
330
|
-
const isMoveLeft = xPos => e.offsetX < this.brushPosInfo[xPos];
|
|
331
|
-
|
|
332
|
-
const isOutsideBrush = isMoveLeft(BUTTON_TYPE.LEFT) || isMoveRight(BUTTON_TYPE.RIGHT);
|
|
333
|
-
const isInsideBrush = isMoveRight(BUTTON_TYPE.LEFT) && isMoveLeft(BUTTON_TYPE.RIGHT);
|
|
334
|
-
|
|
335
|
-
const isInsideButton = e.offsetX + this.brushPosInfo.buttonWidth
|
|
336
|
-
>= this.brushPosInfo[buttonType]
|
|
337
|
-
&& e.offsetX - this.brushPosInfo.buttonWidth
|
|
338
|
-
<= this.brushPosInfo[buttonType];
|
|
339
|
-
|
|
340
|
-
this.curBrushButtonType = isInsideButton && buttonType;
|
|
341
|
-
|
|
342
|
-
return {
|
|
343
|
-
isInsideButton,
|
|
344
|
-
isInsideBrush,
|
|
345
|
-
isOutsideBrush,
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
destroy() {
|
|
350
|
-
if (this.brushCanvas) {
|
|
351
|
-
this.setEventListener('removeEventListener');
|
|
352
|
-
|
|
353
|
-
this.brushCanvas = null;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (this.evChartBrushContainer) {
|
|
357
|
-
const evChartBrushContainer = this.evChartBrushContainer;
|
|
358
|
-
|
|
359
|
-
while (evChartBrushContainer.hasChildNodes()) {
|
|
360
|
-
evChartBrushContainer.removeChild(evChartBrushContainer.firstChild);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* @param {string} type eventListener setting type.
|
|
367
|
-
*
|
|
368
|
-
* @returns {undefined}
|
|
369
|
-
*/
|
|
370
|
-
setEventListener(type) {
|
|
371
|
-
this.brushCanvas[type]('mousemove', this.onMouseMove);
|
|
372
|
-
this.brushCanvas[type]('mousedown', this.onMouseDown);
|
|
373
|
-
this.brushCanvas[type]('mouseup', this.onMouseUp);
|
|
374
|
-
this.brushCanvas[type]('mouseleave', this.onMouseLeave);
|
|
375
|
-
|
|
376
|
-
if (this.evChartBrushOptions.value.useWheelMove) {
|
|
377
|
-
this.brushCanvas[type]('wheel', this.onWheel);
|
|
378
|
-
this.brushCanvas[type]('wheel', this.onWheelDebounce);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
removeBrushWrapper() {
|
|
383
|
-
if (this.evChartBrushRef.value) {
|
|
384
|
-
const evChartBrushWrapper = this.evChartBrushRef.value.querySelector('.ev-chart-brush-wrapper');
|
|
385
|
-
|
|
386
|
-
if (evChartBrushWrapper) {
|
|
387
|
-
this.evChartBrushRef.value.removeChild(evChartBrushWrapper);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
removeBrushCanvas() {
|
|
393
|
-
if (this.evChartBrushContainer) {
|
|
394
|
-
const brushCanvas = this.evChartBrushContainer.querySelector('.brush-canvas');
|
|
395
|
-
|
|
396
|
-
if (brushCanvas) {
|
|
397
|
-
this.evChartBrushContainer.removeChild(brushCanvas);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
teleportBrush(e) {
|
|
403
|
-
const brushIdx = this.debounceBrushIdx ?? this.brushIdx;
|
|
404
|
-
|
|
405
|
-
const middle = (brushIdx.end - brushIdx.start) / 2;
|
|
406
|
-
let left;
|
|
407
|
-
let right;
|
|
408
|
-
let clickIdx;
|
|
409
|
-
|
|
410
|
-
if (middle > 0.5) {
|
|
411
|
-
if ((brushIdx.end - brushIdx.start) % 2 === 0) {
|
|
412
|
-
clickIdx = Math.round(e.offsetX / this.brushPosInfo.axesXInterval);
|
|
413
|
-
|
|
414
|
-
left = Math.ceil(middle);
|
|
415
|
-
right = Math.floor(middle);
|
|
416
|
-
} else {
|
|
417
|
-
clickIdx = Math.ceil(e.offsetX / this.brushPosInfo.axesXInterval);
|
|
418
|
-
|
|
419
|
-
left = Math.ceil(middle);
|
|
420
|
-
right = Math.floor(middle);
|
|
421
|
-
}
|
|
422
|
-
} else {
|
|
423
|
-
clickIdx = Math.floor(e.offsetX / this.brushPosInfo.axesXInterval);
|
|
424
|
-
|
|
425
|
-
if (
|
|
426
|
-
e.offsetX - (clickIdx * this.brushPosInfo.axesXInterval)
|
|
427
|
-
> (this.brushPosInfo.axesXInterval / 2)
|
|
428
|
-
) {
|
|
429
|
-
left = Math.floor(middle);
|
|
430
|
-
right = Math.ceil(middle);
|
|
431
|
-
} else {
|
|
432
|
-
left = Math.ceil(middle);
|
|
433
|
-
right = Math.floor(middle);
|
|
434
|
-
|
|
435
|
-
if (middle < 1) {
|
|
436
|
-
clickIdx += 1;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
if (clickIdx - left <= 0) {
|
|
442
|
-
brushIdx.start = 0;
|
|
443
|
-
brushIdx.end = right + left;
|
|
444
|
-
} else if (clickIdx + right >= this.labelEndIdx) {
|
|
445
|
-
brushIdx.start = this.labelEndIdx - right - left;
|
|
446
|
-
brushIdx.end = this.labelEndIdx;
|
|
447
|
-
} else {
|
|
448
|
-
brushIdx.start = clickIdx - left;
|
|
449
|
-
brushIdx.end = clickIdx + right;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
this.brushIdx.isUseScroll = true;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
changeCursor(mousePosition) {
|
|
456
|
-
if (mousePosition.isOutsideBrush) {
|
|
457
|
-
this.brushCanvas.style.cursor = 'pointer';
|
|
458
|
-
} else if (mousePosition.isInsideBrush) {
|
|
459
|
-
if (mousePosition.isInsideButton) {
|
|
460
|
-
this.brushCanvas.style.cursor = 'ew-resize';
|
|
461
|
-
} else {
|
|
462
|
-
this.brushCanvas.style.cursor = 'grab';
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
mouseDownAndMove(e) {
|
|
468
|
-
const moveSensitive = this.debounceBrushIdx ? 0 : (this.brushPosInfo.axesXInterval / 3);
|
|
469
|
-
let mode;
|
|
470
|
-
|
|
471
|
-
if (e.offsetX > this.beforeMouseXPos) {
|
|
472
|
-
// 오른쪽 이동
|
|
473
|
-
if (this.clickBrushInsideX > 0) {
|
|
474
|
-
if (this.clickBrushInsideX < e.offsetX - moveSensitive) {
|
|
475
|
-
mode = BRUSH_UPDATE_MODE.GRAB.UP;
|
|
476
|
-
|
|
477
|
-
this.isUseBrushGrab = true;
|
|
478
|
-
this.brushIdx.isUseScroll = true;
|
|
479
|
-
this.clickBrushInsideX = e.offsetX + moveSensitive;
|
|
480
|
-
}
|
|
481
|
-
} else {
|
|
482
|
-
const isMoveRight = e.offsetX - this.brushPosInfo[this.curBrushButtonType]
|
|
483
|
-
> moveSensitive;
|
|
484
|
-
|
|
485
|
-
if (isMoveRight) {
|
|
486
|
-
mode = this.curBrushButtonType === BUTTON_TYPE.LEFT
|
|
487
|
-
? BRUSH_UPDATE_MODE.BUTTON.DECREASE : BRUSH_UPDATE_MODE.BUTTON.INCREASE;
|
|
488
|
-
|
|
489
|
-
this.brushIdx.isUseButton = true;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
} else if (e.offsetX < this.beforeMouseXPos) {
|
|
493
|
-
// 왼쪽 이동
|
|
494
|
-
if (this.clickBrushInsideX > 0) {
|
|
495
|
-
if (this.clickBrushInsideX > e.offsetX + moveSensitive) {
|
|
496
|
-
mode = BRUSH_UPDATE_MODE.GRAB.DOWN;
|
|
497
|
-
|
|
498
|
-
this.isUseBrushGrab = true;
|
|
499
|
-
this.brushIdx.isUseScroll = true;
|
|
500
|
-
this.clickBrushInsideX = e.offsetX - moveSensitive;
|
|
501
|
-
}
|
|
502
|
-
} else {
|
|
503
|
-
const isMoveLeft = this.brushPosInfo[this.curBrushButtonType] - e.offsetX
|
|
504
|
-
> moveSensitive;
|
|
505
|
-
|
|
506
|
-
if (isMoveLeft) {
|
|
507
|
-
mode = this.curBrushButtonType === BUTTON_TYPE.LEFT
|
|
508
|
-
? BRUSH_UPDATE_MODE.BUTTON.INCREASE : BRUSH_UPDATE_MODE.BUTTON.DECREASE;
|
|
509
|
-
|
|
510
|
-
this.brushIdx.isUseButton = true;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
if (this.debounceBrushIdx) {
|
|
516
|
-
this.drawBrushRect({
|
|
517
|
-
brushCanvas: this.brushCanvas,
|
|
518
|
-
isDebounce: true,
|
|
519
|
-
mode,
|
|
520
|
-
offsetX: e.offsetX,
|
|
521
|
-
});
|
|
522
|
-
} else {
|
|
523
|
-
this.updateBrushIdx(mode);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
this.beforeMouseXPos = e.offsetX;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* @param {string} mode determines how to update the brush index value.
|
|
531
|
-
*
|
|
532
|
-
* @returns {undefined}
|
|
533
|
-
*/
|
|
534
|
-
updateBrushIdx(mode) {
|
|
535
|
-
const brushIdx = this.debounceBrushIdx ?? this.brushIdx;
|
|
536
|
-
|
|
537
|
-
switch (mode) {
|
|
538
|
-
case BRUSH_UPDATE_MODE.WHEEL.UP:
|
|
539
|
-
case BRUSH_UPDATE_MODE.GRAB.UP:
|
|
540
|
-
if (brushIdx.end >= this.labelEndIdx) {
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
brushIdx.start += 1;
|
|
545
|
-
brushIdx.end += 1;
|
|
546
|
-
|
|
547
|
-
break;
|
|
548
|
-
case BRUSH_UPDATE_MODE.WHEEL.DOWN:
|
|
549
|
-
case BRUSH_UPDATE_MODE.GRAB.DOWN:
|
|
550
|
-
if (brushIdx.start <= 0) {
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
brushIdx.start -= 1;
|
|
555
|
-
brushIdx.end -= 1;
|
|
556
|
-
|
|
557
|
-
break;
|
|
558
|
-
case BRUSH_UPDATE_MODE.BUTTON.INCREASE:
|
|
559
|
-
if (this.curBrushButtonType === BUTTON_TYPE.LEFT) {
|
|
560
|
-
if (!brushIdx.start) {
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
brushIdx.start -= 1;
|
|
565
|
-
} else {
|
|
566
|
-
if (brushIdx.end === this.labelEndIdx) {
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
brushIdx.end += 1;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
break;
|
|
574
|
-
case BRUSH_UPDATE_MODE.BUTTON.DECREASE:
|
|
575
|
-
if (brushIdx.start === brushIdx.end - 1) {
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
if (this.curBrushButtonType === BUTTON_TYPE.LEFT) {
|
|
580
|
-
brushIdx.start += 1;
|
|
581
|
-
} else {
|
|
582
|
-
brushIdx.end -= 1;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
break;
|
|
586
|
-
default:
|
|
587
|
-
break;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
updateBrushIdxUseXPos() {
|
|
592
|
-
if (!this.debounceBrushIdx) {
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
const calculateBrushIdxByPos = () => {
|
|
597
|
-
let brushStartIdx;
|
|
598
|
-
let brushEndIdx;
|
|
599
|
-
if (this.brushPosInfo) {
|
|
600
|
-
const {
|
|
601
|
-
brushRectX,
|
|
602
|
-
brushRectWidth,
|
|
603
|
-
brushCanvasWidth,
|
|
604
|
-
axesXInterval,
|
|
605
|
-
} = this.brushPosInfo;
|
|
606
|
-
|
|
607
|
-
if (this.brushIdx.isUseButton || this.isUseBrushGrab) {
|
|
608
|
-
brushStartIdx = brushRectX / axesXInterval;
|
|
609
|
-
brushEndIdx = this.labelEndIdx - (
|
|
610
|
-
(brushCanvasWidth - (brushRectX + brushRectWidth)) / axesXInterval
|
|
611
|
-
);
|
|
612
|
-
|
|
613
|
-
if (this.curBrushButtonType === BUTTON_TYPE.LEFT) {
|
|
614
|
-
brushStartIdx = Math.round(brushStartIdx);
|
|
615
|
-
brushEndIdx = this.brushIdx.end;
|
|
616
|
-
|
|
617
|
-
if (brushStartIdx === brushEndIdx) {
|
|
618
|
-
brushStartIdx -= 1;
|
|
619
|
-
}
|
|
620
|
-
} else if (this.curBrushButtonType === BUTTON_TYPE.RIGHT) {
|
|
621
|
-
brushStartIdx = this.brushIdx.start;
|
|
622
|
-
brushEndIdx = Math.round(brushEndIdx);
|
|
623
|
-
|
|
624
|
-
if (brushStartIdx === brushEndIdx) {
|
|
625
|
-
brushEndIdx += 1;
|
|
626
|
-
}
|
|
627
|
-
} else {
|
|
628
|
-
brushStartIdx = Math.round(brushStartIdx);
|
|
629
|
-
brushEndIdx = Math.round(brushEndIdx);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
if (brushEndIdx > this.labelEndIdx) {
|
|
633
|
-
const excessIdx = brushEndIdx - this.labelEndIdx;
|
|
634
|
-
|
|
635
|
-
brushStartIdx -= excessIdx;
|
|
636
|
-
brushEndIdx -= excessIdx;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
if (brushStartIdx < 0) {
|
|
640
|
-
const excessIdx = Math.abs(brushStartIdx);
|
|
641
|
-
|
|
642
|
-
brushStartIdx = 0;
|
|
643
|
-
brushEndIdx += excessIdx;
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
return {
|
|
648
|
-
brushStartIdx,
|
|
649
|
-
brushEndIdx,
|
|
650
|
-
};
|
|
651
|
-
};
|
|
652
|
-
|
|
653
|
-
const {
|
|
654
|
-
brushStartIdx,
|
|
655
|
-
brushEndIdx,
|
|
656
|
-
} = calculateBrushIdxByPos();
|
|
657
|
-
|
|
658
|
-
if (this.brushIdx.start === brushStartIdx && this.brushIdx.end === brushEndIdx) {
|
|
659
|
-
this.drawBrushRect({ brushCanvas: this.brushCanvas });
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
this.brushIdx.start = brushStartIdx ?? this.debounceBrushIdx.start;
|
|
663
|
-
this.brushIdx.end = brushEndIdx ?? this.debounceBrushIdx.end;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* @param {boolean} updateBrushIdxUseXPos to initialize state after update brush index value
|
|
668
|
-
*
|
|
669
|
-
* @returns {undefined}
|
|
670
|
-
*/
|
|
671
|
-
initEventState() {
|
|
672
|
-
const promise = new Promise((resolve) => {
|
|
673
|
-
this.updateBrushIdxUseXPos();
|
|
674
|
-
|
|
675
|
-
resolve(true);
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
promise.then((isUpdateBrushIdx) => {
|
|
679
|
-
if (isUpdateBrushIdx) {
|
|
680
|
-
this.clickBrushInsideX = null;
|
|
681
|
-
this.beforeMouseXPos = null;
|
|
682
|
-
this.curBrushButtonType = null;
|
|
683
|
-
|
|
684
|
-
this.isUseBrushGrab = false;
|
|
685
|
-
this.offsetXAndRectXInterval = null;
|
|
686
|
-
this.brushIdx.isUseButton = false;
|
|
687
|
-
this.brushIdx.isUseScroll = false;
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
useWheelMove: true,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
17
|
-
export const useBrushModel = () => {
|
|
18
|
-
const getNormalizedBrushOptions = options => defaultsDeep({}, options, DEFAULT_OPTIONS);
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
getNormalizedBrushOptions,
|
|
22
|
-
};
|
|
23
|
-
};
|