evui 2.0.8 → 2.1.1
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/{adac9fa4f723f9d2cb5b6640517114a9.png → 0b8d1200e71cae8d747dce4e69c4efb6.png} +0 -0
- package/dist/1.css +4 -0
- package/dist/1.css.map +1 -0
- package/dist/1.evui.min.js +2 -0
- package/dist/1.evui.min.js.map +1 -0
- package/dist/1ba679c05036b34bf359aa2e6c450faa.ttf +0 -0
- package/dist/2.css +4 -0
- package/dist/2.css.map +1 -0
- package/dist/2.evui.min.js +2 -0
- package/dist/2.evui.min.js.map +1 -0
- package/dist/{e8c322de9658cbeb8a774b6624167c2c.woff2 → 278156e41e0ad908cf7f841b17130502.woff2} +0 -0
- package/dist/3.evui.min.js +2 -0
- package/dist/3.evui.min.js.map +1 -0
- package/dist/32be89b11725274cd3e801192ba88361.ttf +0 -0
- package/dist/{0ab54153eeeca0ce03978cc463b257f7.woff2 → 38c6d8bab26db77d8c806813e1497763.woff2} +0 -0
- package/dist/4.evui.min.js +2 -0
- package/dist/4.evui.min.js.map +1 -0
- package/dist/{faff92145777a3cbaf8e7367b4807987.woff → 425399f81e4ce7cbd967685402ba0260.woff} +0 -0
- package/dist/4730076470a665bbc7b783c56d29a72e.svg +261 -0
- package/dist/52e9a7f6ff3af5ad261e5292d07ebdca.eot +0 -0
- package/dist/{ad97afd3337e8cda302d10ff5a4026b8.ttf → 5367103510b27b78482794590e1ce3b0.ttf} +0 -0
- package/dist/{65363c4d55617bbeb57d8ce6dcd46099.svg → 57e963e3d6dd0a9cf05150b40eebf69b.svg} +0 -0
- package/dist/{c5ebe0b32dc1b5cc449a76c4204d13bb.ttf → 65a2fb6d9aaa164b41a039302093995b.ttf} +0 -0
- package/dist/{cd6c777f1945164224dee082abaea03a.woff2 → 687a4990ea22bb1a49d469a5d9319790.woff2} +0 -0
- package/dist/{7583da5c07275cd5eb364507616f998f.ttf → 6c1d906bf5ba48676f65b2d65e935e1a.ttf} +0 -0
- package/dist/6dafca5a4f1e31f2bdf11939b24ff422.ttf +0 -0
- package/dist/{701ae6abd4719e9c2ada3535a497b341.eot → 752905fa5edf21fc52a10a0c1ca9c7a4.eot} +0 -0
- package/dist/76c05d80dda67cdc5d03f345b7bd063f.ttf +0 -0
- package/dist/{b551b554a67e86a840bc80cbb8066c30.svg → 7d62eb50e7bb05eedb2a4656f7fe8f3b.svg} +0 -0
- package/dist/{8e3c7f5520f5ae906c6cf6d7f3ddcd19.eot → a01e3f2d6c83dc3aee175e2482b3f777.eot} +0 -0
- package/dist/{448f2aaa315fa9dce7b2cf6ce31caed6.svg → b30fd8419d7e6d5918856c7531d33482.svg} +0 -0
- package/dist/c57dd55fa982e8940f69ca1d69a8a999.woff +0 -0
- package/dist/{b87b9ba532ace76ae9f6edfe9f72ded2.ttf → c656b8caa454ed19b9a2ef7f4f5b8fea.ttf} +0 -0
- package/dist/{a046592bac8f2fd96e994733faf3858c.woff → cac87dc00c87a5d74711d0276713808a.woff} +0 -0
- package/dist/{13db00b7a34fee4d819ab7f9838cc428.eot → d68fa3e67dbb653a13cec44b1bcabcfe.eot} +0 -0
- package/dist/{ef60a4f6c25ef7f39f2d25a748dbecfe.woff → ddae9b1ba9b0b42f58809904b0b21349.woff} +0 -0
- package/dist/evui.min.js +12 -59485
- package/dist/evui.min.js.gz +0 -0
- package/dist/evui.min.js.map +1 -1
- package/dist/main.css +85 -0
- package/dist/main.css.gz +0 -0
- package/dist/main.css.map +1 -0
- package/package.json +58 -89
- package/src/common/emitter.js +20 -0
- package/src/common/utils.debounce.js +223 -0
- package/src/common/utils.js +51 -17
- package/src/common/utils.throttle.js +83 -0
- package/src/common/utils.tree.js +18 -0
- package/src/components/button/button.vue +316 -241
- package/src/components/chart/chart.core.js +699 -0
- package/src/components/chart/chart.vue +200 -204
- package/src/components/chart/element/element.bar.js +311 -0
- package/src/components/chart/element/element.bar.time.js +115 -0
- package/src/components/chart/element/element.line.js +288 -0
- package/src/components/chart/element/element.pie.js +86 -0
- package/src/components/chart/element/element.scatter.js +83 -0
- package/src/components/chart/element/element.tip.js +356 -0
- package/src/components/chart/helpers/helpers.canvas.js +237 -0
- package/src/components/chart/helpers/helpers.constant.js +138 -0
- package/src/components/chart/helpers/helpers.util.js +154 -0
- package/src/components/chart/index.js +0 -1
- package/src/components/chart/model/index.js +4 -0
- package/src/components/chart/model/model.series.js +86 -0
- package/src/components/chart/model/model.store.js +559 -0
- package/src/components/chart/plugins/plugins.interaction.js +324 -0
- package/src/components/chart/plugins/plugins.legend.js +589 -0
- package/src/components/chart/plugins/plugins.pie.js +179 -0
- package/src/components/chart/plugins/plugins.title.js +56 -0
- package/src/components/chart/plugins/plugins.tooltip.js +384 -0
- package/src/components/chart/scale/scale.js +272 -0
- package/src/components/chart/scale/scale.linear.js +30 -0
- package/src/components/chart/scale/scale.logarithmic.js +120 -0
- package/src/components/chart/scale/scale.step.js +197 -0
- package/src/components/chart/scale/scale.time.category.js +204 -0
- package/src/components/chart/scale/scale.time.js +40 -0
- package/src/components/checkbox/checkbox-group.vue +31 -12
- package/src/components/checkbox/checkbox.vue +269 -19
- package/src/components/codeview/code.vue +42 -29
- package/src/components/contextmenu/contextmenu.child.vue +79 -0
- package/src/components/contextmenu/contextmenu.vue +276 -0
- package/src/components/contextmenu/contextmenu.wrap.vue +189 -0
- package/src/components/contextmenu/index.js +3 -0
- package/src/components/datepicker/calendar.core.js +604 -510
- package/src/components/datepicker/calendar.vue +0 -3
- package/src/components/datepicker/datepicker.vue +73 -14
- package/src/components/datepicker/index.js +5 -1
- package/src/components/grid/grid.filter.vue +290 -0
- package/src/components/grid/grid.filter.window.vue +411 -0
- package/src/components/grid/grid.render.vue +45 -0
- package/src/components/grid/grid.vue +1338 -0
- package/src/components/icon/icon.vue +22 -7
- package/src/components/input/input.number.vue +309 -277
- package/src/components/label/label.vue +2 -2
- package/src/components/loadingmask/loadingmask.vue +52 -63
- package/src/components/loginfield/index.js +3 -0
- package/src/components/loginfield/loginfield.vue +339 -0
- package/src/components/markdown/index.js +3 -0
- package/src/components/markdown/markdown.vue +1001 -0
- package/src/components/menu/index.js +1 -3
- package/src/components/menu/menu.nav.item.vue +115 -0
- package/src/components/menu/menu.nav.sub.vue +42 -0
- package/src/components/menu/menu.nav.vue +71 -98
- package/src/components/message/index.js +3 -0
- package/src/components/message/message.js +63 -0
- package/src/components/message/message.vue +191 -0
- package/src/components/message-box/index.js +3 -0
- package/src/components/message-box/message-box.js +31 -0
- package/src/components/message-box/message-box.vue +298 -0
- package/src/components/notification/index.js +3 -0
- package/src/components/notification/notification.js +75 -0
- package/src/components/notification/notification.vue +242 -0
- package/src/components/radio/radio-group.vue +12 -2
- package/src/components/radio/radio.vue +186 -25
- package/src/components/selectbox/dropdown.vue +96 -39
- package/src/components/selectbox/listbox.vue +68 -29
- package/src/components/selectbox/option.vue +1 -1
- package/src/components/selectbox/selectbox.vue +445 -245
- package/src/components/slider/slider-tooltip.vue +7 -7
- package/src/components/slider/slider.vue +20 -25
- package/src/components/splitter/index.js +3 -0
- package/src/components/splitter/splitter.vue +294 -0
- package/src/components/table/table.black.css +1 -1
- package/src/components/table/table.filter.lite.vue +8 -8
- package/src/components/table/table.filter.vue +1 -1
- package/src/components/table/table.grey.css +5 -6
- package/src/components/table/table.navy.css +1 -1
- package/src/components/table/table.vue +60 -55
- package/src/components/tabs/tab-panel.vue +19 -5
- package/src/components/tabs/tabs.vue +182 -87
- package/src/components/textfield/textfield.vue +140 -80
- package/src/components/timepicker/index.js +2 -2
- package/src/components/timepicker/spinner.vue +15 -17
- package/src/components/timepicker/timepicker.vue +98 -53
- package/src/components/toggle/toggle.vue +206 -158
- package/src/components/tree/index.js +2 -6
- package/src/components/tree/render.js +17 -0
- package/src/components/tree/tree-node.vue +214 -0
- package/src/components/tree/tree.vue +296 -0
- package/src/components/tree-table/index.js +7 -0
- package/src/components/{tree → tree-table}/tree.table.black.css +0 -0
- package/src/components/{tree → tree-table}/tree.table.grey.css +12 -12
- package/src/components/{tree → tree-table}/tree.table.vue +151 -95
- package/src/components/tree-table/tree.util.js +119 -0
- package/src/components/window/window.vue +238 -183
- package/src/index.js +29 -12
- package/src/styles/base/base.scss +50 -0
- package/src/styles/base/index.scss +1 -0
- package/src/styles/default.scss +5 -0
- package/src/styles/{codemirror.css → lib/codemirror.css} +0 -0
- package/src/styles/{all.css → lib/fontawesome.css} +1 -1
- package/src/styles/lib/icon.css +792 -0
- package/src/styles/themes/index.scss +2 -0
- package/src/styles/themes/mixin.scss +33 -0
- package/src/styles/themes/variables.scss +206 -0
- package/src/styles/utils/colors.scss +222 -0
- package/src/styles/utils/index.scss +2 -0
- package/src/styles/utils/mixins.scss +34 -0
- package/src/styles/utils/variables.scss +27 -0
- package/src/webfonts/EVUI.eot +0 -0
- package/src/webfonts/EVUI.svg +251 -173
- package/src/webfonts/EVUI.ttf +0 -0
- package/src/webfonts/EVUI.woff +0 -0
- package/src/webfonts/Roboto-Bold.ttf +0 -0
- package/src/webfonts/Roboto-Medium.ttf +0 -0
- package/src/webfonts/Roboto-Regular.ttf +0 -0
- package/dist/3c9453211570a4ede66a4b4954a32bbb.ttf +0 -0
- package/dist/8634884f932627fc43782e6963b64ccd.svg +0 -183
- package/dist/b9e64d9b5fa6b500eb5df6fa980d3e5b.eot +0 -0
- package/dist/f0ac0c8b3c9cd3ef9002749985ae546f.woff +0 -0
- package/src/components/chart/charts/chart.bar.js +0 -334
- package/src/components/chart/charts/chart.base.js +0 -1075
- package/src/components/chart/charts/chart.line.js +0 -262
- package/src/components/chart/charts/chart.pie.js +0 -383
- package/src/components/chart/charts/chart.scatter.js +0 -349
- package/src/components/chart/charts/chart.sunburst.js +0 -193
- package/src/components/chart/core/axis/axis.js +0 -217
- package/src/components/chart/core/axis/axis.scale.auto.js +0 -69
- package/src/components/chart/core/axis/axis.scale.fixed.js +0 -65
- package/src/components/chart/core/axis/axis.scale.steps.js +0 -149
- package/src/components/chart/core/core.constant.js +0 -91
- package/src/components/chart/core/core.legend.js +0 -473
- package/src/components/chart/core/core.util.js +0 -66
- package/src/components/chart/core/data/data.js +0 -412
- package/src/components/chart/core/data/data.pie.js +0 -70
- package/src/components/chart/core/data/data.stack.js +0 -222
- package/src/components/chart/core/data/data.sunburst.js +0 -172
- package/src/components/menu/menu.context.children.vue +0 -201
- package/src/components/menu/menu.context.vue +0 -144
- package/src/components/tabs/jun/tab.vue +0 -123
- package/src/components/tabs/jun/tabs.vue +0 -484
- package/src/components/tree/tree.util.js +0 -39
- package/src/styles/evui.css +0 -386
- package/src/styles/icon.css +0 -557
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
import throttle from '@/common/utils.throttle';
|
|
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 Interaction from './plugins/plugins.interaction';
|
|
11
|
+
import Tooltip from './plugins/plugins.tooltip';
|
|
12
|
+
import Pie from './plugins/plugins.pie';
|
|
13
|
+
import Tip from './element/element.tip';
|
|
14
|
+
|
|
15
|
+
class EvChart {
|
|
16
|
+
constructor(target, data, options, listeners) {
|
|
17
|
+
Object.keys(Model).forEach(key => Object.assign(this, Model[key]));
|
|
18
|
+
Object.assign(this, Title);
|
|
19
|
+
Object.assign(this, Legend);
|
|
20
|
+
Object.assign(this, Interaction);
|
|
21
|
+
Object.assign(this, Tooltip);
|
|
22
|
+
Object.assign(this, Pie);
|
|
23
|
+
Object.assign(this, Tip);
|
|
24
|
+
|
|
25
|
+
this.target = target;
|
|
26
|
+
this.data = data;
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.listeners = listeners;
|
|
29
|
+
|
|
30
|
+
this.wrapperDOM = document.createElement('div');
|
|
31
|
+
this.wrapperDOM.className = 'ev-chart-wrapper';
|
|
32
|
+
this.chartDOM = document.createElement('div');
|
|
33
|
+
this.chartDOM.className = 'ev-chart-container';
|
|
34
|
+
this.wrapperDOM.appendChild(this.chartDOM);
|
|
35
|
+
this.target.appendChild(this.wrapperDOM);
|
|
36
|
+
|
|
37
|
+
this.displayCanvas = document.createElement('canvas');
|
|
38
|
+
this.displayCanvas.setAttribute('style', 'display: block;');
|
|
39
|
+
this.displayCtx = this.displayCanvas.getContext('2d');
|
|
40
|
+
this.bufferCanvas = document.createElement('canvas');
|
|
41
|
+
this.bufferCanvas.setAttribute('style', 'display: block;');
|
|
42
|
+
this.bufferCtx = this.bufferCanvas.getContext('2d');
|
|
43
|
+
this.overlayCanvas = document.createElement('canvas');
|
|
44
|
+
this.overlayCanvas.setAttribute('style', 'display: block;');
|
|
45
|
+
this.overlayCtx = this.overlayCanvas.getContext('2d');
|
|
46
|
+
|
|
47
|
+
this.pixelRatio = window.devicePixelRatio || 1;
|
|
48
|
+
this.oldPixelRatio = this.pixelRatio;
|
|
49
|
+
|
|
50
|
+
this.chartDOM.appendChild(this.displayCanvas);
|
|
51
|
+
this.chartDOM.appendChild(this.overlayCanvas);
|
|
52
|
+
|
|
53
|
+
this.overlayCanvas.style.position = 'absolute';
|
|
54
|
+
this.overlayCanvas.style.top = '0px';
|
|
55
|
+
this.overlayCanvas.style.left = '0px';
|
|
56
|
+
|
|
57
|
+
this.isInitLegend = false;
|
|
58
|
+
this.isInitTitle = false;
|
|
59
|
+
this.isInit = false;
|
|
60
|
+
this.seriesList = {};
|
|
61
|
+
this.lastTip = { pos: null, value: null };
|
|
62
|
+
this.seriesInfo = {
|
|
63
|
+
charts: { pie: [], bar: [], line: [], scatter: [] },
|
|
64
|
+
count: 0,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Initialize chart object
|
|
70
|
+
*
|
|
71
|
+
* @returns {undefined}
|
|
72
|
+
*/
|
|
73
|
+
init() {
|
|
74
|
+
const { series, data, labels, groups } = this.data;
|
|
75
|
+
const { type, axesX, axesY, tooltip, horizontal } = this.options;
|
|
76
|
+
|
|
77
|
+
this.createSeriesSet(series, type, horizontal);
|
|
78
|
+
if (groups.length) {
|
|
79
|
+
this.addGroupInfo(groups);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.createDataSet(data, labels);
|
|
83
|
+
this.minMax = this.getStoreMinMax();
|
|
84
|
+
|
|
85
|
+
this.initRect();
|
|
86
|
+
|
|
87
|
+
this.axesX = this.createAxes('x', axesX);
|
|
88
|
+
this.axesY = this.createAxes('y', axesY);
|
|
89
|
+
|
|
90
|
+
this.axesRange = this.getAxesRange();
|
|
91
|
+
this.labelOffset = this.getLabelOffset();
|
|
92
|
+
|
|
93
|
+
this.initScale();
|
|
94
|
+
this.drawChart();
|
|
95
|
+
|
|
96
|
+
if (tooltip.use) {
|
|
97
|
+
this.createTooltipDOM();
|
|
98
|
+
|
|
99
|
+
if (tooltip.throttledMove) {
|
|
100
|
+
this.onMouseMove = throttle(this.onMouseMove, 30);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.createEventFunctions();
|
|
105
|
+
this.isInit = true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Initialize chart rectangle
|
|
110
|
+
*
|
|
111
|
+
* @returns {undefined}
|
|
112
|
+
*/
|
|
113
|
+
initRect() {
|
|
114
|
+
const opt = this.options;
|
|
115
|
+
if (opt.title.show) {
|
|
116
|
+
this.initTitle();
|
|
117
|
+
this.showTitle();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (opt.legend.show) {
|
|
121
|
+
this.initLegend();
|
|
122
|
+
this.setLegendPosition();
|
|
123
|
+
}
|
|
124
|
+
this.chartRect = this.getChartRect();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* To draw canvas chart, it processes several sequential jobs
|
|
129
|
+
* @param {any} [hitInfo=undefined] from mousemove callback (object or undefined)
|
|
130
|
+
*
|
|
131
|
+
* @returns {undefined}
|
|
132
|
+
*/
|
|
133
|
+
drawChart(hitInfo) {
|
|
134
|
+
this.labelRange = this.getAxesLabelRange();
|
|
135
|
+
this.axesSteps = this.calculateSteps();
|
|
136
|
+
this.drawAxis();
|
|
137
|
+
this.drawSeries();
|
|
138
|
+
this.drawTip(hitInfo);
|
|
139
|
+
this.displayCtx.drawImage(this.bufferCanvas, 0, 0);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Draw each series
|
|
144
|
+
*
|
|
145
|
+
* @returns {undefined}
|
|
146
|
+
*/
|
|
147
|
+
drawSeries() {
|
|
148
|
+
const thickness = this.options.thickness;
|
|
149
|
+
const maxTip = this.options.maxTip;
|
|
150
|
+
|
|
151
|
+
const opt = {
|
|
152
|
+
ctx: this.bufferCtx,
|
|
153
|
+
chartRect: this.chartRect,
|
|
154
|
+
labelOffset: this.labelOffset,
|
|
155
|
+
axesSteps: this.axesSteps,
|
|
156
|
+
maxTipOpt: { background: maxTip.background, color: maxTip.color },
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
let showIndex = 0;
|
|
160
|
+
let showSeriesCount = 0;
|
|
161
|
+
|
|
162
|
+
this.seriesInfo.charts.bar.forEach((series) => {
|
|
163
|
+
if (this.seriesList[series].show) {
|
|
164
|
+
showSeriesCount++;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const chartKeys = Object.keys(this.seriesInfo.charts);
|
|
169
|
+
for (let ix = 0; ix < chartKeys.length; ix++) {
|
|
170
|
+
const chartType = chartKeys[ix];
|
|
171
|
+
const chartTypeSet = this.seriesInfo.charts[chartType];
|
|
172
|
+
|
|
173
|
+
for (let jx = 0; jx < chartTypeSet.length; jx++) {
|
|
174
|
+
const series = this.seriesList[chartTypeSet[jx]];
|
|
175
|
+
|
|
176
|
+
if (chartType === 'line' || chartType === 'scatter') {
|
|
177
|
+
series.draw(opt);
|
|
178
|
+
} else if (chartType === 'bar') {
|
|
179
|
+
series.draw({ thickness, showSeriesCount, showIndex, ...opt });
|
|
180
|
+
|
|
181
|
+
if (series.show) {
|
|
182
|
+
showIndex++;
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
if (this.options.sunburst) {
|
|
186
|
+
this.drawSunburst();
|
|
187
|
+
} else {
|
|
188
|
+
this.drawPie();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (this.options.doughnutHoleSize > 0) {
|
|
192
|
+
this.drawDoughnutHole();
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Create axes
|
|
202
|
+
* @param {string} dir axis direction
|
|
203
|
+
* @param {array} axes axes array
|
|
204
|
+
*
|
|
205
|
+
* @returns {array} axes objects in array
|
|
206
|
+
*/
|
|
207
|
+
createAxes(dir, axes = []) {
|
|
208
|
+
const ctx = this.bufferCtx;
|
|
209
|
+
const labels = this.data.labels;
|
|
210
|
+
|
|
211
|
+
return axes.map((axis) => {
|
|
212
|
+
switch (axis.type) {
|
|
213
|
+
case 'linear':
|
|
214
|
+
return new LinearScale(dir, axis, ctx);
|
|
215
|
+
case 'time':
|
|
216
|
+
if (axis.categoryMode) {
|
|
217
|
+
return new TimeCategoryScale(dir, axis, ctx, labels);
|
|
218
|
+
}
|
|
219
|
+
return new TimeScale(dir, axis, ctx);
|
|
220
|
+
case 'log':
|
|
221
|
+
return new LogarithmicScale(dir, axis, ctx);
|
|
222
|
+
case 'step':
|
|
223
|
+
return new StepScale(dir, axis, ctx, labels);
|
|
224
|
+
default:
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Calculate min/max value, label and size information for each axis
|
|
232
|
+
*
|
|
233
|
+
* @returns {object} axes min/max information
|
|
234
|
+
*/
|
|
235
|
+
getAxesRange() {
|
|
236
|
+
/* eslint-disable max-len */
|
|
237
|
+
const axesXMinMax = this.axesX.map((axis, index) => axis.calculateScaleRange(this.minMax.x[index], this.chartRect));
|
|
238
|
+
const axesYMinMax = this.axesY.map((axis, index) => axis.calculateScaleRange(this.minMax.y[index], this.chartRect));
|
|
239
|
+
/* eslint-enable max-len */
|
|
240
|
+
|
|
241
|
+
return { x: axesXMinMax, y: axesYMinMax };
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Draw each axis
|
|
246
|
+
*
|
|
247
|
+
* @returns {undefined}
|
|
248
|
+
*/
|
|
249
|
+
drawAxis() {
|
|
250
|
+
this.axesX.forEach((axis, index) => {
|
|
251
|
+
axis.draw(this.chartRect, this.labelOffset, this.axesSteps.x[index]);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
this.axesY.forEach((axis, index) => {
|
|
255
|
+
axis.draw(this.chartRect, this.labelOffset, this.axesSteps.y[index]);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* With each axis's min/max value and label information, calculate how many labels in each axis
|
|
261
|
+
*
|
|
262
|
+
* @returns {object} each axis's label steps in axes array
|
|
263
|
+
*/
|
|
264
|
+
calculateSteps() {
|
|
265
|
+
const axesXMinMax = this.axesX.map((axis, index) => {
|
|
266
|
+
const range = {
|
|
267
|
+
minValue: this.axesRange.x[index].min,
|
|
268
|
+
maxValue: this.axesRange.x[index].max,
|
|
269
|
+
minSteps: this.labelRange.x[index].min,
|
|
270
|
+
maxSteps: this.labelRange.x[index].max,
|
|
271
|
+
};
|
|
272
|
+
return axis.calculateSteps(range);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
const axesYMinMax = this.axesY.map((axis, index) => {
|
|
276
|
+
const range = {
|
|
277
|
+
minValue: this.axesRange.y[index].min,
|
|
278
|
+
maxValue: this.axesRange.y[index].max,
|
|
279
|
+
minSteps: this.labelRange.y[index].min,
|
|
280
|
+
maxSteps: this.labelRange.y[index].max,
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
return axis.calculateSteps(range);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
return { x: axesXMinMax, y: axesYMinMax };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Calculate axis's min/max label steps
|
|
291
|
+
*
|
|
292
|
+
* @returns {object} axes's label range
|
|
293
|
+
*/
|
|
294
|
+
getAxesLabelRange() {
|
|
295
|
+
const axesXSteps = this.axesX.map((axis, index) => {
|
|
296
|
+
const size = this.axesRange.x[index].size;
|
|
297
|
+
return axis.calculateLabelRange('x', this.chartRect, this.labelOffset, size.width);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
const axesYSteps = this.axesY.map((axis, index) => {
|
|
301
|
+
const size = this.axesRange.y[index].size;
|
|
302
|
+
return axis.calculateLabelRange('y', this.chartRect, this.labelOffset, size.height);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
return { x: axesXSteps, y: axesYSteps };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Reset devicePixelRatio for high DPI
|
|
310
|
+
*
|
|
311
|
+
* @returns {undefined}
|
|
312
|
+
*/
|
|
313
|
+
initScale() {
|
|
314
|
+
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
315
|
+
const backingStoreRatio = this.displayCtx.webkitBackingStorePixelRatio
|
|
316
|
+
|| this.displayCtx.mozBackingStorePixelRatio
|
|
317
|
+
|| this.displayCtx.msBackingStorePixelRatio
|
|
318
|
+
|| this.displayCtx.oBackingStorePixelRatio
|
|
319
|
+
|| this.displayCtx.backingStorePixelRatio
|
|
320
|
+
|| 1;
|
|
321
|
+
|
|
322
|
+
this.pixelRatio = devicePixelRatio / backingStoreRatio;
|
|
323
|
+
|
|
324
|
+
if (this.oldPixelRatio !== this.pixelRatio) {
|
|
325
|
+
this.oldPixelRatio = this.pixelRatio;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
this.bufferCtx.scale(this.pixelRatio, this.pixelRatio);
|
|
329
|
+
this.overlayCtx.scale(this.pixelRatio, this.pixelRatio);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Get chart DOM size and set canvas size
|
|
334
|
+
*
|
|
335
|
+
* @returns {object} chart size information
|
|
336
|
+
*/
|
|
337
|
+
getChartDOMRect() {
|
|
338
|
+
const rect = this.chartDOM.getBoundingClientRect();
|
|
339
|
+
const width = rect.width || 10;
|
|
340
|
+
const height = rect.height || 10;
|
|
341
|
+
|
|
342
|
+
this.setWidth(width);
|
|
343
|
+
this.setHeight(height);
|
|
344
|
+
|
|
345
|
+
return { width, height };
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Calculate chart size
|
|
350
|
+
*
|
|
351
|
+
* @returns {object} chart size information
|
|
352
|
+
*/
|
|
353
|
+
getChartRect() {
|
|
354
|
+
const { width, height } = this.getChartDOMRect();
|
|
355
|
+
|
|
356
|
+
const padding = { top: 20, right: 2, left: 2, bottom: 4 };
|
|
357
|
+
const chartWidth = width - padding.left - padding.right;
|
|
358
|
+
const chartHeight = height - padding.top - padding.bottom;
|
|
359
|
+
|
|
360
|
+
const x1 = padding.left;
|
|
361
|
+
const x2 = Math.max(width - padding.right, x1 + 2);
|
|
362
|
+
const y1 = padding.top;
|
|
363
|
+
const y2 = Math.max(height - padding.bottom, y1 + 2);
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
x1,
|
|
367
|
+
x2,
|
|
368
|
+
y1,
|
|
369
|
+
y2,
|
|
370
|
+
chartWidth,
|
|
371
|
+
chartHeight,
|
|
372
|
+
width,
|
|
373
|
+
height,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Set canvas width
|
|
379
|
+
* @param {number} width canvas width from chartDOM.width
|
|
380
|
+
*
|
|
381
|
+
* @returns {undefined}
|
|
382
|
+
*/
|
|
383
|
+
setWidth(width) {
|
|
384
|
+
if (!this.displayCanvas) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
this.displayCanvas.width = width * this.pixelRatio;
|
|
389
|
+
this.displayCanvas.style.width = `${width}px`;
|
|
390
|
+
this.bufferCanvas.width = width * this.pixelRatio;
|
|
391
|
+
this.bufferCanvas.style.width = `${width}px`;
|
|
392
|
+
this.overlayCanvas.width = width * this.pixelRatio;
|
|
393
|
+
this.overlayCanvas.style.width = `${width}px`;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Set canvas height
|
|
398
|
+
* @param {number} height canvas width from chartDOM.height
|
|
399
|
+
*
|
|
400
|
+
* @returns {undefined}
|
|
401
|
+
*/
|
|
402
|
+
setHeight(height) {
|
|
403
|
+
if (!this.displayCanvas) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
this.displayCanvas.height = height * this.pixelRatio;
|
|
408
|
+
this.displayCanvas.style.height = `${height}px`;
|
|
409
|
+
this.bufferCanvas.height = height * this.pixelRatio;
|
|
410
|
+
this.bufferCanvas.style.height = `${height}px`;
|
|
411
|
+
this.overlayCanvas.height = height * this.pixelRatio;
|
|
412
|
+
this.overlayCanvas.style.height = `${height}px`;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Calculate labels offset from chart rect (Axis 영역을 벗어나는 label 크기 계산)
|
|
417
|
+
*
|
|
418
|
+
* ex)
|
|
419
|
+
* Y축 label의 넓이와 (X축 최소값 label 넓이 / 2) 중 넓은 값이 left label offset으로 처리됨
|
|
420
|
+
*
|
|
421
|
+
* 0 |
|
|
422
|
+
* |
|
|
423
|
+
* |
|
|
424
|
+
* 0 ----------------------
|
|
425
|
+
* hh:mm hh:mm
|
|
426
|
+
*
|
|
427
|
+
* @returns {object} label offset for edge
|
|
428
|
+
*/
|
|
429
|
+
getLabelOffset() {
|
|
430
|
+
const axesX = this.axesX;
|
|
431
|
+
const axesY = this.axesY;
|
|
432
|
+
const range = this.axesRange;
|
|
433
|
+
const labelOffset = { top: 2, left: 2, right: 2, bottom: 2 };
|
|
434
|
+
const labelBuffer = { width: 14, height: 4 };
|
|
435
|
+
|
|
436
|
+
let lw = 0;
|
|
437
|
+
let lh = 0;
|
|
438
|
+
|
|
439
|
+
axesX.forEach((axis, index) => {
|
|
440
|
+
lw = range.x[index].size.width + labelBuffer.width;
|
|
441
|
+
lh = range.x[index].size.height + labelBuffer.height;
|
|
442
|
+
|
|
443
|
+
if (axis.position === 'bottom') {
|
|
444
|
+
if (lh > labelOffset.bottom) {
|
|
445
|
+
labelOffset.bottom = lh;
|
|
446
|
+
}
|
|
447
|
+
} else if (axis.position === 'top') {
|
|
448
|
+
if (lh > labelOffset.top) {
|
|
449
|
+
labelOffset.top = lh;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
labelOffset.left = (lw / 2) > labelOffset.left ? (lw / 2) : labelOffset.left;
|
|
454
|
+
labelOffset.right = (lw / 2) > labelOffset.right ? (lw / 2) : labelOffset.right;
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
axesY.forEach((axis, index) => {
|
|
458
|
+
lw = Math.max(range.y[index].size.width + labelBuffer.width, 42 + labelBuffer.width);
|
|
459
|
+
|
|
460
|
+
if (axis.position === 'left') {
|
|
461
|
+
if (lw > labelOffset.left) {
|
|
462
|
+
labelOffset.left = lw;
|
|
463
|
+
}
|
|
464
|
+
} else if (axis.position === 'right') {
|
|
465
|
+
if (lw > labelOffset.right) {
|
|
466
|
+
labelOffset.right = lw;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
labelOffset.top = (lh / 2) > labelOffset.top ? (lh / 2) : labelOffset.top;
|
|
471
|
+
labelOffset.bottom = (lh / 2) > labelOffset.bottom ? (lh / 2) : labelOffset.bottom;
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
return labelOffset;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* To re-render chart, reset properties, canvas and then render chart.
|
|
479
|
+
* @param {object} updateInfo information for each components are needed to update
|
|
480
|
+
*
|
|
481
|
+
* @returns {undefined}
|
|
482
|
+
*/
|
|
483
|
+
update(updateInfo) {
|
|
484
|
+
const options = this.options;
|
|
485
|
+
const data = this.data.data;
|
|
486
|
+
const labels = this.data.labels;
|
|
487
|
+
const groups = this.data.groups;
|
|
488
|
+
const series = this.data.series;
|
|
489
|
+
|
|
490
|
+
const { updateSeries, updateSelTip } = updateInfo;
|
|
491
|
+
|
|
492
|
+
if (!this.isInit) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
this.resetProps();
|
|
497
|
+
|
|
498
|
+
if (updateSeries) {
|
|
499
|
+
this.seriesInfo = null;
|
|
500
|
+
this.seriesList = null;
|
|
501
|
+
this.lastTip = null;
|
|
502
|
+
|
|
503
|
+
this.seriesInfo = {
|
|
504
|
+
charts: {
|
|
505
|
+
pie: [],
|
|
506
|
+
bar: [],
|
|
507
|
+
line: [],
|
|
508
|
+
scatter: [],
|
|
509
|
+
},
|
|
510
|
+
count: 0,
|
|
511
|
+
};
|
|
512
|
+
this.seriesList = {};
|
|
513
|
+
this.lastTip = { pos: null, value: null };
|
|
514
|
+
|
|
515
|
+
this.createSeriesSet(series, options.type);
|
|
516
|
+
|
|
517
|
+
if (this.legendDOM) {
|
|
518
|
+
this.resetLegend();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (updateSelTip.update) {
|
|
523
|
+
this.lastTip.value = null;
|
|
524
|
+
|
|
525
|
+
if (!updateSelTip.keepDomain) {
|
|
526
|
+
this.lastTip.pos = null;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (groups.length) {
|
|
531
|
+
this.addGroupInfo(groups);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
this.createDataSet(data, labels);
|
|
535
|
+
|
|
536
|
+
// title update
|
|
537
|
+
if (options.title.show) {
|
|
538
|
+
if (!this.isInitTitle) {
|
|
539
|
+
this.initTitle();
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
this.showTitle();
|
|
543
|
+
} else if (this.isInitTitle) {
|
|
544
|
+
this.hideTitle();
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (options.legend.show) {
|
|
548
|
+
if (!this.isInitLegend) {
|
|
549
|
+
this.initLegend();
|
|
550
|
+
} else if (updateSeries) {
|
|
551
|
+
this.updateLegend();
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
this.setLegendPosition();
|
|
555
|
+
this.updateLegendContainerSize();
|
|
556
|
+
this.showLegend();
|
|
557
|
+
} else if (this.isInitLegend) {
|
|
558
|
+
this.hideLegend();
|
|
559
|
+
}
|
|
560
|
+
this.chartRect = this.getChartRect();
|
|
561
|
+
|
|
562
|
+
this.minMax = this.getStoreMinMax();
|
|
563
|
+
this.axesX = this.createAxes('x', options.axesX);
|
|
564
|
+
this.axesY = this.createAxes('y', options.axesY);
|
|
565
|
+
this.axesRange = this.getAxesRange();
|
|
566
|
+
this.labelOffset = this.getLabelOffset();
|
|
567
|
+
|
|
568
|
+
this.render();
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* To re-render chart, reset properties
|
|
573
|
+
*
|
|
574
|
+
* @returns {undefined}
|
|
575
|
+
*/
|
|
576
|
+
resetProps() {
|
|
577
|
+
this.axesX[0] = null;
|
|
578
|
+
this.axesY[0] = null;
|
|
579
|
+
this.axesX = null;
|
|
580
|
+
this.axesY = null;
|
|
581
|
+
this.minMax = null;
|
|
582
|
+
this.axesRange = null;
|
|
583
|
+
this.labelOffset = null;
|
|
584
|
+
this.chartRect = null;
|
|
585
|
+
this.pieDataSet = [];
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Clear overlay canvas
|
|
590
|
+
*
|
|
591
|
+
* @returns {undefined}
|
|
592
|
+
*/
|
|
593
|
+
overlayClear() {
|
|
594
|
+
this.clearRectRatio = (this.pixelRatio < 1) ? this.pixelRatio : 1;
|
|
595
|
+
|
|
596
|
+
this.overlayCtx.clearRect(0, 0, this.overlayCanvas.width / this.clearRectRatio,
|
|
597
|
+
this.overlayCanvas.height / this.clearRectRatio);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Clear display and buffer canvas
|
|
602
|
+
*
|
|
603
|
+
* @returns {undefined}
|
|
604
|
+
*/
|
|
605
|
+
clear() {
|
|
606
|
+
this.clearRectRatio = (this.pixelRatio < 1) ? this.pixelRatio : 1;
|
|
607
|
+
|
|
608
|
+
this.displayCtx.clearRect(0, 0, this.displayCanvas.width / this.clearRectRatio,
|
|
609
|
+
this.displayCanvas.height / this.clearRectRatio);
|
|
610
|
+
this.bufferCtx.clearRect(0, 0, this.bufferCanvas.width / this.clearRectRatio,
|
|
611
|
+
this.bufferCanvas.height / this.clearRectRatio);
|
|
612
|
+
this.overlayCtx.clearRect(0, 0, this.overlayCanvas.width / this.clearRectRatio,
|
|
613
|
+
this.overlayCanvas.height / this.clearRectRatio);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Resize chart
|
|
618
|
+
*
|
|
619
|
+
* @returns {undefined}
|
|
620
|
+
*/
|
|
621
|
+
resize() {
|
|
622
|
+
this.clear();
|
|
623
|
+
this.bufferCtx.restore();
|
|
624
|
+
this.bufferCtx.save();
|
|
625
|
+
|
|
626
|
+
this.getChartDOMRect();
|
|
627
|
+
this.initScale();
|
|
628
|
+
this.drawChart();
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Render chart
|
|
633
|
+
* @param {any} [hitInfo=undefined] hit item from mouse click/dblclick
|
|
634
|
+
*
|
|
635
|
+
* @returns {undefined}
|
|
636
|
+
*/
|
|
637
|
+
render(hitInfo) {
|
|
638
|
+
this.clear();
|
|
639
|
+
this.chartRect = this.getChartRect();
|
|
640
|
+
this.initScale();
|
|
641
|
+
this.drawChart(hitInfo);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* destroy chart component
|
|
646
|
+
*
|
|
647
|
+
* @returns {undefined}
|
|
648
|
+
*/
|
|
649
|
+
destroy() {
|
|
650
|
+
if (!this.isInit) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const target = this.target;
|
|
655
|
+
|
|
656
|
+
if (this.options.legend.show) {
|
|
657
|
+
if (this.legendBoxDOM) {
|
|
658
|
+
this.legendBoxDOM.removeEventListener('click', this.onLegendBoxClick);
|
|
659
|
+
this.legendBoxDOM.removeEventListener('mouseover', this.onLegendBoxOver);
|
|
660
|
+
this.legendBoxDOM.removeEventListener('mouseleave', this.onLegendBoxLeave);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (this.resizeDOM) {
|
|
664
|
+
this.resizeDOM.removeEventListener('mousedown', this.onResizeMouseDown);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
if (this.overlayCanvas) {
|
|
669
|
+
this.overlayCanvas.removeEventListener('mousemove', this.onMouseMove);
|
|
670
|
+
this.overlayCanvas.removeEventListener('mouseleave', this.onMouseLeave);
|
|
671
|
+
this.overlayCanvas.removeEventListener('dblclick', this.onDblClick);
|
|
672
|
+
this.overlayCanvas.removeEventListener('click', this.onClick);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (this.options.tooltip.use) {
|
|
676
|
+
this.tooltipCanvas.remove();
|
|
677
|
+
this.tooltipCanvas = null;
|
|
678
|
+
this.tooltipDOM.remove();
|
|
679
|
+
this.tooltipDOM = null;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
this.wrapperDOM = null;
|
|
683
|
+
this.chartDOM = null;
|
|
684
|
+
this.legendDOM = null;
|
|
685
|
+
this.legendBoxDOM = null;
|
|
686
|
+
this.resizeDOM = null;
|
|
687
|
+
this.ghostDOM = null;
|
|
688
|
+
this.titleDOM = null;
|
|
689
|
+
this.displayCanvas = null;
|
|
690
|
+
this.bufferCanvas = null;
|
|
691
|
+
this.overlayCanvas = null;
|
|
692
|
+
|
|
693
|
+
while (target.hasChildNodes()) {
|
|
694
|
+
target.removeChild(target.firstChild);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
export default EvChart;
|