evui 3.4.207 → 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.
Files changed (162) hide show
  1. package/README.md +18 -33
  2. package/dist/404.html +44 -0
  3. package/dist/favicon.ico +0 -0
  4. package/dist/index.js +22645 -0
  5. package/dist/index.umd.cjs +28 -0
  6. package/dist/style.css +1 -0
  7. package/package.json +46 -43
  8. package/dist/evui.common.js +0 -63681
  9. package/dist/evui.common.js.map +0 -1
  10. package/dist/evui.umd.js +0 -63691
  11. package/dist/evui.umd.js.map +0 -1
  12. package/dist/evui.umd.min.js +0 -2
  13. package/dist/evui.umd.min.js.map +0 -1
  14. package/dist/img/EVUI.b82ee81a.svg +0 -293
  15. package/src/assets/logo.png +0 -0
  16. package/src/common/emitter.js +0 -20
  17. package/src/common/utils.bignumber.js +0 -67
  18. package/src/common/utils.debounce.js +0 -223
  19. package/src/common/utils.js +0 -151
  20. package/src/common/utils.table.js +0 -78
  21. package/src/common/utils.throttle.js +0 -83
  22. package/src/common/utils.tree.js +0 -18
  23. package/src/components/button/Button.vue +0 -195
  24. package/src/components/button/index.js +0 -7
  25. package/src/components/buttonGroup/ButtonGroup.vue +0 -11
  26. package/src/components/buttonGroup/index.js +0 -7
  27. package/src/components/calendar/Calendar.vue +0 -725
  28. package/src/components/calendar/index.js +0 -7
  29. package/src/components/calendar/uses.js +0 -1410
  30. package/src/components/chart/Chart.vue +0 -363
  31. package/src/components/chart/ChartToolbar.vue +0 -52
  32. package/src/components/chart/chart.core.js +0 -1170
  33. package/src/components/chart/chartZoom.core.js +0 -540
  34. package/src/components/chart/element/element.bar.js +0 -672
  35. package/src/components/chart/element/element.bar.time.js +0 -166
  36. package/src/components/chart/element/element.heatmap.js +0 -743
  37. package/src/components/chart/element/element.line.js +0 -611
  38. package/src/components/chart/element/element.pie.js +0 -197
  39. package/src/components/chart/element/element.scatter.js +0 -320
  40. package/src/components/chart/element/element.tip.js +0 -717
  41. package/src/components/chart/helpers/helpers.canvas.js +0 -265
  42. package/src/components/chart/helpers/helpers.constant.js +0 -235
  43. package/src/components/chart/helpers/helpers.util.js +0 -400
  44. package/src/components/chart/index.js +0 -9
  45. package/src/components/chart/model/index.js +0 -50
  46. package/src/components/chart/model/model.series.js +0 -125
  47. package/src/components/chart/model/model.store.js +0 -1427
  48. package/src/components/chart/plugins/plugins.interaction.js +0 -1659
  49. package/src/components/chart/plugins/plugins.legend.gradient.js +0 -606
  50. package/src/components/chart/plugins/plugins.legend.js +0 -1543
  51. package/src/components/chart/plugins/plugins.pie.js +0 -254
  52. package/src/components/chart/plugins/plugins.scrollbar.js +0 -732
  53. package/src/components/chart/plugins/plugins.title.js +0 -61
  54. package/src/components/chart/plugins/plugins.tooltip.js +0 -1041
  55. package/src/components/chart/scale/scale.js +0 -951
  56. package/src/components/chart/scale/scale.linear.js +0 -268
  57. package/src/components/chart/scale/scale.logarithmic.js +0 -135
  58. package/src/components/chart/scale/scale.step.js +0 -430
  59. package/src/components/chart/scale/scale.time.category.js +0 -338
  60. package/src/components/chart/scale/scale.time.js +0 -49
  61. package/src/components/chart/style/chart.scss +0 -405
  62. package/src/components/chart/uses.js +0 -721
  63. package/src/components/chartBrush/ChartBrush.vue +0 -323
  64. package/src/components/chartBrush/chartBrush.core.js +0 -691
  65. package/src/components/chartBrush/index.js +0 -9
  66. package/src/components/chartBrush/uses.js +0 -23
  67. package/src/components/chartGroup/ChartGroup.vue +0 -144
  68. package/src/components/chartGroup/index.js +0 -9
  69. package/src/components/chartGroup/style/chartGroup.scss +0 -5
  70. package/src/components/chartGroup/uses.js +0 -53
  71. package/src/components/checkbox/Checkbox.vue +0 -229
  72. package/src/components/checkbox/index.js +0 -7
  73. package/src/components/checkboxGroup/CheckboxGroup.vue +0 -44
  74. package/src/components/checkboxGroup/index.js +0 -7
  75. package/src/components/contextMenu/ContextMenu.vue +0 -95
  76. package/src/components/contextMenu/MenuList.vue +0 -182
  77. package/src/components/contextMenu/index.js +0 -7
  78. package/src/components/contextMenu/uses.js +0 -223
  79. package/src/components/datePicker/DatePicker.vue +0 -504
  80. package/src/components/datePicker/index.js +0 -7
  81. package/src/components/datePicker/uses.js +0 -460
  82. package/src/components/grid/Grid.vue +0 -1535
  83. package/src/components/grid/GridColumnSetting.vue +0 -358
  84. package/src/components/grid/GridFilterSetting.vue +0 -323
  85. package/src/components/grid/GridPagination.vue +0 -75
  86. package/src/components/grid/GridSummary.vue +0 -314
  87. package/src/components/grid/GridToolbar.vue +0 -35
  88. package/src/components/grid/icon/icon-option-button.vue +0 -17
  89. package/src/components/grid/icon/icon-sort-button.vue +0 -67
  90. package/src/components/grid/index.js +0 -11
  91. package/src/components/grid/style/grid.scss +0 -417
  92. package/src/components/grid/uses.js +0 -1629
  93. package/src/components/icon/Icon.vue +0 -53
  94. package/src/components/icon/index.js +0 -8
  95. package/src/components/inputNumber/InputNumber.vue +0 -212
  96. package/src/components/inputNumber/index.js +0 -7
  97. package/src/components/inputNumber/uses.js +0 -217
  98. package/src/components/loading/Loading.vue +0 -125
  99. package/src/components/loading/index.js +0 -7
  100. package/src/components/menu/Menu.vue +0 -79
  101. package/src/components/menu/MenuItem.vue +0 -201
  102. package/src/components/menu/index.js +0 -7
  103. package/src/components/message/Message.vue +0 -229
  104. package/src/components/message/index.js +0 -34
  105. package/src/components/messageBox/MessageBox.vue +0 -358
  106. package/src/components/messageBox/index.js +0 -22
  107. package/src/components/notification/Notification.vue +0 -316
  108. package/src/components/notification/index.js +0 -49
  109. package/src/components/pagination/Pagination.vue +0 -317
  110. package/src/components/pagination/index.js +0 -7
  111. package/src/components/pagination/pageButton.vue +0 -31
  112. package/src/components/progress/Progress.vue +0 -139
  113. package/src/components/progress/index.js +0 -7
  114. package/src/components/radio/Radio.vue +0 -159
  115. package/src/components/radio/index.js +0 -7
  116. package/src/components/radioGroup/RadioGroup.vue +0 -41
  117. package/src/components/radioGroup/index.js +0 -7
  118. package/src/components/scheduler/Scheduler.vue +0 -149
  119. package/src/components/scheduler/index.js +0 -7
  120. package/src/components/scheduler/uses.js +0 -183
  121. package/src/components/select/Select.vue +0 -556
  122. package/src/components/select/index.js +0 -7
  123. package/src/components/select/uses.js +0 -379
  124. package/src/components/slider/Slider.vue +0 -505
  125. package/src/components/slider/index.js +0 -7
  126. package/src/components/slider/uses.js +0 -391
  127. package/src/components/tabPanel/TabPanel.vue +0 -74
  128. package/src/components/tabPanel/index.js +0 -7
  129. package/src/components/tabs/Tabs.vue +0 -517
  130. package/src/components/tabs/index.js +0 -7
  131. package/src/components/textField/TextField.vue +0 -399
  132. package/src/components/textField/index.js +0 -7
  133. package/src/components/timePicker/TimePicker.vue +0 -364
  134. package/src/components/timePicker/index.js +0 -7
  135. package/src/components/toggle/Toggle.vue +0 -115
  136. package/src/components/toggle/index.js +0 -7
  137. package/src/components/tree/Tree.vue +0 -338
  138. package/src/components/tree/TreeNode.vue +0 -293
  139. package/src/components/tree/index.js +0 -7
  140. package/src/components/treeGrid/TreeGrid.vue +0 -1074
  141. package/src/components/treeGrid/TreeGridNode.vue +0 -349
  142. package/src/components/treeGrid/TreeGridToolbar.vue +0 -35
  143. package/src/components/treeGrid/icon/icon-tree.png +0 -0
  144. package/src/components/treeGrid/index.js +0 -9
  145. package/src/components/treeGrid/style/treeGrid.scss +0 -277
  146. package/src/components/treeGrid/uses.js +0 -1178
  147. package/src/components/window/Window.vue +0 -329
  148. package/src/components/window/index.js +0 -7
  149. package/src/components/window/uses.js +0 -908
  150. package/src/directives/clickoutside.js +0 -90
  151. package/src/main.js +0 -120
  152. package/src/style/components/input.scss +0 -108
  153. package/src/style/functions.scss +0 -3
  154. package/src/style/index.scss +0 -6
  155. package/src/style/lib/fonts/EVUI.eot +0 -0
  156. package/src/style/lib/fonts/EVUI.svg +0 -293
  157. package/src/style/lib/fonts/EVUI.ttf +0 -0
  158. package/src/style/lib/fonts/EVUI.woff +0 -0
  159. package/src/style/lib/icon.css +0 -888
  160. package/src/style/mixins.scss +0 -94
  161. package/src/style/themes.scss +0 -69
  162. package/src/style/variables.scss +0 -22
@@ -1,606 +0,0 @@
1
- import { convertToPercent } from '../../../common/utils';
2
-
3
- const MAX_HANDLE_SIZE = 28;
4
-
5
- const MIN_BOX_SIZE = {
6
- width: 70,
7
- height: 60,
8
- };
9
-
10
- const modules = {
11
- /**
12
- * Create legend DOM
13
- *
14
- * @returns {undefined}
15
- */
16
- createLegendLayout() {
17
- this.legendDOM = document.createElement('div');
18
- this.legendDOM.className = 'ev-chart-legend';
19
- this.legendBoxDOM = document.createElement('div');
20
- this.legendBoxDOM.className = 'ev-chart-legend-box';
21
- this.containerDOM = document.createElement('div');
22
- this.containerDOM.className = 'ev-chart-legend-container';
23
-
24
- this.legendBoxDOM.appendChild(this.containerDOM);
25
- this.legendDOM.appendChild(this.legendBoxDOM);
26
- this.wrapperDOM.appendChild(this.legendDOM);
27
- },
28
-
29
- /**
30
- * Initialize legend
31
- * If there was no initialization, create DOM and set default layout.
32
- * It not, there will already be set layout, so add a legend for each series with group
33
- *
34
- * @returns {undefined}
35
- */
36
- initLegend() {
37
- if (!this.isInitLegend) {
38
- this.createLegendLayout();
39
- this.createLegend();
40
- }
41
-
42
- Object.values(this.seriesList).forEach((series) => {
43
- this.setLegendStyle(series);
44
- });
45
- this.initEvent();
46
-
47
- this.isInitLegend = true;
48
- this.legendDragInfo = {
49
- dragging: false,
50
- isStart: true,
51
- };
52
- },
53
-
54
- /**
55
- * Initialize legend event
56
- *
57
- * @returns {undefined}
58
- */
59
- initEvent() {
60
- if (this.isInitLegend) {
61
- return;
62
- }
63
-
64
- this.onLegendMouseDown = (e) => {
65
- e.stopPropagation();
66
- e.preventDefault();
67
-
68
- const type = e.target.dataset.type;
69
-
70
- let targetDOM;
71
- if (type === 'handle') {
72
- targetDOM = e.target;
73
- } else if (type === 'handle-btn') {
74
- targetDOM = e.target.parentElement;
75
- } else if (type === 'handle-btn-color') {
76
- targetDOM = e.target.parentElement.parentElement;
77
- } else {
78
- return;
79
- }
80
-
81
- const seriesList = Object.values(this.seriesList);
82
- if (!seriesList.length) {
83
- return;
84
- }
85
-
86
- const { colorState } = seriesList[0];
87
- const { start, end } = colorState[0];
88
-
89
- colorState[0].selectedValue = null;
90
- this.clearOverlay();
91
-
92
- this.legendDragInfo.dragging = true;
93
- this.legendDragInfo.isStart = start !== end
94
- ? targetDOM.className.includes('start')
95
- : this.legendDragInfo.isStart;
96
- targetDOM.classList.add('dragging');
97
- this.legendBoxDOM.addEventListener('mousemove', this.onLegendMouseMove, false);
98
- this.legendBoxDOM.addEventListener('mouseup', this.onLegendMouseUp, false);
99
- };
100
-
101
- this.onLegendMouseMove = (e) => {
102
- e.stopPropagation();
103
- e.preventDefault();
104
-
105
- const { dragging, isStart } = this.legendDragInfo;
106
-
107
- if (dragging) {
108
- let value = this.getSelectedValue(e);
109
- value = this.isSide ? 100 - value : value;
110
- const dir = isStart ? 'start' : 'end';
111
-
112
- const seriesList = Object.values(this.seriesList);
113
- if (!seriesList.length) {
114
- return;
115
- }
116
-
117
- const { colorState } = seriesList[0];
118
- const { start, end } = colorState[0];
119
- if ((isStart && value > end) || (!isStart && value < start)) {
120
- return;
121
- }
122
- colorState[0][dir] = value;
123
-
124
- this.update({
125
- updateSeries: false,
126
- updateSelTip: { update: false, keepDomain: false },
127
- });
128
- }
129
- };
130
-
131
- this.onLegendMouseUp = () => {
132
- this.legendDragInfo.dragging = false;
133
-
134
- const targetDOM = this.containerDOM.getElementsByClassName('ev-chart-legend-handle dragging')[0];
135
- targetDOM?.classList.remove('dragging');
136
- this.legendBoxDOM.removeEventListener('mouseup', this.onLegendMouseUp, false);
137
- };
138
-
139
- /**
140
- * callback for legendBoxDOM hovering
141
- *
142
- * @returns {undefined}
143
- */
144
- this.onLegendBoxOver = (e) => {
145
- const type = e.target.dataset.type;
146
-
147
- const seriesList = Object.values(this.seriesList);
148
- if (!seriesList.length) {
149
- return;
150
- }
151
-
152
- const { colorState, valueOpt } = seriesList[0];
153
- const state = colorState[0];
154
-
155
- let value = this.getSelectedValue(e);
156
- value = this.isSide ? 100 - value : value;
157
- if (['line', 'thumb', 'layer', 'overlay', 'overlay-item'].includes(type)) {
158
- if (state.start <= value && value <= state.end) {
159
- state.selectedValue = value;
160
- this.createLegendOverlay(value, valueOpt);
161
- } else {
162
- return;
163
- }
164
- } else if (['handle', 'handle-btn', 'handle-btn-color'].includes(type)) {
165
- const isStart = e.target.className.includes('start');
166
- state.selectedValue = isStart ? state.start : state.end;
167
- this.clearOverlay();
168
- } else {
169
- return;
170
- }
171
-
172
- this.legendHover = { sId: 'gradient', type: this.options.type };
173
-
174
- this.update({
175
- updateSeries: false,
176
- updateSelTip: { update: false, keepDomain: false },
177
- });
178
- };
179
-
180
- /**
181
- * callback for mouseleave event on legendBoxDOM
182
- *
183
- * @returns {undefined}
184
- */
185
- this.onLegendBoxLeave = () => {
186
- this.legendDragInfo.dragging = false;
187
-
188
- this.legendHover = null;
189
-
190
- this.clearOverlay();
191
-
192
- const seriesList = Object.values(this.seriesList);
193
- if (!seriesList.length) {
194
- return;
195
- }
196
-
197
- const { colorState } = seriesList[0];
198
- colorState[0].selectedValue = null;
199
-
200
- this.update({
201
- updateSeries: false,
202
- updateSelTip: { update: false, keepDomain: false },
203
- });
204
- };
205
-
206
- this.legendBoxDOM.addEventListener('mousedown', this.onLegendMouseDown);
207
- this.legendBoxDOM.addEventListener('mouseover', this.onLegendBoxOver);
208
- this.legendBoxDOM.addEventListener('mouseleave', this.onLegendBoxLeave);
209
- },
210
-
211
- getSelectedValue(evt) {
212
- const { x, y, width, height } = this.containerDOM.getBoundingClientRect();
213
- const isTop = !this.isSide;
214
-
215
- const sp = isTop ? x : y;
216
- const size = isTop ? width : height;
217
- let movePoint = isTop ? evt.clientX : evt.clientY;
218
- if (movePoint < sp) {
219
- movePoint = sp;
220
- } else if (movePoint > sp + size) {
221
- movePoint = sp + size;
222
- }
223
-
224
- const move = movePoint - sp;
225
- return +convertToPercent(move, size);
226
- },
227
-
228
- /**
229
- * To update legend, reset all process.
230
- *
231
- * @returns {undefined}
232
- */
233
- updateLegend() {
234
- this.resetLegend();
235
- this.createLegend();
236
-
237
- Object.values(this.seriesList).forEach((series) => {
238
- this.setLegendStyle(series);
239
- });
240
- },
241
-
242
- /**
243
- * To update legend, remove all of legendBoxDOM's children
244
- *
245
- * @returns {undefined}
246
- */
247
- resetLegend() {
248
- const containerDOM = this.containerDOM;
249
-
250
- if (!containerDOM) {
251
- return;
252
- }
253
-
254
- while (containerDOM.hasChildNodes()) {
255
- containerDOM.removeChild(containerDOM.firstChild);
256
- }
257
- },
258
-
259
- clearOverlay() {
260
- const targetDOM = this.containerDOM.getElementsByClassName('ev-chart-legend-line')[0];
261
- const overlayDOM = targetDOM?.getElementsByClassName('ev-chart-legend-overlay')[0];
262
- if (overlayDOM) {
263
- targetDOM.removeChild(overlayDOM);
264
-
265
- const thumbDOM = targetDOM.getElementsByClassName('ev-chart-legend-thumb')[0];
266
- const labels = thumbDOM.children;
267
- labels.forEach((labelDOM) => {
268
- labelDOM.style.opacity = 1;
269
- });
270
- }
271
- },
272
-
273
- createLegendOverlay(value, opt) {
274
- this.clearOverlay();
275
- const handleSize = this.legendHandleSize;
276
- const { min, max } = opt;
277
- if (min === undefined || max === undefined) {
278
- return;
279
- }
280
-
281
- const targetDOM = this.containerDOM.getElementsByClassName('ev-chart-legend-line')[0];
282
-
283
- const overlayDOM = document.createElement('div');
284
- overlayDOM.className = 'ev-chart-legend-overlay';
285
- overlayDOM.dataset.type = 'overlay';
286
-
287
- const tooltipDOM = document.createElement('div');
288
- tooltipDOM.className = 'ev-chart-legend-overlay-tooltip';
289
- tooltipDOM.innerText = Math.floor(min + ((max - min) * (value / 100)));
290
-
291
- const itemDOM = document.createElement('span');
292
- itemDOM.className = 'ev-chart-legend-overlay-item';
293
- itemDOM.dataset.type = 'overlay-item';
294
-
295
- let itemStyle;
296
- let tooltipStyle;
297
- const position = Math.floor(handleSize / 2) + 14;
298
- if (this.isSide) {
299
- tooltipStyle = `top:${100 - value}%;left:${position}px;transform:translateY(-50%);`;
300
- itemStyle = `top:${100 - value}%;transform:translateY(-50%);`;
301
- } else {
302
- tooltipStyle = `top:-${position}px;left:${value}%;transform:translateX(-50%);`;
303
- itemStyle = `left:${value}%;transform:translateX(-50%);`;
304
- }
305
- itemStyle += `width:${handleSize - 10}px;height:${handleSize - 10}px;`;
306
-
307
- tooltipDOM.style.cssText = tooltipStyle;
308
- itemDOM.style.cssText = itemStyle;
309
-
310
- overlayDOM.appendChild(tooltipDOM);
311
- overlayDOM.appendChild(itemDOM);
312
- targetDOM?.appendChild(overlayDOM);
313
-
314
- const thumbDOM = targetDOM?.getElementsByClassName('ev-chart-legend-thumb')[0];
315
- if (thumbDOM) {
316
- const labels = thumbDOM.children;
317
- labels.forEach((labelDOM) => {
318
- labelDOM.style.opacity = 0.2;
319
- });
320
- }
321
- },
322
-
323
- createLegendHandle(type) {
324
- const colorBtnDOM = document.createElement('span');
325
- colorBtnDOM.className = `ev-chart-legend-handle-btn-color ${type}`;
326
- colorBtnDOM.dataset.type = 'handle-btn-color';
327
-
328
- const btnDOM = document.createElement('div');
329
- btnDOM.className = `ev-chart-legend-handle-btn ${type}`;
330
- btnDOM.dataset.type = 'handle-btn';
331
-
332
- btnDOM.appendChild(colorBtnDOM);
333
-
334
- const handleDOM = document.createElement('div');
335
- handleDOM.className = `ev-chart-legend-handle ${type}`;
336
- handleDOM.dataset.type = 'handle';
337
-
338
- handleDOM.appendChild(btnDOM);
339
-
340
- return handleDOM;
341
- },
342
-
343
- createLegendLabel() {
344
- const textDOM = document.createElement('span');
345
- textDOM.className = 'ev-chart-legend-label-text';
346
-
347
- const labelDOM = document.createElement('div');
348
- labelDOM.className = 'ev-chart-legend-label';
349
-
350
- return labelDOM;
351
- },
352
-
353
- /**
354
- * Create legend DOM
355
- *
356
- * @returns {undefined}
357
- */
358
- createLegend() {
359
- if (!Object.values(this.seriesList).length) {
360
- return;
361
- }
362
-
363
- const opt = this.options.legend;
364
- this.isSide = !['top', 'bottom'].includes(opt.position);
365
- const legendSize = this.isSide ? opt.width : opt.height;
366
- this.legendHandleSize = legendSize > MAX_HANDLE_SIZE ? MAX_HANDLE_SIZE : legendSize;
367
- const handleSize = this.legendHandleSize;
368
-
369
- const startHandleDOM = this.createLegendHandle(this.isSide ? 'end' : 'start', handleSize);
370
- const endHandleDOM = this.createLegendHandle(this.isSide ? 'start' : 'end', handleSize);
371
-
372
- const lineLayerDOM = document.createElement('div');
373
- lineLayerDOM.className = 'ev-chart-legend-line-layer';
374
- lineLayerDOM.dataset.type = 'line-layer';
375
- const thumbDOM = document.createElement('div');
376
- thumbDOM.className = 'ev-chart-legend-thumb';
377
- thumbDOM.dataset.type = 'thumb';
378
-
379
- thumbDOM.appendChild(this.createLegendLabel());
380
- thumbDOM.appendChild(this.createLegendLabel());
381
-
382
- const lineDOM = document.createElement('div');
383
- lineDOM.className = 'ev-chart-legend-line';
384
- lineDOM.dataset.type = 'line';
385
-
386
- lineDOM.appendChild(lineLayerDOM);
387
- lineDOM.appendChild(thumbDOM);
388
-
389
- this.containerDOM.appendChild(lineDOM);
390
- this.containerDOM.appendChild(startHandleDOM);
391
- this.containerDOM.appendChild(endHandleDOM);
392
- },
393
-
394
- setLegendStyle(series) {
395
- const dir = this.isSide ? 'top' : 'right';
396
- const handleSize = this.legendHandleSize;
397
-
398
- const { valueOpt, colorState } = series;
399
-
400
- const { min, max, decimalPoint } = valueOpt;
401
-
402
- const { start, end } = colorState[0];
403
- const startColor = series.getColorForGradient(start);
404
- const endColor = series.getColorForGradient(end);
405
- let gradient = `linear-gradient(to ${dir}, `;
406
- gradient += `${startColor}, ${endColor})`;
407
-
408
- const labelPosition = Math.floor(handleSize / 2) + 14;
409
- let defaultHandleStyle = `width:${handleSize}px;height:${handleSize}px;`;
410
- let labelStyle;
411
- let startStyle;
412
- let endStyle;
413
- let thumbStyle = `background:${gradient};`;
414
-
415
- if (this.isSide) {
416
- defaultHandleStyle += `margin-top:-${handleSize / 2}px;`;
417
- labelStyle = `left:${labelPosition}px;transform:translateY(-50%);top:`;
418
- startStyle = `top:${100 - end}%;`;
419
- endStyle = `top:${100 - start}%;`;
420
- thumbStyle += `top:${100 - end}%;height:${end - start}%;`;
421
- } else {
422
- defaultHandleStyle += `margin-left:-${handleSize / 2}px;`;
423
- labelStyle = `top:-${labelPosition}px;transform:translateX(-50%);left:`;
424
- startStyle = `left:${start}%;`;
425
- endStyle = `left:${end}%;`;
426
- thumbStyle += `left:${start}%;width:${end - start}%;`;
427
- }
428
-
429
- const minText = (min + ((max - min) * (start / 100))).toFixed(decimalPoint);
430
- const maxText = (min + ((max - min) * (end / 100))).toFixed(decimalPoint);
431
-
432
- const thumbDOM = this.containerDOM.getElementsByClassName('ev-chart-legend-thumb')[0];
433
- thumbDOM.style.cssText = thumbStyle;
434
-
435
- const labelDOM = thumbDOM.getElementsByClassName('ev-chart-legend-label');
436
- labelDOM[0].style.cssText = `${labelStyle}0%;`;
437
- labelDOM[1].style.cssText = `${labelStyle}100%;`;
438
- if (min !== undefined && max !== undefined) {
439
- labelDOM[0].innerText = this.isSide ? maxText : minText;
440
- labelDOM[1].innerText = this.isSide ? minText : maxText;
441
- }
442
-
443
- const handleDOM = this.containerDOM.getElementsByClassName('ev-chart-legend-handle');
444
- handleDOM[0].style.cssText = defaultHandleStyle + startStyle;
445
- handleDOM[1].style.cssText = defaultHandleStyle + endStyle;
446
-
447
- const btnDOM = this.containerDOM.getElementsByClassName('ev-chart-legend-handle-btn-color');
448
- btnDOM[0].style.backgroundColor = this.isSide ? endColor : startColor;
449
- btnDOM[1].style.backgroundColor = this.isSide ? startColor : endColor;
450
- },
451
-
452
- /**
453
- * Set legend components position by option
454
- *
455
- * @returns {undefined}
456
- */
457
- setLegendPosition() {
458
- const opt = this.options;
459
- const position = opt?.legend?.position;
460
- const { width: minWidth, height: minHeight } = MIN_BOX_SIZE;
461
- const handleSize = this.legendHandleSize;
462
-
463
- const title = opt?.title?.show ? opt?.title?.height : 0;
464
- const positionTop = title + minHeight;
465
- const { top = 0, bottom = 0, left = 0, right = 0 } = opt?.legend?.padding ?? {};
466
- const wrapperStyle = this.wrapperDOM.style;
467
-
468
- if (!wrapperStyle) {
469
- return;
470
- }
471
-
472
- let legendStyle;
473
- let boxStyle;
474
- let containerStyle;
475
- let chartRect;
476
-
477
- switch (position) {
478
- case 'top':
479
- wrapperStyle.padding = `${positionTop}px 0 0 0`;
480
- chartRect = this.chartDOM.getBoundingClientRect();
481
-
482
- boxStyle = `padding:${handleSize + 7}px ${right}px ${bottom}px ${left}px;`;
483
- boxStyle += 'width:100%';
484
- boxStyle += `height${minHeight}px;`;
485
-
486
- legendStyle = `width:${chartRect.width}px;`;
487
- legendStyle += `height:${minHeight}px;`;
488
- legendStyle += `top:${title}px;`;
489
- break;
490
- case 'right':
491
- wrapperStyle.padding = `${title}px ${minWidth}px 0 0`;
492
- chartRect = this.chartDOM.getBoundingClientRect();
493
-
494
- boxStyle = `padding:${top}px ${right}px ${bottom}px ${left}px;`;
495
- boxStyle += `width:${minWidth}px;`;
496
- boxStyle += 'height:100%;';
497
- boxStyle += `max-height:${chartRect.height}px;`;
498
-
499
- legendStyle = `width:${minWidth}px;`;
500
- legendStyle += `height:${chartRect.height}px;`;
501
- legendStyle += `top:${title}px;right:0px;`;
502
- break;
503
- case 'bottom':
504
- wrapperStyle.padding = `${title}px 0 ${minHeight}px 0`;
505
- chartRect = this.chartDOM.getBoundingClientRect();
506
-
507
- boxStyle = `padding:${handleSize + 7}px ${right}px ${bottom}px ${left}px;`;
508
- boxStyle += 'width:100%;';
509
- boxStyle += `height:${minHeight}px;`;
510
-
511
- legendStyle = `width:${chartRect.width}px;`;
512
- legendStyle += `height:${minHeight}px;`;
513
-
514
- legendStyle += 'bottom:0px;left:0px;';
515
- break;
516
- case 'left':
517
- wrapperStyle.padding = `${title}px 0 0 ${minWidth}px`;
518
- chartRect = this.chartDOM.getBoundingClientRect();
519
-
520
- boxStyle = `padding:${top}px ${right}px ${bottom}px ${left}px;`;
521
- boxStyle += 'display:absolute;';
522
- boxStyle += 'bottom:0px;';
523
- boxStyle += `width:${minWidth}px;`;
524
- boxStyle += 'height:100%;';
525
- boxStyle += `maxHeight:${chartRect.height}px;`;
526
-
527
- legendStyle = `width:${minWidth}px;`;
528
- legendStyle += `height:${chartRect.height}px;`;
529
- legendStyle += `top:${title}px;left:0px`;
530
- break;
531
- default:
532
- break;
533
- }
534
- if (['top', 'bottom'].includes(position)) {
535
- const containerSize = chartRect.width / 2;
536
-
537
- containerStyle = `left:${(chartRect.width / 2) - (containerSize / 2)}px;`;
538
- containerStyle += `width:${containerSize}px;`;
539
- containerStyle += `height:${handleSize}px;`;
540
- containerStyle += 'padding:4px 0;';
541
- containerStyle += 'margin:0 4px;';
542
- } else {
543
- const containerSize = chartRect.height / 2;
544
-
545
- containerStyle = `top:${(chartRect.height / 2) - (containerSize / 2)}px;`;
546
- containerStyle += 'left:5px;';
547
- containerStyle += `width:${handleSize}px;`;
548
- containerStyle += `height:${containerSize}px;`;
549
- containerStyle += 'padding:0 4px;';
550
- containerStyle += 'margin:4px 0;';
551
- }
552
-
553
- this.containerDOM.style.cssText = containerStyle;
554
- this.legendBoxDOM.style.cssText = boxStyle;
555
- this.legendDOM.style.cssText = legendStyle;
556
- },
557
-
558
- /**
559
- * Update legend components size
560
- *
561
- * @returns {undefined}
562
- */
563
- updateLegendContainerSize() {
564
- Object.values(this.seriesList).forEach((series) => {
565
- this.setLegendStyle(series);
566
- });
567
- },
568
-
569
- /**
570
- * Show legend components by manipulating css
571
- *
572
- * @returns {undefined}
573
- */
574
- showLegend() {
575
- if (this.resizeDOM) {
576
- this.resizeDOM.style.display = 'block';
577
- }
578
-
579
- if (this.legendDOM) {
580
- this.legendDOM.style.display = 'block';
581
- }
582
- },
583
-
584
- /**
585
- * Hide legend components by manipulating css
586
- *
587
- * @returns {undefined}
588
- */
589
- hideLegend() {
590
- const opt = this.options;
591
- const wrapperStyle = this.wrapperDOM?.style;
592
- const legendStyle = this.legendDOM?.style;
593
- const title = opt?.title?.show ? opt?.title?.height : 0;
594
-
595
- if (!legendStyle || !wrapperStyle) {
596
- return;
597
- }
598
-
599
- legendStyle.display = 'none';
600
- legendStyle.width = '0';
601
- legendStyle.height = '0';
602
- wrapperStyle.padding = `${title}px 0 0 0`;
603
- },
604
- };
605
-
606
- export default modules;