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,1170 +0,0 @@
|
|
|
1
|
-
import { mobileCheck } from '@/common/utils';
|
|
2
|
-
import Model from './model';
|
|
3
|
-
import TimeScale from './scale/scale.time';
|
|
4
|
-
import LinearScale from './scale/scale.linear';
|
|
5
|
-
import LogarithmicScale from './scale/scale.logarithmic';
|
|
6
|
-
import StepScale from './scale/scale.step';
|
|
7
|
-
import TimeCategoryScale from './scale/scale.time.category';
|
|
8
|
-
import Title from './plugins/plugins.title';
|
|
9
|
-
import Legend from './plugins/plugins.legend';
|
|
10
|
-
import GradientLegend from './plugins/plugins.legend.gradient';
|
|
11
|
-
import Scrollbar from './plugins/plugins.scrollbar';
|
|
12
|
-
import Interaction from './plugins/plugins.interaction';
|
|
13
|
-
import Tooltip from './plugins/plugins.tooltip';
|
|
14
|
-
import Pie from './plugins/plugins.pie';
|
|
15
|
-
import Tip from './element/element.tip';
|
|
16
|
-
|
|
17
|
-
class EvChart {
|
|
18
|
-
constructor(
|
|
19
|
-
target,
|
|
20
|
-
data,
|
|
21
|
-
options,
|
|
22
|
-
listeners,
|
|
23
|
-
defaultSelectItemInfo,
|
|
24
|
-
defaultSelectInfo,
|
|
25
|
-
brushSeries,
|
|
26
|
-
) {
|
|
27
|
-
Object.keys(Model).forEach(key => Object.assign(this, Model[key]));
|
|
28
|
-
|
|
29
|
-
if (!options.brush) {
|
|
30
|
-
Object.assign(this, Tooltip);
|
|
31
|
-
Object.assign(this, Interaction);
|
|
32
|
-
Object.assign(this, Tip);
|
|
33
|
-
Object.assign(this, Legend);
|
|
34
|
-
Object.assign(this, Pie);
|
|
35
|
-
Object.assign(this, Title);
|
|
36
|
-
Object.assign(this, Scrollbar);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (options.type === 'heatMap' && options.legend.type === 'gradient') {
|
|
40
|
-
Object.assign(this, GradientLegend);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
this.isMobile = mobileCheck();
|
|
44
|
-
this.brushSeries = brushSeries;
|
|
45
|
-
this.target = target;
|
|
46
|
-
this.data = data;
|
|
47
|
-
this.options = options;
|
|
48
|
-
this.listeners = listeners;
|
|
49
|
-
|
|
50
|
-
this.wrapperDOM = document.createElement('div');
|
|
51
|
-
this.wrapperDOM.className = options.brush ? 'ev-chart-brush-wrapper' : 'ev-chart-wrapper';
|
|
52
|
-
this.chartDOM = document.createElement('div');
|
|
53
|
-
this.chartDOM.className = options.brush ? 'ev-chart-brush-container' : 'ev-chart-container';
|
|
54
|
-
this.wrapperDOM.appendChild(this.chartDOM);
|
|
55
|
-
this.target.appendChild(this.wrapperDOM);
|
|
56
|
-
|
|
57
|
-
this.displayCanvas = document.createElement('canvas');
|
|
58
|
-
this.displayCanvas.setAttribute('style', 'display: block;');
|
|
59
|
-
this.displayCtx = this.displayCanvas.getContext('2d');
|
|
60
|
-
this.bufferCanvas = document.createElement('canvas');
|
|
61
|
-
this.bufferCanvas.setAttribute('style', 'display: block;');
|
|
62
|
-
this.bufferCtx = this.bufferCanvas.getContext('2d');
|
|
63
|
-
|
|
64
|
-
this.pixelRatio = window.devicePixelRatio || 1;
|
|
65
|
-
this.oldPixelRatio = this.pixelRatio;
|
|
66
|
-
|
|
67
|
-
this.chartDOM.appendChild(this.displayCanvas);
|
|
68
|
-
|
|
69
|
-
if (!options.brush) {
|
|
70
|
-
this.overlayCanvas = document.createElement('canvas');
|
|
71
|
-
this.overlayCanvas.setAttribute('style', 'display: block; z-index: 2;');
|
|
72
|
-
this.overlayCanvas.setAttribute('class', 'overlay-canvas');
|
|
73
|
-
this.overlayCtx = this.overlayCanvas.getContext('2d');
|
|
74
|
-
|
|
75
|
-
this.chartDOM.appendChild(this.overlayCanvas);
|
|
76
|
-
|
|
77
|
-
this.overlayCanvas.style.position = 'absolute';
|
|
78
|
-
this.overlayCanvas.style.top = '0px';
|
|
79
|
-
this.overlayCanvas.style.left = '0px';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.isInitLegend = false;
|
|
84
|
-
this.isInitTitle = false;
|
|
85
|
-
this.isInit = false;
|
|
86
|
-
this.scrollbar = {
|
|
87
|
-
x: { isInit: false },
|
|
88
|
-
y: { isInit: false },
|
|
89
|
-
};
|
|
90
|
-
this.seriesList = {};
|
|
91
|
-
this.lastTip = { pos: null, value: null };
|
|
92
|
-
this.seriesInfo = {
|
|
93
|
-
charts: { pie: [], bar: [], line: [], scatter: [], heatMap: [] },
|
|
94
|
-
count: 0,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
this.defaultSelectItemInfo = defaultSelectItemInfo;
|
|
98
|
-
this.defaultSelectInfo = defaultSelectInfo;
|
|
99
|
-
|
|
100
|
-
this.legendHover = null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Initialize chart object
|
|
105
|
-
*
|
|
106
|
-
* @returns {undefined}
|
|
107
|
-
*/
|
|
108
|
-
init() {
|
|
109
|
-
const { series, data, labels, groups } = this.data;
|
|
110
|
-
const { type, axesX, axesY, tooltip, horizontal, realTimeScatter } = this.options;
|
|
111
|
-
|
|
112
|
-
this.createSeriesSet(series, type, horizontal, groups);
|
|
113
|
-
if (groups.length) {
|
|
114
|
-
this.addGroupInfo(groups);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (realTimeScatter?.use) {
|
|
118
|
-
this.dataSet = {};
|
|
119
|
-
this.createRealTimeScatterDataSet(data);
|
|
120
|
-
} else {
|
|
121
|
-
this.createDataSet(data, labels);
|
|
122
|
-
}
|
|
123
|
-
this.minMax = this.getStoreMinMax();
|
|
124
|
-
|
|
125
|
-
this.initRect();
|
|
126
|
-
|
|
127
|
-
this.axesX = this.createAxes('x', axesX);
|
|
128
|
-
this.axesY = this.createAxes('y', axesY);
|
|
129
|
-
|
|
130
|
-
this.initDefaultSelectInfo();
|
|
131
|
-
|
|
132
|
-
this.drawChart();
|
|
133
|
-
|
|
134
|
-
if (tooltip.use && !this.isInitTooltip) {
|
|
135
|
-
this.createTooltipDOM();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
this.createEventFunctions?.();
|
|
139
|
-
this.isInit = true;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Initialize chart rectangle
|
|
144
|
-
*
|
|
145
|
-
* @returns {undefined}
|
|
146
|
-
*/
|
|
147
|
-
initRect() {
|
|
148
|
-
const opt = this.options;
|
|
149
|
-
if (opt.title.show) {
|
|
150
|
-
if (!this.isInitTitle) {
|
|
151
|
-
this.initTitle();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this.showTitle();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (opt.legend.show) {
|
|
158
|
-
if (!this.isInitLegend) {
|
|
159
|
-
this.initLegend();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
this.setLegendPosition();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (opt.axesX?.[0]?.scrollbar?.use || opt.axesY?.[0]?.scrollbar?.use) {
|
|
166
|
-
this.initScrollbar();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
this.chartRect = this.getChartRect();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
drawSyncedIndicator({ horizontal, label, mousePosition }) {
|
|
173
|
-
this.drawSyncedIndicator({ horizontal, label, mousePosition });
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
adjustXAndYAxisWidth() {
|
|
177
|
-
// fitWidth(maxWidth에 넘을 시 말줄임표 들어가는 기능)을 사용중인 step Axis인 경우에는 적용 제외
|
|
178
|
-
const isStepXAxisUseFitWidth = this.options.axesX?.some(axisX => axisX.type === 'step' && axisX.labelStyle?.fitWidth);
|
|
179
|
-
const isStepYAxisUseFitWidth = this.options.axesY?.some(axisY => axisY.type === 'step' && axisY.labelStyle?.fitWidth);
|
|
180
|
-
|
|
181
|
-
const getNotFormattedLabels = (axesSteps) => {
|
|
182
|
-
const { interval, graphMin, graphMax, steps = 0 } = axesSteps ?? {};
|
|
183
|
-
let result = [];
|
|
184
|
-
|
|
185
|
-
if (interval) {
|
|
186
|
-
result = Array.from({ length: steps }, (_, i) => graphMin + i * interval);
|
|
187
|
-
result.push(graphMax);
|
|
188
|
-
} else {
|
|
189
|
-
const { labels } = this.data;
|
|
190
|
-
result = labels?.y ?? labels ?? [];
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return result;
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
const notFormattedXLabels = getNotFormattedLabels(this.axesSteps?.x[0]);
|
|
197
|
-
const notFormattedYLabels = getNotFormattedLabels(this.axesSteps?.y[0]);
|
|
198
|
-
|
|
199
|
-
const xMaxWidth = this.axesX[0]?.getLabelWidthHasMaxLength(notFormattedXLabels);
|
|
200
|
-
const yMaxWidth = this.axesY[0]?.getLabelWidthHasMaxLength(notFormattedYLabels);
|
|
201
|
-
|
|
202
|
-
const adjustedRange = {
|
|
203
|
-
x: !isStepXAxisUseFitWidth ? this.axesRange?.x?.map(value => ({
|
|
204
|
-
...value,
|
|
205
|
-
size: {
|
|
206
|
-
width: Math.max(xMaxWidth, value.size.width),
|
|
207
|
-
height: value.size.height,
|
|
208
|
-
},
|
|
209
|
-
})) : this.axesRange?.x,
|
|
210
|
-
y: !isStepYAxisUseFitWidth ? this.axesRange?.y?.map(value => ({
|
|
211
|
-
...value,
|
|
212
|
-
size: {
|
|
213
|
-
width: Math.max(yMaxWidth, value.size.width),
|
|
214
|
-
height: value.size.height,
|
|
215
|
-
},
|
|
216
|
-
})) : this.axesRange?.y,
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
this.axesRange = adjustedRange;
|
|
220
|
-
this.labelOffset = this.getLabelOffset(adjustedRange);
|
|
221
|
-
this.labelRange = this.getAxesLabelRange();
|
|
222
|
-
this.axesSteps = this.calculateSteps();
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* To draw canvas chart, it processes several sequential jobs
|
|
227
|
-
* @param {any} [hitInfo=undefined] from mousemove callback (object or object[] of undefined)
|
|
228
|
-
*
|
|
229
|
-
* @returns {undefined}
|
|
230
|
-
*/
|
|
231
|
-
drawChart(hitInfo) {
|
|
232
|
-
this.initScale();
|
|
233
|
-
|
|
234
|
-
this.axesRange = this.getAxesRange();
|
|
235
|
-
this.labelOffset = this.getLabelOffset();
|
|
236
|
-
this.labelRange = this.getAxesLabelRange();
|
|
237
|
-
this.axesSteps = this.calculateSteps();
|
|
238
|
-
|
|
239
|
-
this.adjustXAndYAxisWidth();
|
|
240
|
-
|
|
241
|
-
this.drawAxis(hitInfo);
|
|
242
|
-
this.drawSeries(hitInfo);
|
|
243
|
-
|
|
244
|
-
if (this.scrollbar?.x?.use || this.scrollbar?.y?.use) {
|
|
245
|
-
this.initScrollbar();
|
|
246
|
-
this.updateScrollbarPosition();
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
this.drawTip();
|
|
250
|
-
|
|
251
|
-
if (
|
|
252
|
-
this.bufferCanvas
|
|
253
|
-
&& this.bufferCanvas?.width > 1
|
|
254
|
-
&& this.bufferCanvas?.height > 1
|
|
255
|
-
) {
|
|
256
|
-
this.displayCtx.drawImage(this.bufferCanvas, 0, 0);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Collect duplicate point keys for scatter overlap detection
|
|
262
|
-
* @param {Map<string, string>} duple
|
|
263
|
-
* @param {string[]} chartTypeSet
|
|
264
|
-
*
|
|
265
|
-
* @returns {undefined}
|
|
266
|
-
*/
|
|
267
|
-
collectDuplicatePoints(duple, chartTypeSet) {
|
|
268
|
-
const isReverseOrder = !!this.options.seriesReverse;
|
|
269
|
-
for (
|
|
270
|
-
let jx = isReverseOrder ? chartTypeSet.length - 1 : 0;
|
|
271
|
-
isReverseOrder ? jx >= 0 : jx < chartTypeSet.length;
|
|
272
|
-
isReverseOrder ? jx-- : jx++
|
|
273
|
-
) {
|
|
274
|
-
const series = this.seriesList[chartTypeSet[jx]];
|
|
275
|
-
const shouldInclude = !!series?.show;
|
|
276
|
-
if (shouldInclude) {
|
|
277
|
-
if (this.options.realTimeScatter?.use) {
|
|
278
|
-
const seriesDatas = series.data[series.sId]?.dataGroup;
|
|
279
|
-
for (let i = 0; i < seriesDatas.length; i++) {
|
|
280
|
-
const dataItems = seriesDatas[i]?.data || [];
|
|
281
|
-
for (let j = 0; j < dataItems.length; j++) {
|
|
282
|
-
const item = dataItems[j];
|
|
283
|
-
duple.set(`${item.x}${item.y}`, series.sId);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
} else {
|
|
287
|
-
const seriesDatas = this.data.data[chartTypeSet[jx]] ?? [];
|
|
288
|
-
for (let i = 0; i < seriesDatas.length; i++) {
|
|
289
|
-
const item = seriesDatas[i];
|
|
290
|
-
duple.set(`${item.x}${item.y}`, series.sId);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Draw each series
|
|
299
|
-
* @param {any} [hitInfo=undefined] legend mouseover callback (object or undefined)
|
|
300
|
-
*
|
|
301
|
-
* @returns {undefined}
|
|
302
|
-
*/
|
|
303
|
-
drawSeries(hitInfo) {
|
|
304
|
-
const {
|
|
305
|
-
maxTip,
|
|
306
|
-
selectLabel,
|
|
307
|
-
selectItem,
|
|
308
|
-
selectSeries,
|
|
309
|
-
brush,
|
|
310
|
-
displayOverflow,
|
|
311
|
-
} = this.options;
|
|
312
|
-
|
|
313
|
-
const opt = {
|
|
314
|
-
ctx: this.bufferCtx,
|
|
315
|
-
chartRect: this.chartRect,
|
|
316
|
-
labelOffset: this.labelOffset,
|
|
317
|
-
axesSteps: this.axesSteps,
|
|
318
|
-
maxTipOpt: { background: maxTip.background, color: maxTip.color },
|
|
319
|
-
selectLabel: { option: selectLabel, selected: this.defaultSelectInfo },
|
|
320
|
-
selectSeries: { option: selectSeries, selected: this.defaultSelectInfo },
|
|
321
|
-
selectItem: { option: selectItem, selected: this.defaultSelectItemInfo },
|
|
322
|
-
overlayCtx: this.overlayCtx,
|
|
323
|
-
isBrush: !!brush,
|
|
324
|
-
displayOverflow,
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
let showIndex = 0;
|
|
328
|
-
let showSeriesCount = 0;
|
|
329
|
-
|
|
330
|
-
this.seriesInfo.charts.bar.forEach((series) => {
|
|
331
|
-
if (this.seriesList[series].show) {
|
|
332
|
-
showSeriesCount++;
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* new Map<`${x}${y}`, seriesID>
|
|
338
|
-
*/
|
|
339
|
-
const duple = new Map();
|
|
340
|
-
|
|
341
|
-
const chartKeys = Object.keys(this.seriesInfo.charts);
|
|
342
|
-
|
|
343
|
-
for (let ix = 0; ix < chartKeys.length; ix++) {
|
|
344
|
-
const chartType = chartKeys[ix];
|
|
345
|
-
const chartTypeSet = this.seriesInfo.charts[chartType];
|
|
346
|
-
|
|
347
|
-
if (chartType === 'scatter' && this.options.coordinateDedupe) {
|
|
348
|
-
this.collectDuplicatePoints(duple, chartTypeSet);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
for (let jx = 0; jx < chartTypeSet.length; jx++) {
|
|
352
|
-
let series = this.seriesList[chartTypeSet[jx]];
|
|
353
|
-
|
|
354
|
-
switch (chartType) {
|
|
355
|
-
case 'line': {
|
|
356
|
-
const legendHitInfo = hitInfo?.legend;
|
|
357
|
-
|
|
358
|
-
series.draw({
|
|
359
|
-
legendHitInfo,
|
|
360
|
-
...opt,
|
|
361
|
-
});
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
case 'heatMap': {
|
|
365
|
-
const legendHitInfo = hitInfo?.legend;
|
|
366
|
-
|
|
367
|
-
series.draw({
|
|
368
|
-
legendHitInfo,
|
|
369
|
-
...opt,
|
|
370
|
-
});
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
case 'bar': {
|
|
374
|
-
const legendHitInfo = hitInfo?.legend;
|
|
375
|
-
const { thickness, cPadRatio, borderRadius } = this.options;
|
|
376
|
-
|
|
377
|
-
series.draw({
|
|
378
|
-
thickness,
|
|
379
|
-
cPadRatio,
|
|
380
|
-
borderRadius,
|
|
381
|
-
showSeriesCount,
|
|
382
|
-
showIndex,
|
|
383
|
-
legendHitInfo,
|
|
384
|
-
...opt,
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
if (series.show) {
|
|
388
|
-
showIndex++;
|
|
389
|
-
}
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
case 'pie': {
|
|
393
|
-
const selectInfo = this.lastHitInfo ?? { sId: this.defaultSelectItemInfo?.seriesID };
|
|
394
|
-
const legendHitInfo = hitInfo?.legend;
|
|
395
|
-
|
|
396
|
-
if (this.options.sunburst) {
|
|
397
|
-
this.drawSunburst({
|
|
398
|
-
selectInfo,
|
|
399
|
-
legendHitInfo,
|
|
400
|
-
});
|
|
401
|
-
} else {
|
|
402
|
-
this.drawPie({
|
|
403
|
-
selectInfo,
|
|
404
|
-
legendHitInfo,
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (this.options.doughnutHoleSize > 0) {
|
|
409
|
-
this.drawDoughnutHole();
|
|
410
|
-
}
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
case 'scatter': {
|
|
414
|
-
const legendHitInfo = hitInfo?.legend;
|
|
415
|
-
|
|
416
|
-
let selectInfo;
|
|
417
|
-
if (selectItem.use && selectItem.useSeriesOpacity) {
|
|
418
|
-
const lastHitInfo = this.lastHitInfo;
|
|
419
|
-
const defaultSelectInfo = this.defaultSelectItemInfo;
|
|
420
|
-
|
|
421
|
-
if (lastHitInfo?.maxIndex || lastHitInfo?.maxIndex === 0) {
|
|
422
|
-
selectInfo = {
|
|
423
|
-
seriesID: lastHitInfo.sId,
|
|
424
|
-
dataIndex: lastHitInfo.maxIndex,
|
|
425
|
-
};
|
|
426
|
-
} else if (defaultSelectInfo?.dataIndex || defaultSelectInfo?.dataIndex === 0) {
|
|
427
|
-
selectInfo = { ...defaultSelectInfo };
|
|
428
|
-
} else {
|
|
429
|
-
selectInfo = null;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
if (this.options.seriesReverse) {
|
|
434
|
-
series = this.seriesList[chartTypeSet.at(-1 - jx)];
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
series.draw({
|
|
438
|
-
legendHitInfo,
|
|
439
|
-
selectInfo,
|
|
440
|
-
duple,
|
|
441
|
-
coordinateDedupe: this.options.coordinateDedupe,
|
|
442
|
-
...opt,
|
|
443
|
-
});
|
|
444
|
-
break;
|
|
445
|
-
}
|
|
446
|
-
default: {
|
|
447
|
-
break;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Draw Tip with hitInfo and defaultSelectItemInfo
|
|
456
|
-
*/
|
|
457
|
-
drawTip() {
|
|
458
|
-
let tipLocationInfo;
|
|
459
|
-
|
|
460
|
-
if (this.lastHitInfo) {
|
|
461
|
-
tipLocationInfo = this.lastHitInfo;
|
|
462
|
-
} else if (this.defaultSelectItemInfo) {
|
|
463
|
-
tipLocationInfo = this.getItem(this.defaultSelectItemInfo, false);
|
|
464
|
-
} else if (this.defaultSelectInfo && this.options.selectLabel.use) {
|
|
465
|
-
tipLocationInfo = this.getItem(this.defaultSelectInfo, false);
|
|
466
|
-
} else {
|
|
467
|
-
tipLocationInfo = null;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
this.drawTips?.(tipLocationInfo);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Create axes
|
|
475
|
-
* @param {string} dir axis direction
|
|
476
|
-
* @param {array} axes axes array
|
|
477
|
-
*
|
|
478
|
-
* @returns {array} axes objects in array
|
|
479
|
-
*/
|
|
480
|
-
createAxes(dir, axes = []) {
|
|
481
|
-
const ctx = this.bufferCtx;
|
|
482
|
-
|
|
483
|
-
const isHeatMapType = (this.options.type === 'heatMap');
|
|
484
|
-
const labels = isHeatMapType ? this.data.labels[dir] : this.data.labels;
|
|
485
|
-
|
|
486
|
-
const options = this.options;
|
|
487
|
-
return axes.map((axis) => {
|
|
488
|
-
switch (axis.type) {
|
|
489
|
-
case 'linear':
|
|
490
|
-
return new LinearScale(dir, axis, ctx, options);
|
|
491
|
-
case 'time':
|
|
492
|
-
if (axis.categoryMode) {
|
|
493
|
-
return new TimeCategoryScale(dir, axis, ctx, labels, options);
|
|
494
|
-
}
|
|
495
|
-
return new TimeScale(dir, axis, ctx, options);
|
|
496
|
-
case 'log':
|
|
497
|
-
return new LogarithmicScale(dir, axis, ctx);
|
|
498
|
-
case 'step':
|
|
499
|
-
return new StepScale(dir, axis, ctx, labels, options);
|
|
500
|
-
default:
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Calculate min/max value, label and size information for each axis
|
|
508
|
-
*
|
|
509
|
-
* @returns {object} axes min/max information
|
|
510
|
-
*/
|
|
511
|
-
getAxesRange() {
|
|
512
|
-
/* eslint-disable max-len */
|
|
513
|
-
const axesXMinMax = this.axesX.map((axis, index) => axis.calculateScaleRange(this.minMax.x[index], this.scrollbar.x, this.chartRect));
|
|
514
|
-
const axesYMinMax = this.axesY.map((axis, index) => axis.calculateScaleRange(this.minMax.y[index], this.scrollbar.y, this.chartRect));
|
|
515
|
-
/* eslint-enable max-len */
|
|
516
|
-
|
|
517
|
-
return { x: axesXMinMax, y: axesYMinMax };
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Draw each axis
|
|
522
|
-
*
|
|
523
|
-
* @returns {undefined}
|
|
524
|
-
*/
|
|
525
|
-
drawAxis(hitInfo) {
|
|
526
|
-
this.axesX.forEach((axis, index) => {
|
|
527
|
-
axis.draw(
|
|
528
|
-
this.chartRect,
|
|
529
|
-
this.labelOffset,
|
|
530
|
-
this.axesSteps.x[index],
|
|
531
|
-
hitInfo,
|
|
532
|
-
this.defaultSelectInfo,
|
|
533
|
-
this.data.labels);
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
this.axesY.forEach((axis, index) => {
|
|
537
|
-
axis.draw(
|
|
538
|
-
this.chartRect,
|
|
539
|
-
this.labelOffset,
|
|
540
|
-
this.axesSteps.y[index],
|
|
541
|
-
hitInfo,
|
|
542
|
-
this.defaultSelectInfo);
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* With each axis's min/max value and label information, calculate how many labels in each axis
|
|
548
|
-
*
|
|
549
|
-
* @returns {object} each axis's label steps in axes array
|
|
550
|
-
*/
|
|
551
|
-
calculateSteps() {
|
|
552
|
-
const axesXMinMax = this.axesX.map((axis, index) => {
|
|
553
|
-
const range = {
|
|
554
|
-
minValue: this.axesRange.x[index].min,
|
|
555
|
-
maxValue: this.axesRange.x[index].max,
|
|
556
|
-
minIndex: this.axesRange.x[index].minIndex,
|
|
557
|
-
maxIndex: this.axesRange.x[index].maxIndex,
|
|
558
|
-
minSteps: this.labelRange.x[index].min,
|
|
559
|
-
maxSteps: this.labelRange.x[index].max,
|
|
560
|
-
};
|
|
561
|
-
return axis.calculateSteps(range);
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
const axesYMinMax = this.axesY.map((axis, index) => {
|
|
565
|
-
const range = {
|
|
566
|
-
minValue: this.axesRange.y[index].min,
|
|
567
|
-
maxValue: this.axesRange.y[index].max,
|
|
568
|
-
minIndex: this.axesRange.y[index].minIndex,
|
|
569
|
-
maxIndex: this.axesRange.y[index].maxIndex,
|
|
570
|
-
minSteps: this.labelRange.y[index].min,
|
|
571
|
-
maxSteps: this.labelRange.y[index].max,
|
|
572
|
-
};
|
|
573
|
-
return axis.calculateSteps(range);
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
return { x: axesXMinMax, y: axesYMinMax };
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* Calculate axis's min/max label steps
|
|
581
|
-
*
|
|
582
|
-
* @returns {object} axes's label range
|
|
583
|
-
*/
|
|
584
|
-
getAxesLabelRange() {
|
|
585
|
-
const axesXSteps = this.axesX.map((axis, index) => {
|
|
586
|
-
const size = this.axesRange.x[index].size;
|
|
587
|
-
return axis.calculateLabelRange('x', this.chartRect, this.labelOffset, size.width);
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
const axesYSteps = this.axesY.map((axis, index) => {
|
|
591
|
-
const size = this.axesRange.y[index].size;
|
|
592
|
-
return axis.calculateLabelRange('y', this.chartRect, this.labelOffset, size.height);
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
return { x: axesXSteps, y: axesYSteps };
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Reset devicePixelRatio for high DPI
|
|
600
|
-
*
|
|
601
|
-
* @returns {undefined}
|
|
602
|
-
*/
|
|
603
|
-
initScale() {
|
|
604
|
-
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
605
|
-
const backingStoreRatio = this.displayCtx.webkitBackingStorePixelRatio
|
|
606
|
-
|| this.displayCtx.mozBackingStorePixelRatio
|
|
607
|
-
|| this.displayCtx.msBackingStorePixelRatio
|
|
608
|
-
|| this.displayCtx.oBackingStorePixelRatio
|
|
609
|
-
|| this.displayCtx.backingStorePixelRatio
|
|
610
|
-
|| 1;
|
|
611
|
-
|
|
612
|
-
this.pixelRatio = devicePixelRatio / backingStoreRatio;
|
|
613
|
-
|
|
614
|
-
if (this.oldPixelRatio !== this.pixelRatio) {
|
|
615
|
-
this.oldPixelRatio = this.pixelRatio;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
this.bufferCtx.scale(this.pixelRatio, this.pixelRatio);
|
|
619
|
-
|
|
620
|
-
if (this.overlayCtx) {
|
|
621
|
-
this.overlayCtx.scale(this.pixelRatio, this.pixelRatio);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* Get chart DOM size and set canvas size
|
|
627
|
-
* @typedef {import('./model/index').ChartDOMSize} ChartDOMSize
|
|
628
|
-
*
|
|
629
|
-
* @returns {ChartDOMSize} chart size information
|
|
630
|
-
*/
|
|
631
|
-
getChartDOMRect() {
|
|
632
|
-
const rect = this.chartDOM?.getBoundingClientRect();
|
|
633
|
-
const width = rect?.width || 10;
|
|
634
|
-
const height = rect?.height || 10;
|
|
635
|
-
|
|
636
|
-
this.setWidth(width);
|
|
637
|
-
this.setHeight(height);
|
|
638
|
-
|
|
639
|
-
return { width, height };
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
/**
|
|
643
|
-
* Calculate chart size
|
|
644
|
-
* @typedef {import('./model/index').ChartRect} ChartRect
|
|
645
|
-
*
|
|
646
|
-
* @returns {ChartRect} chart size information
|
|
647
|
-
*/
|
|
648
|
-
getChartRect() {
|
|
649
|
-
const { width, height } = this.getChartDOMRect();
|
|
650
|
-
|
|
651
|
-
const padding = this.options.padding;
|
|
652
|
-
const xAxisTitleOpt = this.options.axesX?.[0]?.title;
|
|
653
|
-
const yAxisTitleOpt = this.options.axesY?.[0]?.title;
|
|
654
|
-
const titleMargin = 10;
|
|
655
|
-
|
|
656
|
-
let xAxisTitleHeight = 0;
|
|
657
|
-
if (xAxisTitleOpt?.use && xAxisTitleOpt?.text) {
|
|
658
|
-
const fontSize = isNaN(xAxisTitleOpt?.fontSize) ? 12 : xAxisTitleOpt?.fontSize;
|
|
659
|
-
xAxisTitleHeight = fontSize + titleMargin;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
let yAxisTitleHeight = 0;
|
|
663
|
-
if (yAxisTitleOpt?.use && yAxisTitleOpt?.text) {
|
|
664
|
-
const fontSize = isNaN(yAxisTitleOpt?.fontSize) ? 12 : yAxisTitleOpt?.fontSize;
|
|
665
|
-
yAxisTitleHeight = fontSize + titleMargin;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
const xAxisScrollOpt = this.scrollbar.x;
|
|
669
|
-
const yAxisScrollOpt = this.scrollbar.y;
|
|
670
|
-
|
|
671
|
-
let xAxisScrollHeight = 0;
|
|
672
|
-
if (xAxisScrollOpt?.use) {
|
|
673
|
-
xAxisScrollHeight = xAxisScrollOpt?.height;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
let yAxisScrollWidth = 0;
|
|
677
|
-
if (yAxisScrollOpt?.use) {
|
|
678
|
-
yAxisScrollWidth = yAxisScrollOpt?.width;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
const horizontalPadding = padding.left + padding.right + yAxisScrollWidth;
|
|
682
|
-
const verticalPadding = padding.top + padding.bottom
|
|
683
|
-
+ xAxisTitleHeight + yAxisTitleHeight + xAxisScrollHeight;
|
|
684
|
-
const chartWidth = width > horizontalPadding ? width - horizontalPadding : width;
|
|
685
|
-
const chartHeight = height > verticalPadding ? height - verticalPadding : height;
|
|
686
|
-
|
|
687
|
-
const x1 = padding.left;
|
|
688
|
-
const x2 = Math.max(width - padding.right - yAxisScrollWidth, x1 + 2);
|
|
689
|
-
const y1 = padding.top + yAxisTitleHeight;
|
|
690
|
-
const y2 = Math.max(height - padding.bottom - xAxisTitleHeight - xAxisScrollHeight, y1 + 2);
|
|
691
|
-
|
|
692
|
-
return {
|
|
693
|
-
x1,
|
|
694
|
-
x2,
|
|
695
|
-
y1,
|
|
696
|
-
y2,
|
|
697
|
-
chartWidth,
|
|
698
|
-
chartHeight,
|
|
699
|
-
width,
|
|
700
|
-
height,
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
/**
|
|
705
|
-
* Set canvas width
|
|
706
|
-
* @param {number} width canvas width from chartDOM.width
|
|
707
|
-
*
|
|
708
|
-
* @returns {undefined}
|
|
709
|
-
*/
|
|
710
|
-
setWidth(width) {
|
|
711
|
-
if (!this.displayCanvas) {
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
this.displayCanvas.width = width * this.pixelRatio;
|
|
716
|
-
this.displayCanvas.style.width = `${width}px`;
|
|
717
|
-
this.bufferCanvas.width = width * this.pixelRatio;
|
|
718
|
-
this.bufferCanvas.style.width = `${width}px`;
|
|
719
|
-
|
|
720
|
-
if (this.overlayCanvas) {
|
|
721
|
-
this.overlayCanvas.width = width * this.pixelRatio;
|
|
722
|
-
this.overlayCanvas.style.width = `${width}px`;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/**
|
|
727
|
-
* Set canvas height
|
|
728
|
-
* @param {number} height canvas width from chartDOM.height
|
|
729
|
-
*
|
|
730
|
-
* @returns {undefined}
|
|
731
|
-
*/
|
|
732
|
-
setHeight(height) {
|
|
733
|
-
if (!this.displayCanvas) {
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
this.displayCanvas.height = height * this.pixelRatio;
|
|
738
|
-
this.displayCanvas.style.height = `${height}px`;
|
|
739
|
-
this.bufferCanvas.height = height * this.pixelRatio;
|
|
740
|
-
this.bufferCanvas.style.height = `${height}px`;
|
|
741
|
-
|
|
742
|
-
if (this.overlayCanvas) {
|
|
743
|
-
this.overlayCanvas.height = height * this.pixelRatio;
|
|
744
|
-
this.overlayCanvas.style.height = `${height}px`;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Calculate labels offset from chart rect (Axis 영역을 벗어나는 label 크기 계산)
|
|
750
|
-
*
|
|
751
|
-
* ex)
|
|
752
|
-
* Y축 label의 넓이와 (X축 최소값 label 넓이 / 2) 중 넓은 값이 left label offset으로 처리됨
|
|
753
|
-
*
|
|
754
|
-
* 0 |
|
|
755
|
-
* |
|
|
756
|
-
* |
|
|
757
|
-
* 0 ----------------------
|
|
758
|
-
* hh:mm hh:mm
|
|
759
|
-
*
|
|
760
|
-
* @param {object} adjustedRange
|
|
761
|
-
* {
|
|
762
|
-
* min: number, max: number, minLabel: string, maxLabel: string,
|
|
763
|
-
* size: {width: number, height: number}
|
|
764
|
-
* }
|
|
765
|
-
* minLabel and maxLabel is formatted label
|
|
766
|
-
* @returns {object} label offset for edge
|
|
767
|
-
*/
|
|
768
|
-
getLabelOffset(adjustedRange = null) {
|
|
769
|
-
const axesX = this.axesX;
|
|
770
|
-
const axesY = this.axesY;
|
|
771
|
-
const range = adjustedRange ?? this.axesRange;
|
|
772
|
-
const labelOffset = { top: 2, left: 2, right: 2, bottom: 2 };
|
|
773
|
-
const labelBuffer = { width: 14, height: 4 };
|
|
774
|
-
|
|
775
|
-
let lw = 0;
|
|
776
|
-
let lh = 0;
|
|
777
|
-
|
|
778
|
-
axesX.forEach((axis, index) => {
|
|
779
|
-
if (axis.labelStyle?.show) {
|
|
780
|
-
lw = range.x[index].size.width + labelBuffer.width;
|
|
781
|
-
lh = range.x[index].size.height + labelBuffer.height;
|
|
782
|
-
|
|
783
|
-
if (axis.position === 'bottom') {
|
|
784
|
-
if (lh > labelOffset.bottom) {
|
|
785
|
-
labelOffset.bottom = lh;
|
|
786
|
-
}
|
|
787
|
-
} else if (axis.position === 'top') {
|
|
788
|
-
if (lh > labelOffset.top) {
|
|
789
|
-
labelOffset.top = lh;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
labelOffset.left = (lw / 2) > labelOffset.left ? (lw / 2) : labelOffset.left;
|
|
794
|
-
labelOffset.right = (lw / 2) > labelOffset.right ? (lw / 2) : labelOffset.right;
|
|
795
|
-
}
|
|
796
|
-
});
|
|
797
|
-
|
|
798
|
-
axesY.forEach((axis, index) => {
|
|
799
|
-
if (axis.labelStyle?.show) {
|
|
800
|
-
lw = range.y[index].size.width + labelBuffer.width;
|
|
801
|
-
|
|
802
|
-
if (axis.position === 'left') {
|
|
803
|
-
if (lw > labelOffset.left) {
|
|
804
|
-
labelOffset.left = lw;
|
|
805
|
-
}
|
|
806
|
-
} else if (axis.position === 'right') {
|
|
807
|
-
if (lw > labelOffset.right) {
|
|
808
|
-
labelOffset.right = lw;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
labelOffset.top = (lh / 2) > labelOffset.top ? (lh / 2) : labelOffset.top;
|
|
813
|
-
labelOffset.bottom = (lh / 2) > labelOffset.bottom ? (lh / 2) : labelOffset.bottom;
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
|
|
817
|
-
return labelOffset;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
/**
|
|
821
|
-
* To re-render chart, reset properties, canvas and then render chart.
|
|
822
|
-
* @param {object} updateInfo information for each components are needed to update
|
|
823
|
-
*
|
|
824
|
-
* @returns {undefined}
|
|
825
|
-
*/
|
|
826
|
-
update(updateInfo) {
|
|
827
|
-
const options = this.options;
|
|
828
|
-
const data = this.data.data;
|
|
829
|
-
const labels = this.data.labels;
|
|
830
|
-
const groups = this.data.groups;
|
|
831
|
-
const series = this.data.series;
|
|
832
|
-
|
|
833
|
-
const { updateSeries, updateSelTip, updateLegend, updateData, updateTooltip } = updateInfo;
|
|
834
|
-
|
|
835
|
-
if (!this.isInit) {
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
this.updateScrollbar?.(updateData);
|
|
840
|
-
|
|
841
|
-
this.resetProps();
|
|
842
|
-
|
|
843
|
-
this.updateSeries = updateSeries;
|
|
844
|
-
if (updateSeries) {
|
|
845
|
-
this.seriesInfo = null;
|
|
846
|
-
this.seriesList = null;
|
|
847
|
-
this.lastTip = null;
|
|
848
|
-
|
|
849
|
-
this.seriesInfo = {
|
|
850
|
-
charts: {
|
|
851
|
-
pie: [],
|
|
852
|
-
bar: [],
|
|
853
|
-
line: [],
|
|
854
|
-
scatter: [],
|
|
855
|
-
heatMap: [],
|
|
856
|
-
},
|
|
857
|
-
count: 0,
|
|
858
|
-
};
|
|
859
|
-
this.seriesList = {};
|
|
860
|
-
this.lastTip = { pos: null, value: null };
|
|
861
|
-
|
|
862
|
-
this.createSeriesSet(series, options.type, options.horizontal, groups);
|
|
863
|
-
|
|
864
|
-
if (this.legendDOM) {
|
|
865
|
-
this.updateLegend();
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
if (updateSelTip.update) {
|
|
870
|
-
this.lastTip.value = null;
|
|
871
|
-
|
|
872
|
-
if (!updateSelTip.keepDomain) {
|
|
873
|
-
this.lastTip.pos = null;
|
|
874
|
-
this.lastHitInfo = null;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
if (groups.length) {
|
|
879
|
-
this.addGroupInfo(groups);
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
if (this.options.realTimeScatter?.use) {
|
|
883
|
-
if (!this.dataSet) {
|
|
884
|
-
this.dataSet = {};
|
|
885
|
-
}
|
|
886
|
-
this.createRealTimeScatterDataSet(data);
|
|
887
|
-
} else {
|
|
888
|
-
this.createDataSet(data, labels);
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
// title update
|
|
892
|
-
if (options.title.show) {
|
|
893
|
-
if (!this.isInitTitle) {
|
|
894
|
-
this.initTitle();
|
|
895
|
-
} else {
|
|
896
|
-
this.updateTitle();
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
this.showTitle();
|
|
900
|
-
} else if (this.isInitTitle) {
|
|
901
|
-
this.hideTitle();
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
// legend Update
|
|
905
|
-
if (options.legend.show) {
|
|
906
|
-
const useTable = !!options.legend?.table?.use
|
|
907
|
-
&& options.type !== 'heatMap'
|
|
908
|
-
&& options.type !== 'scatter';
|
|
909
|
-
|
|
910
|
-
if (!this.isInitLegend) {
|
|
911
|
-
this.initLegend();
|
|
912
|
-
} else if (updateSeries) {
|
|
913
|
-
this.updateLegend();
|
|
914
|
-
} else if (updateLegend) {
|
|
915
|
-
this.forceUpdateLegend();
|
|
916
|
-
} else if (useTable && updateData) {
|
|
917
|
-
this.updateLegendTableValues();
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
this.setLegendPosition();
|
|
921
|
-
this.updateLegendContainerSize();
|
|
922
|
-
this.showLegend();
|
|
923
|
-
} else if (this.isInitLegend) {
|
|
924
|
-
this.hideLegend();
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
// Tooltip Update
|
|
928
|
-
if (updateTooltip) {
|
|
929
|
-
if (!this.isInitTooltip) {
|
|
930
|
-
this.createTooltipDOM();
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
this.tooltipDOM.innerHTML = '';
|
|
934
|
-
|
|
935
|
-
if (!options.tooltip?.formatter?.html) {
|
|
936
|
-
this.setDefaultTooltipLayout();
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
this.chartRect = this.getChartRect();
|
|
941
|
-
|
|
942
|
-
this.minMax = this.getStoreMinMax();
|
|
943
|
-
this.axesX = this.createAxes('x', options.axesX);
|
|
944
|
-
this.axesY = this.createAxes('y', options.axesY);
|
|
945
|
-
|
|
946
|
-
this.initDefaultSelectInfo();
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
let renderHitInfo = updateInfo?.hitInfo;
|
|
950
|
-
if (!renderHitInfo?.legend && this.legendHover?.sId) {
|
|
951
|
-
renderHitInfo = { ...(renderHitInfo || {}), legend: this.legendHover };
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
this.render(renderHitInfo);
|
|
955
|
-
|
|
956
|
-
const isDragMove = this.dragInfo && this.drawSelectionArea;
|
|
957
|
-
if (isDragMove) {
|
|
958
|
-
this.drawSelectionArea(this.dragInfo);
|
|
959
|
-
} else if (this.dragInfoBackup) {
|
|
960
|
-
this.dragInfoBackup = null;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
/**
|
|
965
|
-
* To re-render chart, reset properties
|
|
966
|
-
*
|
|
967
|
-
* @returns {undefined}
|
|
968
|
-
*/
|
|
969
|
-
resetProps() {
|
|
970
|
-
this.axesX[0] = null;
|
|
971
|
-
this.axesY[0] = null;
|
|
972
|
-
this.axesX = null;
|
|
973
|
-
this.axesY = null;
|
|
974
|
-
this.minMax = null;
|
|
975
|
-
this.axesRange = null;
|
|
976
|
-
this.labelOffset = null;
|
|
977
|
-
this.chartRect = null;
|
|
978
|
-
this.pieDataSet = [];
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
/**
|
|
982
|
-
* Clear overlay canvas
|
|
983
|
-
*
|
|
984
|
-
* @returns {undefined}
|
|
985
|
-
*/
|
|
986
|
-
overlayClear() {
|
|
987
|
-
this.clearRectRatio = (this.pixelRatio < 1) ? this.pixelRatio : 1;
|
|
988
|
-
|
|
989
|
-
this.overlayCtx.clearRect(0, 0, this.overlayCanvas.width / this.clearRectRatio,
|
|
990
|
-
this.overlayCanvas.height / this.clearRectRatio);
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
/**
|
|
994
|
-
* Clear display and buffer canvas
|
|
995
|
-
*
|
|
996
|
-
* @returns {undefined}
|
|
997
|
-
*/
|
|
998
|
-
clear() {
|
|
999
|
-
this.clearRectRatio = (this.pixelRatio < 1) ? this.pixelRatio : 1;
|
|
1000
|
-
if (this.displayCanvas) {
|
|
1001
|
-
this.displayCtx.clearRect(0, 0, this.displayCanvas.width / this.clearRectRatio,
|
|
1002
|
-
this.displayCanvas.height / this.clearRectRatio);
|
|
1003
|
-
}
|
|
1004
|
-
if (this.bufferCanvas) {
|
|
1005
|
-
this.bufferCtx.clearRect(0, 0, this.bufferCanvas.width / this.clearRectRatio,
|
|
1006
|
-
this.bufferCanvas.height / this.clearRectRatio);
|
|
1007
|
-
}
|
|
1008
|
-
if (this.overlayCanvas) {
|
|
1009
|
-
this.overlayCtx.clearRect(0, 0, this.overlayCanvas.width / this.clearRectRatio,
|
|
1010
|
-
this.overlayCanvas.height / this.clearRectRatio);
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
* Resize chart
|
|
1016
|
-
* @param {Function} promiseRes After evChart resize completes,
|
|
1017
|
-
* callback completion status with promiseRes to draw a Brush over it.
|
|
1018
|
-
*
|
|
1019
|
-
* @returns {undefined}
|
|
1020
|
-
*/
|
|
1021
|
-
resize(promiseRes) {
|
|
1022
|
-
// 차트 크기가 변경될 때 저장된 스크롤 픽셀 위치를 초기화하여
|
|
1023
|
-
// 새로운 크기에 맞춰 스크롤바 크기/위치를 재계산하도록 함
|
|
1024
|
-
if (this.scrollbar?.x) {
|
|
1025
|
-
delete this.scrollbar.x.savedPosition;
|
|
1026
|
-
}
|
|
1027
|
-
if (this.scrollbar?.y) {
|
|
1028
|
-
delete this.scrollbar.y.savedPosition;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
this.clear();
|
|
1032
|
-
this.bufferCtx.restore();
|
|
1033
|
-
this.bufferCtx.save();
|
|
1034
|
-
|
|
1035
|
-
this.initRect();
|
|
1036
|
-
this.initScale();
|
|
1037
|
-
this.chartRect = this.getChartRect();
|
|
1038
|
-
this.drawChart();
|
|
1039
|
-
if (this.dragInfoBackup) {
|
|
1040
|
-
this.drawSelectionArea?.(this.dragInfoBackup);
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
if (promiseRes) {
|
|
1044
|
-
promiseRes(true);
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
/**
|
|
1049
|
-
* Render chart
|
|
1050
|
-
* @param {any} [hitInfo=undefined] hit item from mouse click/dblclick
|
|
1051
|
-
*
|
|
1052
|
-
* @returns {undefined}
|
|
1053
|
-
*/
|
|
1054
|
-
render(hitInfo) {
|
|
1055
|
-
if (this.isInit) {
|
|
1056
|
-
this.clear();
|
|
1057
|
-
this.chartRect = this.getChartRect();
|
|
1058
|
-
this.drawChart(hitInfo);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
/**
|
|
1063
|
-
* destroy chart component
|
|
1064
|
-
*
|
|
1065
|
-
* @returns {undefined}
|
|
1066
|
-
*/
|
|
1067
|
-
destroy() {
|
|
1068
|
-
if (!this.isInit) {
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
const target = this.target;
|
|
1073
|
-
|
|
1074
|
-
if (this.options.legend.show) {
|
|
1075
|
-
if (this.legendBoxDOM) {
|
|
1076
|
-
this.legendBoxDOM.removeEventListener('click', this.onLegendBoxClick);
|
|
1077
|
-
this.legendBoxDOM.removeEventListener('mouseover', this.onLegendBoxOver);
|
|
1078
|
-
this.legendBoxDOM.removeEventListener('mouseleave', this.onLegendBoxLeave);
|
|
1079
|
-
if (this.options.legend.type === 'gradient') {
|
|
1080
|
-
this.legendBoxDOM.removeEventListener('mousedown', this.onLegendMouseDown);
|
|
1081
|
-
}
|
|
1082
|
-
if (this.options.legend.virtualScroll && !this.useTable) {
|
|
1083
|
-
this.legendBoxDOM.removeEventListener('resize', this.updateVisibleRowCount);
|
|
1084
|
-
this.legendBoxDOM.removeEventListener('scroll', this.renderVisibleLegends);
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
if (this.resizeDOM) {
|
|
1089
|
-
this.resizeDOM.removeEventListener('mousedown', this.onResizeMouseDown);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
if (this.overlayCanvas) {
|
|
1094
|
-
this.overlayCanvas.removeEventListener('mousemove', this.onMouseMove);
|
|
1095
|
-
this.overlayCanvas.removeEventListener('mouseleave', this.onMouseLeave);
|
|
1096
|
-
this.overlayCanvas.removeEventListener('dblclick', this.onDblClick);
|
|
1097
|
-
this.overlayCanvas.removeEventListener('click', this.onClick);
|
|
1098
|
-
this.overlayCanvas.removeEventListener('mousedown', this.onMouseDown);
|
|
1099
|
-
this.overlayCanvas.removeEventListener('wheel', this.onWheel);
|
|
1100
|
-
window.removeEventListener('click', this.dragTouchSelectionEvent);
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
if (this.isInitTooltip) {
|
|
1104
|
-
this.tooltipDestroy();
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
if (this.renderVisibleLegendsFrameId != null) {
|
|
1108
|
-
cancelAnimationFrame(this.renderVisibleLegendsFrameId);
|
|
1109
|
-
this.renderVisibleLegendsFrameId = null;
|
|
1110
|
-
}
|
|
1111
|
-
if (this.updateVisibleRowCountFrameId != null) {
|
|
1112
|
-
cancelAnimationFrame(this.updateVisibleRowCountFrameId);
|
|
1113
|
-
this.updateVisibleRowCountFrameId = null;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
this.wrapperDOM = null;
|
|
1117
|
-
this.chartDOM = null;
|
|
1118
|
-
this.legendDOM = null;
|
|
1119
|
-
this.legendBoxDOM = null;
|
|
1120
|
-
this.resizeDOM = null;
|
|
1121
|
-
this.ghostDOM = null;
|
|
1122
|
-
this.titleDOM = null;
|
|
1123
|
-
this.displayCanvas = null;
|
|
1124
|
-
this.bufferCanvas = null;
|
|
1125
|
-
this.overlayCanvas = null;
|
|
1126
|
-
|
|
1127
|
-
while (target.hasChildNodes()) {
|
|
1128
|
-
target.removeChild(target.firstChild);
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
/**
|
|
1133
|
-
* hide chart tooltip
|
|
1134
|
-
*
|
|
1135
|
-
* @returns {undefined}
|
|
1136
|
-
*/
|
|
1137
|
-
hideTooltip() {
|
|
1138
|
-
if (this.options.tooltip.use && this.tooltipDOM?.style) {
|
|
1139
|
-
this.tooltipDOM.style.display = 'none';
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
/**
|
|
1144
|
-
* init defaultSelectInfo (for selectLabel, selectSeries options)
|
|
1145
|
-
*/
|
|
1146
|
-
initDefaultSelectInfo() {
|
|
1147
|
-
const {
|
|
1148
|
-
type: chartType,
|
|
1149
|
-
selectLabel,
|
|
1150
|
-
selectSeries,
|
|
1151
|
-
} = this.options;
|
|
1152
|
-
|
|
1153
|
-
if (selectLabel.use) {
|
|
1154
|
-
let targetAxis = null;
|
|
1155
|
-
if (chartType === 'heatMap' && selectLabel?.useBothAxis) {
|
|
1156
|
-
targetAxis = this.defaultSelectInfo?.targetAxis;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
this.defaultSelectInfo = !this.defaultSelectInfo?.dataIndex
|
|
1160
|
-
? { dataIndex: [], label: [], data: [] }
|
|
1161
|
-
: this.getSelectedLabelInfoWithLabelData(this.defaultSelectInfo.dataIndex, targetAxis);
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
if (selectSeries.use && !this.defaultSelectInfo) {
|
|
1165
|
-
this.defaultSelectInfo = { seriesId: [] };
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
export default EvChart;
|