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,589 @@
|
|
|
1
|
+
const modules = {
|
|
2
|
+
/**
|
|
3
|
+
* Create legend DOM
|
|
4
|
+
*
|
|
5
|
+
* @returns {undefined}
|
|
6
|
+
*/
|
|
7
|
+
createLegendLayout() {
|
|
8
|
+
this.legendDOM = document.createElement('div');
|
|
9
|
+
this.legendDOM.className = 'ev-chart-legend';
|
|
10
|
+
this.legendBoxDOM = document.createElement('div');
|
|
11
|
+
this.legendBoxDOM.className = 'ev-chart-legend-box';
|
|
12
|
+
this.resizeDOM = document.createElement('div');
|
|
13
|
+
this.resizeDOM.className = 'ev-chart-resize-bar';
|
|
14
|
+
this.ghostDOM = document.createElement('div');
|
|
15
|
+
this.ghostDOM.className = 'ev-chart-resize-ghost';
|
|
16
|
+
|
|
17
|
+
this.wrapperDOM.appendChild(this.resizeDOM);
|
|
18
|
+
this.legendDOM.appendChild(this.legendBoxDOM);
|
|
19
|
+
this.wrapperDOM.appendChild(this.legendDOM);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Initialize legend
|
|
24
|
+
* If there was no initialization, create DOM and set default layout.
|
|
25
|
+
* It not, there will already be set layout, so add a legend for each series with group
|
|
26
|
+
*
|
|
27
|
+
* @returns {undefined}
|
|
28
|
+
*/
|
|
29
|
+
initLegend() {
|
|
30
|
+
if (!this.isInitLegend) {
|
|
31
|
+
this.createLegendLayout();
|
|
32
|
+
this.initEvent();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.addLegendList();
|
|
36
|
+
this.isInitLegend = true;
|
|
37
|
+
this.isLegendMove = false;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Add legend with group information to align each series properly.
|
|
42
|
+
* Especially if a chart is stacked,
|
|
43
|
+
* legends have to align with series ordering as we can see in chart.
|
|
44
|
+
*
|
|
45
|
+
* @returns {undefined}
|
|
46
|
+
*/
|
|
47
|
+
addLegendList() {
|
|
48
|
+
const groups = this.data.groups;
|
|
49
|
+
const seriesList = this.seriesList;
|
|
50
|
+
|
|
51
|
+
groups.forEach((group) => {
|
|
52
|
+
group.slice().reverse().forEach((sId) => {
|
|
53
|
+
if (seriesList[sId] && seriesList[sId].showLegend) {
|
|
54
|
+
this.addLegend(seriesList[sId]);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
Object.values(seriesList).forEach((series) => {
|
|
60
|
+
if (!series.isExistGrp && series.showLegend) {
|
|
61
|
+
this.addLegend(series);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Initialize legend event
|
|
68
|
+
*
|
|
69
|
+
* @returns {undefined}
|
|
70
|
+
*/
|
|
71
|
+
initEvent() {
|
|
72
|
+
/**
|
|
73
|
+
* callback for legendBoxDOM to show/hide clicked series
|
|
74
|
+
*
|
|
75
|
+
* @returns {undefined}
|
|
76
|
+
*/
|
|
77
|
+
this.onLegendBoxClick = (e) => {
|
|
78
|
+
const opt = this.options.legend;
|
|
79
|
+
const type = e.target.dataset.type;
|
|
80
|
+
|
|
81
|
+
let targetDOM;
|
|
82
|
+
if (type === 'container') {
|
|
83
|
+
targetDOM = e.target;
|
|
84
|
+
} else if (type === 'name' || type === 'color') {
|
|
85
|
+
targetDOM = e.target.parentElement;
|
|
86
|
+
} else {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const colorDOM = targetDOM.getElementsByClassName('ev-chart-legend-color')[0];
|
|
91
|
+
const nameDOM = targetDOM.getElementsByClassName('ev-chart-legend-name')[0];
|
|
92
|
+
const isActive = !colorDOM.className.includes('inactive');
|
|
93
|
+
const series = nameDOM.series;
|
|
94
|
+
|
|
95
|
+
if (isActive && this.seriesInfo.count === 1) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (isActive) {
|
|
100
|
+
this.seriesInfo.count--;
|
|
101
|
+
colorDOM.style.backgroundColor = opt.inactive;
|
|
102
|
+
nameDOM.style.color = opt.inactive;
|
|
103
|
+
} else {
|
|
104
|
+
this.seriesInfo.count++;
|
|
105
|
+
colorDOM.style.backgroundColor = series.color;
|
|
106
|
+
nameDOM.style.color = opt.color;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
series.show = !series.show;
|
|
110
|
+
colorDOM.classList.toggle('inactive');
|
|
111
|
+
nameDOM.classList.toggle('inactive');
|
|
112
|
+
|
|
113
|
+
this.update({
|
|
114
|
+
updateSeries: false,
|
|
115
|
+
updateSelTip: { update: true, keepDomain: true },
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* callback for resizeDOM click event
|
|
121
|
+
* 1. hide resizeDOM
|
|
122
|
+
* 2. show ghost DOM on same position with hidden resizeDOM
|
|
123
|
+
*
|
|
124
|
+
* @returns {undefined}
|
|
125
|
+
*/
|
|
126
|
+
this.onResizeMouseDown = (e) => {
|
|
127
|
+
e.stopPropagation();
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
|
|
130
|
+
const opt = this.options;
|
|
131
|
+
const pos = opt.legend.position;
|
|
132
|
+
const title = opt.title.show ? opt.title.height : 0;
|
|
133
|
+
|
|
134
|
+
const ghostDOM = this.ghostDOM;
|
|
135
|
+
this.resizeDOM.style.display = 'none';
|
|
136
|
+
this.wrapperDOM.appendChild(ghostDOM);
|
|
137
|
+
|
|
138
|
+
// mouse down 시, resizeDOM의 위치를 기반으로 ghostDOM의 위치를 세팅
|
|
139
|
+
if (pos === 'left' || pos === 'right') {
|
|
140
|
+
ghostDOM.style.top = `${title}px`;
|
|
141
|
+
ghostDOM.style.left = this.resizeDOM.style.left;
|
|
142
|
+
ghostDOM.style.right = this.resizeDOM.style.right;
|
|
143
|
+
ghostDOM.style.height = this.resizeDOM.style.height;
|
|
144
|
+
} else {
|
|
145
|
+
ghostDOM.classList.add('horizontal');
|
|
146
|
+
|
|
147
|
+
if (pos === 'top') {
|
|
148
|
+
ghostDOM.style.top = this.resizeDOM.style.top;
|
|
149
|
+
} else if (pos === 'bottom') {
|
|
150
|
+
ghostDOM.style.bottom = this.resizeDOM.style.bottom;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.wrapperDOM.addEventListener('mousemove', this.mouseMove, false);
|
|
155
|
+
this.wrapperDOM.addEventListener('mouseup', this.mouseUp, false);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* callback for legendBoxDOM hovering
|
|
160
|
+
*
|
|
161
|
+
* @returns {undefined}
|
|
162
|
+
*/
|
|
163
|
+
this.onLegendBoxOver = (e) => {
|
|
164
|
+
const type = e.target.dataset.type;
|
|
165
|
+
|
|
166
|
+
let targetDOM;
|
|
167
|
+
if (type === 'container') {
|
|
168
|
+
targetDOM = e.target;
|
|
169
|
+
} else if (type === 'name' || type === 'color') {
|
|
170
|
+
targetDOM = e.target.parentElement;
|
|
171
|
+
} else {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const nameDOM = targetDOM.getElementsByClassName('ev-chart-legend-name')[0];
|
|
175
|
+
const targetId = nameDOM.series.sId;
|
|
176
|
+
|
|
177
|
+
Object.values(this.seriesList).forEach((series) => {
|
|
178
|
+
series.state = series.sId === targetId ? 'highlight' : 'downplay';
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
this.update({
|
|
182
|
+
updateSeries: false,
|
|
183
|
+
updateSelTip: { update: false, keepDomain: false },
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* callback for mouseleave event on legendBoxDOM
|
|
189
|
+
*
|
|
190
|
+
* @returns {undefined}
|
|
191
|
+
*/
|
|
192
|
+
this.onLegendBoxLeave = () => {
|
|
193
|
+
Object.values(this.seriesList).forEach((series) => {
|
|
194
|
+
series.state = 'normal';
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
this.update({
|
|
198
|
+
updateSeries: false,
|
|
199
|
+
updateSelTip: { update: false, keepDomain: false },
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
this.legendBoxDOM.addEventListener('click', this.onLegendBoxClick);
|
|
204
|
+
this.legendBoxDOM.addEventListener('mouseover', this.onLegendBoxOver);
|
|
205
|
+
this.legendBoxDOM.addEventListener('mouseleave', this.onLegendBoxLeave);
|
|
206
|
+
this.resizeDOM.addEventListener('mousedown', this.onResizeMouseDown);
|
|
207
|
+
|
|
208
|
+
this.mouseMove = this.onMouseMove.bind(this); // resizing function
|
|
209
|
+
this.mouseUp = this.onMouseUp.bind(this); // resizing function
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* To update legend, reset all process.
|
|
214
|
+
*
|
|
215
|
+
* @returns {undefined}
|
|
216
|
+
*/
|
|
217
|
+
updateLegend() {
|
|
218
|
+
this.resetLegend();
|
|
219
|
+
this.addLegendList();
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* To update legend, remove all of legendBoxDOM's children
|
|
224
|
+
*
|
|
225
|
+
* @returns {undefined}
|
|
226
|
+
*/
|
|
227
|
+
resetLegend() {
|
|
228
|
+
const legendDOM = this.legendBoxDOM;
|
|
229
|
+
|
|
230
|
+
while (legendDOM.hasChildNodes()) {
|
|
231
|
+
legendDOM.removeChild(legendDOM.firstChild);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Create DOM for each series
|
|
237
|
+
*
|
|
238
|
+
* @returns {undefined}
|
|
239
|
+
*/
|
|
240
|
+
addLegend(series) {
|
|
241
|
+
const opt = this.options.legend;
|
|
242
|
+
const containerDOM = document.createElement('div');
|
|
243
|
+
const colorDOM = document.createElement('span');
|
|
244
|
+
const nameDOM = document.createElement('div');
|
|
245
|
+
|
|
246
|
+
containerDOM.className = 'ev-chart-legend-container';
|
|
247
|
+
colorDOM.className = 'ev-chart-legend-color';
|
|
248
|
+
nameDOM.className = 'ev-chart-legend-name';
|
|
249
|
+
|
|
250
|
+
nameDOM.series = series;
|
|
251
|
+
|
|
252
|
+
colorDOM.style.backgroundColor = series.color;
|
|
253
|
+
colorDOM.dataset.type = 'color';
|
|
254
|
+
nameDOM.style.color = opt.color;
|
|
255
|
+
nameDOM.textContent = series.name;
|
|
256
|
+
nameDOM.setAttribute('title', series.name);
|
|
257
|
+
nameDOM.dataset.type = 'name';
|
|
258
|
+
|
|
259
|
+
this.legendDOM.style.padding = '5px 0 0 0';
|
|
260
|
+
|
|
261
|
+
containerDOM.appendChild(colorDOM);
|
|
262
|
+
containerDOM.appendChild(nameDOM);
|
|
263
|
+
|
|
264
|
+
if (opt.position === 'top' || opt.position === 'bottom') {
|
|
265
|
+
containerDOM.style.width = `${opt.width - 8}px`;
|
|
266
|
+
containerDOM.style.margin = '0 4px';
|
|
267
|
+
} else {
|
|
268
|
+
containerDOM.style.width = '100%';
|
|
269
|
+
}
|
|
270
|
+
containerDOM.style.height = '18px';
|
|
271
|
+
containerDOM.style.display = 'inline-block';
|
|
272
|
+
containerDOM.dataset.type = 'container';
|
|
273
|
+
|
|
274
|
+
this.legendBoxDOM.appendChild(containerDOM);
|
|
275
|
+
this.seriesInfo.count++;
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Set legend components position by option
|
|
280
|
+
*
|
|
281
|
+
* @returns {undefined}
|
|
282
|
+
*/
|
|
283
|
+
setLegendPosition() {
|
|
284
|
+
const opt = this.options;
|
|
285
|
+
const position = opt.legend.position;
|
|
286
|
+
const wrapperStyle = this.wrapperDOM.style;
|
|
287
|
+
const legendStyle = this.legendDOM.style;
|
|
288
|
+
const boxStyle = this.legendBoxDOM.style;
|
|
289
|
+
const resizeStyle = this.resizeDOM.style;
|
|
290
|
+
|
|
291
|
+
let chartRect;
|
|
292
|
+
const title = opt.title.show ? opt.title.height : 0;
|
|
293
|
+
const top = title + opt.legend.height;
|
|
294
|
+
|
|
295
|
+
switch (position) {
|
|
296
|
+
case 'top':
|
|
297
|
+
wrapperStyle.padding = `${top}px 0 0 0`;
|
|
298
|
+
chartRect = this.chartDOM.getBoundingClientRect();
|
|
299
|
+
|
|
300
|
+
boxStyle.width = '100%';
|
|
301
|
+
boxStyle.height = `${opt.legend.height}px`;
|
|
302
|
+
|
|
303
|
+
legendStyle.top = `${title}px`;
|
|
304
|
+
legendStyle.right = '';
|
|
305
|
+
legendStyle.bottom = '';
|
|
306
|
+
legendStyle.left = '';
|
|
307
|
+
|
|
308
|
+
legendStyle.width = `${chartRect.width}px`;
|
|
309
|
+
legendStyle.height = `${opt.legend.height + 4}px`; // 4 resize bar size
|
|
310
|
+
|
|
311
|
+
resizeStyle.top = `${top}px`;
|
|
312
|
+
resizeStyle.right = '';
|
|
313
|
+
resizeStyle.bottom = '';
|
|
314
|
+
resizeStyle.left = '';
|
|
315
|
+
|
|
316
|
+
resizeStyle.width = `${chartRect.width}px`;
|
|
317
|
+
resizeStyle.height = '4px';
|
|
318
|
+
resizeStyle.cursor = 'row-resize';
|
|
319
|
+
break;
|
|
320
|
+
case 'right':
|
|
321
|
+
wrapperStyle.padding = `${title}px ${opt.legend.width}px 0 0`;
|
|
322
|
+
chartRect = this.chartDOM.getBoundingClientRect();
|
|
323
|
+
|
|
324
|
+
boxStyle.width = `${opt.legend.width - 10}px`; // legendDOM left padding
|
|
325
|
+
boxStyle.height = `${chartRect.height}px`;
|
|
326
|
+
|
|
327
|
+
legendStyle.paddingLeft = '10px';
|
|
328
|
+
legendStyle.top = `${title}px`;
|
|
329
|
+
legendStyle.right = '0px';
|
|
330
|
+
legendStyle.bottom = '';
|
|
331
|
+
legendStyle.left = '';
|
|
332
|
+
|
|
333
|
+
legendStyle.width = `${opt.legend.width}px`;
|
|
334
|
+
legendStyle.height = `${chartRect.height}px`;
|
|
335
|
+
|
|
336
|
+
resizeStyle.top = `${title}px`;
|
|
337
|
+
resizeStyle.right = `${opt.legend.width}px`;
|
|
338
|
+
resizeStyle.bottom = '';
|
|
339
|
+
resizeStyle.left = '';
|
|
340
|
+
|
|
341
|
+
resizeStyle.width = '4px';
|
|
342
|
+
resizeStyle.height = `${chartRect.height}px`;
|
|
343
|
+
resizeStyle.cursor = 'col-resize';
|
|
344
|
+
break;
|
|
345
|
+
case 'bottom':
|
|
346
|
+
wrapperStyle.padding = `${title}px 0 ${opt.legend.height}px 0`;
|
|
347
|
+
chartRect = this.chartDOM.getBoundingClientRect();
|
|
348
|
+
|
|
349
|
+
boxStyle.width = '100%';
|
|
350
|
+
boxStyle.height = `${opt.legend.height}px`;
|
|
351
|
+
|
|
352
|
+
legendStyle.top = '';
|
|
353
|
+
legendStyle.right = '';
|
|
354
|
+
legendStyle.bottom = '0px';
|
|
355
|
+
legendStyle.left = '0px';
|
|
356
|
+
|
|
357
|
+
legendStyle.width = `${chartRect.width}px`;
|
|
358
|
+
legendStyle.height = `${opt.legend.height + 4}px`; // 4 resize bar size
|
|
359
|
+
|
|
360
|
+
resizeStyle.top = '';
|
|
361
|
+
resizeStyle.right = '';
|
|
362
|
+
resizeStyle.bottom = `${opt.legend.height}px`;
|
|
363
|
+
resizeStyle.left = '';
|
|
364
|
+
|
|
365
|
+
resizeStyle.width = `${chartRect.width}px`;
|
|
366
|
+
resizeStyle.height = '4px';
|
|
367
|
+
resizeStyle.cursor = 'row-resize';
|
|
368
|
+
break;
|
|
369
|
+
case 'left':
|
|
370
|
+
wrapperStyle.padding = `${title}px 0 0 ${opt.legend.width}px`;
|
|
371
|
+
chartRect = this.chartDOM.getBoundingClientRect();
|
|
372
|
+
|
|
373
|
+
boxStyle.width = `${opt.legend.width}px`;
|
|
374
|
+
boxStyle.height = `${chartRect.height}px`;
|
|
375
|
+
boxStyle.display = 'absolute';
|
|
376
|
+
boxStyle.bottom = '0px';
|
|
377
|
+
|
|
378
|
+
legendStyle.top = `${title}px`;
|
|
379
|
+
legendStyle.right = '';
|
|
380
|
+
legendStyle.bottom = '';
|
|
381
|
+
legendStyle.left = '0px';
|
|
382
|
+
|
|
383
|
+
legendStyle.width = `${opt.legend.width}px`;
|
|
384
|
+
legendStyle.height = `${chartRect.height}px`;
|
|
385
|
+
|
|
386
|
+
resizeStyle.top = `${title}px`;
|
|
387
|
+
resizeStyle.right = '';
|
|
388
|
+
resizeStyle.bottom = '';
|
|
389
|
+
resizeStyle.left = `${opt.legend.width}px`;
|
|
390
|
+
|
|
391
|
+
resizeStyle.width = '4px';
|
|
392
|
+
resizeStyle.height = `${chartRect.height}px`;
|
|
393
|
+
resizeStyle.cursor = 'col-resize';
|
|
394
|
+
break;
|
|
395
|
+
default:
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Update legend components size
|
|
402
|
+
*
|
|
403
|
+
* @returns {undefined}
|
|
404
|
+
*/
|
|
405
|
+
updateLegendContainerSize() {
|
|
406
|
+
const opt = this.options.legend;
|
|
407
|
+
const container = this.legendBoxDOM.getElementsByClassName('ev-chart-legend-container');
|
|
408
|
+
|
|
409
|
+
for (let ix = 0; ix < container.length; ix++) {
|
|
410
|
+
if (opt.position === 'top' || opt.position === 'bottom') {
|
|
411
|
+
container[ix].style.width = `${opt.width - 8}px`;
|
|
412
|
+
container[ix].style.margin = '0 4px';
|
|
413
|
+
} else {
|
|
414
|
+
container[ix].style.width = '100%';
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* When user moves resizeDOM, this function will change css
|
|
421
|
+
*
|
|
422
|
+
* @returns {undefined}
|
|
423
|
+
*/
|
|
424
|
+
onMouseMove(e) {
|
|
425
|
+
e.stopPropagation();
|
|
426
|
+
e.preventDefault();
|
|
427
|
+
|
|
428
|
+
const offset = this.wrapperDOM.getBoundingClientRect();
|
|
429
|
+
const offsetWidth = this.wrapperDOM.offsetWidth;
|
|
430
|
+
const offsetHeight = this.wrapperDOM.offsetHeight;
|
|
431
|
+
|
|
432
|
+
const titleHeight = this.options.title.show ? this.options.title.height : 0;
|
|
433
|
+
const position = this.options.legend.position;
|
|
434
|
+
|
|
435
|
+
const chartMinWidth = 150;
|
|
436
|
+
const chartMinHeight = 70;
|
|
437
|
+
|
|
438
|
+
const legendMinWidth = 120;
|
|
439
|
+
const legendMinHeight = 20;
|
|
440
|
+
|
|
441
|
+
let move;
|
|
442
|
+
|
|
443
|
+
switch (position) {
|
|
444
|
+
case 'left':
|
|
445
|
+
move = e.clientX - offset.left;
|
|
446
|
+
if (move < legendMinWidth) {
|
|
447
|
+
move = legendMinWidth;
|
|
448
|
+
} else if (move > offsetWidth - chartMinWidth) {
|
|
449
|
+
move = offsetWidth - chartMinWidth;
|
|
450
|
+
}
|
|
451
|
+
this.ghostDOM.style.left = `${move}px`;
|
|
452
|
+
break;
|
|
453
|
+
case 'right':
|
|
454
|
+
move = e.clientX - offset.left;
|
|
455
|
+
if (move < chartMinWidth) {
|
|
456
|
+
move = chartMinWidth;
|
|
457
|
+
} else if (move > offsetWidth - legendMinWidth) {
|
|
458
|
+
move = offsetWidth - legendMinWidth;
|
|
459
|
+
}
|
|
460
|
+
this.ghostDOM.style.left = `${move}px`;
|
|
461
|
+
break;
|
|
462
|
+
case 'top':
|
|
463
|
+
move = e.clientY - offset.top;
|
|
464
|
+
if (move < legendMinHeight + titleHeight) {
|
|
465
|
+
move = legendMinHeight + titleHeight;
|
|
466
|
+
} else if (move > offsetHeight - chartMinHeight) {
|
|
467
|
+
move = offsetHeight - chartMinHeight;
|
|
468
|
+
}
|
|
469
|
+
this.ghostDOM.style.top = `${move}px`;
|
|
470
|
+
break;
|
|
471
|
+
case 'bottom':
|
|
472
|
+
move = e.clientY - offset.top;
|
|
473
|
+
if (move < chartMinHeight + titleHeight) {
|
|
474
|
+
move = chartMinHeight + titleHeight;
|
|
475
|
+
} else if (move > offsetHeight - legendMinHeight) {
|
|
476
|
+
move = offsetHeight - legendMinHeight;
|
|
477
|
+
}
|
|
478
|
+
this.ghostDOM.style.bottom = `${this.wrapperDOM.offsetHeight - move}px`;
|
|
479
|
+
break;
|
|
480
|
+
default:
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
this.isLegendMove = true;
|
|
485
|
+
},
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* callback for mouseup on ghostDOM, this function will change legend and chart size.
|
|
489
|
+
*
|
|
490
|
+
* @returns {undefined}
|
|
491
|
+
*/
|
|
492
|
+
onMouseUp(e) {
|
|
493
|
+
e.stopPropagation();
|
|
494
|
+
e.preventDefault();
|
|
495
|
+
|
|
496
|
+
this.wrapperDOM.removeEventListener('mousemove', this.mouseMove, false);
|
|
497
|
+
this.wrapperDOM.removeEventListener('mouseup', this.mouseUp, false);
|
|
498
|
+
|
|
499
|
+
const opt = this.options;
|
|
500
|
+
const pos = opt.legend.position;
|
|
501
|
+
const resizeDOMStyle = this.resizeDOM.style;
|
|
502
|
+
const legendDOMStyle = this.legendDOM.style;
|
|
503
|
+
const boxDOMStyle = this.legendBoxDOM.style;
|
|
504
|
+
const ghostDOMStyle = this.ghostDOM.style;
|
|
505
|
+
const wrapperDOMStyle = this.wrapperDOM.style;
|
|
506
|
+
|
|
507
|
+
const title = opt.title.show ? opt.title.height : 0;
|
|
508
|
+
const padding = +this.legendDOM.style.paddingLeft.replace('px', '');
|
|
509
|
+
let move;
|
|
510
|
+
if (this.isLegendMove) {
|
|
511
|
+
switch (pos) {
|
|
512
|
+
case 'top':
|
|
513
|
+
resizeDOMStyle.top = ghostDOMStyle.top;
|
|
514
|
+
move = +ghostDOMStyle.top.replace('px', '');
|
|
515
|
+
legendDOMStyle.height = `${move - title}px`;
|
|
516
|
+
boxDOMStyle.height = `${move - title - 4}px`;
|
|
517
|
+
opt.legend.height = move - title - 4;
|
|
518
|
+
wrapperDOMStyle.padding = `${move}px 0 0 0`;
|
|
519
|
+
break;
|
|
520
|
+
case 'right':
|
|
521
|
+
resizeDOMStyle.left = ghostDOMStyle.left;
|
|
522
|
+
move = +ghostDOMStyle.left.replace('px', '');
|
|
523
|
+
legendDOMStyle.width = `${(this.wrapperDOM.offsetWidth - move - 4)}px`;
|
|
524
|
+
boxDOMStyle.width = `${(this.wrapperDOM.offsetWidth - move - 4 - padding)}px`;
|
|
525
|
+
opt.legend.width = this.wrapperDOM.offsetWidth - move - 4;
|
|
526
|
+
wrapperDOMStyle.padding = `${title}px ${this.wrapperDOM.offsetWidth - move}px 0 0`;
|
|
527
|
+
break;
|
|
528
|
+
case 'bottom':
|
|
529
|
+
resizeDOMStyle.bottom = ghostDOMStyle.bottom;
|
|
530
|
+
move = this.wrapperDOM.offsetHeight - (+ghostDOMStyle.bottom.replace('px', ''));
|
|
531
|
+
legendDOMStyle.height = `${this.wrapperDOM.offsetHeight - move}px`;
|
|
532
|
+
boxDOMStyle.height = `${move - title - 4}px`;
|
|
533
|
+
opt.legend.height = this.wrapperDOM.offsetHeight - move;
|
|
534
|
+
wrapperDOMStyle.padding = `${title}px 0 ${this.wrapperDOM.offsetHeight - move}px 0`;
|
|
535
|
+
break;
|
|
536
|
+
case 'left':
|
|
537
|
+
resizeDOMStyle.left = ghostDOMStyle.left;
|
|
538
|
+
move = +ghostDOMStyle.left.replace('px', '');
|
|
539
|
+
legendDOMStyle.width = `${move}px`;
|
|
540
|
+
boxDOMStyle.width = `${move}px`;
|
|
541
|
+
opt.legend.width = move;
|
|
542
|
+
wrapperDOMStyle.padding = `${title}px 0 0 ${move - 4}px`;
|
|
543
|
+
break;
|
|
544
|
+
default:
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
resizeDOMStyle.display = 'block';
|
|
550
|
+
this.ghostDOM.remove();
|
|
551
|
+
|
|
552
|
+
if (this.isLegendMove) {
|
|
553
|
+
this.render();
|
|
554
|
+
this.isLegendMove = false;
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Show legend components by manipulating css
|
|
560
|
+
*
|
|
561
|
+
* @returns {undefined}
|
|
562
|
+
*/
|
|
563
|
+
showLegend() {
|
|
564
|
+
this.resizeDOM.style.display = 'block';
|
|
565
|
+
this.legendDOM.style.display = 'block';
|
|
566
|
+
},
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Hide legend components by manipulating css
|
|
570
|
+
*
|
|
571
|
+
* @returns {undefined}
|
|
572
|
+
*/
|
|
573
|
+
hideLegend() {
|
|
574
|
+
const opt = this.options;
|
|
575
|
+
const wrapperStyle = this.wrapperDOM.style;
|
|
576
|
+
const resizeStyle = this.resizeDOM.style;
|
|
577
|
+
const legendStyle = this.legendDOM.style;
|
|
578
|
+
const title = opt.title.show ? opt.title.height : 0;
|
|
579
|
+
|
|
580
|
+
resizeStyle.display = 'none';
|
|
581
|
+
legendStyle.display = 'none';
|
|
582
|
+
|
|
583
|
+
legendStyle.width = '0';
|
|
584
|
+
legendStyle.height = '0';
|
|
585
|
+
wrapperStyle.padding = `${title}px 0 0 0`;
|
|
586
|
+
},
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
export default modules;
|