evui 2.1.0 → 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.
Files changed (189) hide show
  1. package/dist/{adac9fa4f723f9d2cb5b6640517114a9.png → 0b8d1200e71cae8d747dce4e69c4efb6.png} +0 -0
  2. package/dist/1.css +4 -0
  3. package/dist/1.css.map +1 -0
  4. package/dist/1.evui.min.js +2 -0
  5. package/dist/1.evui.min.js.map +1 -0
  6. package/dist/1ba679c05036b34bf359aa2e6c450faa.ttf +0 -0
  7. package/dist/2.css +4 -0
  8. package/dist/2.css.map +1 -0
  9. package/dist/2.evui.min.js +2 -0
  10. package/dist/2.evui.min.js.map +1 -0
  11. package/dist/{e8c322de9658cbeb8a774b6624167c2c.woff2 → 278156e41e0ad908cf7f841b17130502.woff2} +0 -0
  12. package/dist/3.evui.min.js +2 -0
  13. package/dist/3.evui.min.js.map +1 -0
  14. package/dist/32be89b11725274cd3e801192ba88361.ttf +0 -0
  15. package/dist/{0ab54153eeeca0ce03978cc463b257f7.woff2 → 38c6d8bab26db77d8c806813e1497763.woff2} +0 -0
  16. package/dist/4.evui.min.js +2 -0
  17. package/dist/4.evui.min.js.map +1 -0
  18. package/dist/{faff92145777a3cbaf8e7367b4807987.woff → 425399f81e4ce7cbd967685402ba0260.woff} +0 -0
  19. package/dist/4730076470a665bbc7b783c56d29a72e.svg +261 -0
  20. package/dist/52e9a7f6ff3af5ad261e5292d07ebdca.eot +0 -0
  21. package/dist/{ad97afd3337e8cda302d10ff5a4026b8.ttf → 5367103510b27b78482794590e1ce3b0.ttf} +0 -0
  22. package/dist/{65363c4d55617bbeb57d8ce6dcd46099.svg → 57e963e3d6dd0a9cf05150b40eebf69b.svg} +0 -0
  23. package/dist/{c5ebe0b32dc1b5cc449a76c4204d13bb.ttf → 65a2fb6d9aaa164b41a039302093995b.ttf} +0 -0
  24. package/dist/{cd6c777f1945164224dee082abaea03a.woff2 → 687a4990ea22bb1a49d469a5d9319790.woff2} +0 -0
  25. package/dist/{7583da5c07275cd5eb364507616f998f.ttf → 6c1d906bf5ba48676f65b2d65e935e1a.ttf} +0 -0
  26. package/dist/6dafca5a4f1e31f2bdf11939b24ff422.ttf +0 -0
  27. package/dist/{701ae6abd4719e9c2ada3535a497b341.eot → 752905fa5edf21fc52a10a0c1ca9c7a4.eot} +0 -0
  28. package/dist/76c05d80dda67cdc5d03f345b7bd063f.ttf +0 -0
  29. package/dist/{b551b554a67e86a840bc80cbb8066c30.svg → 7d62eb50e7bb05eedb2a4656f7fe8f3b.svg} +0 -0
  30. package/dist/{8e3c7f5520f5ae906c6cf6d7f3ddcd19.eot → a01e3f2d6c83dc3aee175e2482b3f777.eot} +0 -0
  31. package/dist/{448f2aaa315fa9dce7b2cf6ce31caed6.svg → b30fd8419d7e6d5918856c7531d33482.svg} +0 -0
  32. package/dist/c57dd55fa982e8940f69ca1d69a8a999.woff +0 -0
  33. package/dist/{b87b9ba532ace76ae9f6edfe9f72ded2.ttf → c656b8caa454ed19b9a2ef7f4f5b8fea.ttf} +0 -0
  34. package/dist/{a046592bac8f2fd96e994733faf3858c.woff → cac87dc00c87a5d74711d0276713808a.woff} +0 -0
  35. package/dist/{13db00b7a34fee4d819ab7f9838cc428.eot → d68fa3e67dbb653a13cec44b1bcabcfe.eot} +0 -0
  36. package/dist/{ef60a4f6c25ef7f39f2d25a748dbecfe.woff → ddae9b1ba9b0b42f58809904b0b21349.woff} +0 -0
  37. package/dist/evui.min.js +6 -86054
  38. package/dist/evui.min.js.gz +0 -0
  39. package/dist/evui.min.js.map +1 -1
  40. package/dist/main.css +43 -5541
  41. package/dist/main.css.gz +0 -0
  42. package/dist/main.css.map +1 -1
  43. package/package.json +56 -76
  44. package/src/common/emitter.js +20 -0
  45. package/src/common/utils.debounce.js +223 -0
  46. package/src/common/utils.js +51 -17
  47. package/src/common/utils.throttle.js +83 -0
  48. package/src/common/utils.tree.js +18 -0
  49. package/src/components/button/button.vue +316 -241
  50. package/src/components/chart/chart.core.js +378 -85
  51. package/src/components/chart/chart.vue +133 -115
  52. package/src/components/chart/element/element.bar.js +219 -25
  53. package/src/components/chart/element/element.bar.time.js +115 -0
  54. package/src/components/chart/element/element.line.js +172 -21
  55. package/src/components/chart/element/element.pie.js +86 -0
  56. package/src/components/chart/element/element.scatter.js +9 -2
  57. package/src/components/chart/element/element.tip.js +356 -0
  58. package/src/components/chart/helpers/helpers.canvas.js +94 -0
  59. package/src/components/chart/helpers/helpers.constant.js +25 -6
  60. package/src/components/chart/helpers/helpers.util.js +83 -38
  61. package/src/components/chart/index.js +0 -1
  62. package/src/components/chart/model/model.series.js +43 -14
  63. package/src/components/chart/model/model.store.js +440 -46
  64. package/src/components/chart/plugins/plugins.interaction.js +324 -0
  65. package/src/components/chart/plugins/plugins.legend.js +233 -91
  66. package/src/components/chart/plugins/plugins.pie.js +179 -0
  67. package/src/components/chart/plugins/plugins.title.js +25 -2
  68. package/src/components/chart/plugins/plugins.tooltip.js +384 -0
  69. package/src/components/chart/scale/scale.js +91 -29
  70. package/src/components/chart/scale/scale.linear.js +12 -0
  71. package/src/components/chart/scale/scale.logarithmic.js +25 -0
  72. package/src/components/chart/scale/scale.step.js +89 -52
  73. package/src/components/chart/scale/scale.time.category.js +204 -0
  74. package/src/components/chart/scale/scale.time.js +19 -1
  75. package/src/components/checkbox/checkbox-group.vue +15 -11
  76. package/src/components/checkbox/checkbox.vue +210 -138
  77. package/src/components/codeview/code.vue +42 -29
  78. package/src/components/contextmenu/contextmenu.child.vue +79 -0
  79. package/src/components/contextmenu/contextmenu.vue +276 -0
  80. package/src/components/contextmenu/contextmenu.wrap.vue +189 -0
  81. package/src/components/contextmenu/index.js +3 -0
  82. package/src/components/datepicker/calendar.core.js +588 -492
  83. package/src/components/datepicker/calendar.vue +0 -3
  84. package/src/components/datepicker/datepicker.vue +43 -15
  85. package/src/components/datepicker/index.js +5 -1
  86. package/src/components/grid/grid.filter.vue +290 -0
  87. package/src/components/grid/grid.filter.window.vue +411 -0
  88. package/src/components/grid/grid.render.vue +45 -0
  89. package/src/components/grid/grid.vue +1338 -0
  90. package/src/components/icon/icon.vue +22 -7
  91. package/src/components/input/input.number.vue +309 -277
  92. package/src/components/label/label.vue +2 -2
  93. package/src/components/loadingmask/loadingmask.vue +6 -13
  94. package/src/components/loginfield/loginfield.vue +46 -37
  95. package/src/components/markdown/index.js +3 -0
  96. package/src/components/markdown/markdown.vue +1001 -0
  97. package/src/components/menu/index.js +1 -3
  98. package/src/components/menu/menu.nav.item.vue +115 -0
  99. package/src/components/menu/menu.nav.sub.vue +42 -0
  100. package/src/components/menu/menu.nav.vue +71 -98
  101. package/src/components/message/index.js +3 -0
  102. package/src/components/message/message.js +63 -0
  103. package/src/components/message/message.vue +191 -0
  104. package/src/components/message-box/index.js +3 -0
  105. package/src/components/message-box/message-box.js +31 -0
  106. package/src/components/message-box/message-box.vue +298 -0
  107. package/src/components/notification/index.js +3 -0
  108. package/src/components/notification/notification.js +75 -0
  109. package/src/components/notification/notification.vue +242 -0
  110. package/src/components/radio/radio-group.vue +6 -2
  111. package/src/components/radio/radio.vue +156 -76
  112. package/src/components/selectbox/dropdown.vue +86 -40
  113. package/src/components/selectbox/listbox.vue +47 -18
  114. package/src/components/selectbox/option.vue +1 -1
  115. package/src/components/selectbox/selectbox.vue +304 -316
  116. package/src/components/slider/slider-tooltip.vue +7 -7
  117. package/src/components/slider/slider.vue +20 -25
  118. package/src/components/splitter/splitter.vue +104 -94
  119. package/src/components/table/table.black.css +1 -1
  120. package/src/components/table/table.filter.lite.vue +7 -7
  121. package/src/components/table/table.filter.vue +1 -1
  122. package/src/components/table/table.grey.css +5 -6
  123. package/src/components/table/table.navy.css +1 -1
  124. package/src/components/table/table.vue +55 -48
  125. package/src/components/tabs/tab-panel.vue +19 -5
  126. package/src/components/tabs/tabs.vue +182 -87
  127. package/src/components/textfield/textfield.vue +110 -87
  128. package/src/components/timepicker/index.js +2 -2
  129. package/src/components/timepicker/spinner.vue +15 -17
  130. package/src/components/timepicker/timepicker.vue +98 -53
  131. package/src/components/toggle/toggle.vue +148 -109
  132. package/src/components/tree/index.js +2 -6
  133. package/src/components/tree/render.js +17 -0
  134. package/src/components/tree/tree-node.vue +214 -0
  135. package/src/components/tree/tree.vue +296 -0
  136. package/src/components/tree-table/index.js +7 -0
  137. package/src/components/{tree → tree-table}/tree.table.black.css +0 -0
  138. package/src/components/{tree → tree-table}/tree.table.grey.css +0 -0
  139. package/src/components/{tree → tree-table}/tree.table.vue +36 -41
  140. package/src/components/{tree → tree-table}/tree.util.js +0 -0
  141. package/src/components/window/window.vue +238 -191
  142. package/src/index.js +25 -12
  143. package/src/styles/base/base.scss +50 -0
  144. package/src/styles/base/index.scss +1 -0
  145. package/src/styles/default.scss +5 -0
  146. package/src/styles/{codemirror.css → lib/codemirror.css} +0 -0
  147. package/src/styles/{all.css → lib/fontawesome.css} +1 -1
  148. package/src/styles/lib/icon.css +792 -0
  149. package/src/styles/themes/index.scss +2 -0
  150. package/src/styles/themes/mixin.scss +33 -0
  151. package/src/styles/themes/variables.scss +206 -0
  152. package/src/styles/utils/colors.scss +222 -0
  153. package/src/styles/utils/index.scss +2 -0
  154. package/src/styles/utils/mixins.scss +34 -0
  155. package/src/styles/utils/variables.scss +27 -0
  156. package/src/webfonts/EVUI.eot +0 -0
  157. package/src/webfonts/EVUI.svg +251 -173
  158. package/src/webfonts/EVUI.ttf +0 -0
  159. package/src/webfonts/EVUI.woff +0 -0
  160. package/src/webfonts/Roboto-Bold.ttf +0 -0
  161. package/src/webfonts/Roboto-Medium.ttf +0 -0
  162. package/src/webfonts/Roboto-Regular.ttf +0 -0
  163. package/dist/3c9453211570a4ede66a4b4954a32bbb.ttf +0 -0
  164. package/dist/8634884f932627fc43782e6963b64ccd.svg +0 -183
  165. package/dist/b9e64d9b5fa6b500eb5df6fa980d3e5b.eot +0 -0
  166. package/dist/f0ac0c8b3c9cd3ef9002749985ae546f.woff +0 -0
  167. package/src/components/chart/charts/chart.bar.js +0 -334
  168. package/src/components/chart/charts/chart.base.js +0 -1075
  169. package/src/components/chart/charts/chart.line.js +0 -262
  170. package/src/components/chart/charts/chart.pie.js +0 -383
  171. package/src/components/chart/charts/chart.scatter.js +0 -349
  172. package/src/components/chart/charts/chart.sunburst.js +0 -193
  173. package/src/components/chart/core/axis/axis.js +0 -217
  174. package/src/components/chart/core/axis/axis.scale.auto.js +0 -69
  175. package/src/components/chart/core/axis/axis.scale.fixed.js +0 -65
  176. package/src/components/chart/core/axis/axis.scale.steps.js +0 -149
  177. package/src/components/chart/core/core.constant.js +0 -116
  178. package/src/components/chart/core/core.legend.js +0 -473
  179. package/src/components/chart/core/core.util.js +0 -66
  180. package/src/components/chart/core/data/data.js +0 -412
  181. package/src/components/chart/core/data/data.pie.js +0 -70
  182. package/src/components/chart/core/data/data.stack.js +0 -222
  183. package/src/components/chart/core/data/data.sunburst.js +0 -172
  184. package/src/components/menu/menu.context.children.vue +0 -201
  185. package/src/components/menu/menu.context.vue +0 -144
  186. package/src/components/tabs/jun/tab.vue +0 -123
  187. package/src/components/tabs/jun/tabs.vue +0 -484
  188. package/src/styles/evui.css +0 -386
  189. package/src/styles/icon.css +0 -557
@@ -1,1075 +0,0 @@
1
- import _ from 'lodash-es';
2
- import moment from 'moment';
3
- import { CHART_AXIS_TYPE } from '../core/core.constant';
4
- import DataStore from '../core/data/data';
5
- import StackDataStore from '../core/data/data.stack';
6
- import Util from '../core/core.util';
7
- import AxisAutoScale from '../core/axis/axis.scale.auto';
8
- import AxisFixedScale from '../core/axis/axis.scale.fixed';
9
- import AxisStepsScale from '../core/axis/axis.scale.steps';
10
- import Legend from '../core/core.legend';
11
-
12
- class BaseChart {
13
- constructor(target, data, options) {
14
- this.options = options;
15
- this.data = data;
16
-
17
- this.labelOffset = { top: 2, left: 2, right: 2, bottom: 2 };
18
-
19
- this.options.type = this.options.type.toLowerCase();
20
-
21
- if (CHART_AXIS_TYPE[this.options.type] === 'axis') {
22
- this.setAxesOptions();
23
- }
24
-
25
- // step2. Create Target DOM Wrapper
26
- this.target = target;
27
- const targetRect = target.getBoundingClientRect();
28
-
29
- const targetWidth = targetRect.width - 10 || 10;
30
- const targetHeight = targetRect.height - 10 || 10;
31
-
32
- this.wrapperDOM = document.createElement('div');
33
- this.wrapperDOM.className = 'ev-chart-wrapper';
34
- this.wrapperDOM.style.width = `${targetWidth}px`;
35
- this.wrapperDOM.style.height = `${targetHeight}px`;
36
- this.wrapperDOM.style.display = 'block';
37
- this.chartDOM = document.createElement('div');
38
- this.chartDOM.className = 'ev-chart-container';
39
- this.chartDOM.style.width = `${targetWidth}px`;
40
- this.chartDOM.style.height = `${targetHeight}px`;
41
-
42
- if (target === null) {
43
- throw new Error('[EVUI][ERROR][Chart]-Not found Target for rendering Chart');
44
- } else {
45
- this.wrapperDOM.appendChild(this.chartDOM);
46
- target.appendChild(this.wrapperDOM);
47
- }
48
-
49
- // step3. Create Chart Canvas
50
- this.createCanvas();
51
-
52
- // step4. Create Component of Chart.
53
- // 4-1. store
54
- this.createDataStore();
55
- this.store.init();
56
-
57
- // 4-2. title
58
- if (this.options.title.show) {
59
- this.createTitle();
60
- }
61
-
62
- // 4-3. legend
63
- if (this.options.legend.show) {
64
- this.createLegend();
65
- this.legend.init();
66
- }
67
-
68
- // step5. Calculate Size.
69
- this.chartRect = this.getChartRect();
70
-
71
- this.xMinMax = this.store.getXMinMax();
72
- this.yMinMax = this.store.getYMinMax();
73
- this.labelList = this.store.getLabelList();
74
- this.seriesList = this.store.getSeriesList();
75
- this.graphData = this.store.getGraphData();
76
-
77
-
78
- // step6. tooltip
79
- if (this.options.useTooltip) {
80
- this.createTooltip();
81
- }
82
- // step6. Add EventListener
83
- this.overlayCanvas.onmousemove = this.mouseMoveEvent.bind(this);
84
- this.overlayCanvas.onmouseout = this.mouseOutEvent.bind(this);
85
- this.resizeEvent = this.resize.bind(this);
86
-
87
- window.addEventListener('resize', this.resizeEvent);
88
- }
89
-
90
- createCanvas() {
91
- this.displayCanvas = document.createElement('canvas');
92
- this.displayCanvas.setAttribute('style', 'display: block;');
93
- this.displayCtx = this.displayCanvas.getContext('2d');
94
- this.bufferCanvas = document.createElement('canvas');
95
- this.bufferCanvas.setAttribute('style', 'display: block;');
96
- this.bufferCtx = this.bufferCanvas.getContext('2d');
97
- this.overlayCanvas = document.createElement('canvas');
98
- this.overlayCanvas.setAttribute('style', 'display: block;');
99
- this.overlayCtx = this.overlayCanvas.getContext('2d');
100
-
101
-
102
- const devicePixelRatio = window.devicePixelRatio || 1;
103
- const backingStoreRatio =
104
- this.displayCtx.webkitBackingStorePixelRatio ||
105
- this.displayCtx.mozBackingStorePixelRatio ||
106
- this.displayCtx.msBackingStorePixelRatio ||
107
- this.displayCtx.oBackingStorePixelRatio ||
108
- this.displayCtx.backingStorePixelRatio || 1;
109
-
110
- this.pixelRatio = devicePixelRatio / backingStoreRatio;
111
- this.oldPixelRatio = this.pixelRatio;
112
-
113
- this.chartDOM.appendChild(this.bufferCanvas);
114
- this.chartDOM.appendChild(this.overlayCanvas);
115
-
116
- this.overlayCanvas.style.position = 'absolute';
117
- this.overlayCanvas.style.top = '0px';
118
- this.overlayCanvas.style.left = '0px';
119
- }
120
-
121
- createDataStore() {
122
- if (this.data.groups.length) {
123
- this.store = new StackDataStore({
124
- chartData: this.data,
125
- chartOptions: this.options,
126
- });
127
- } else {
128
- this.store = new DataStore({
129
- chartData: this.data,
130
- chartOptions: this.options,
131
- });
132
- }
133
- }
134
-
135
- createLegend() {
136
- const seriesList = this.store.getSeriesList();
137
- const groups = this.data.groups;
138
-
139
- this.legend = new Legend({
140
- wrapperDOM: this.wrapperDOM,
141
- chartDOM: this.chartDOM,
142
- chartOptions: this.options,
143
- seriesList,
144
- groups,
145
- overlayCanvas: this.overlayCanvas,
146
- resize: this.resize.bind(this),
147
- updateChart: this.updateChart.bind(this),
148
- overlayClear: this.overlayClear.bind(this),
149
- seriesHighlight: this.seriesHighlight.bind(this),
150
- });
151
- }
152
-
153
- createTooltip() {
154
- const skey = Object.keys(this.seriesList);
155
- const groups = this.data.groups;
156
-
157
- let series;
158
-
159
-
160
- this.tooltipDOM = document.createElement('div');
161
- this.tooltipDOM.className = 'ev-chart-tooltip';
162
- this.tooltipDOM.style.display = 'none';
163
-
164
- this.tooltipTitleDOM = document.createElement('div');
165
- this.tooltipTitleDOM.className = 'ev-chart-tooltip-title';
166
-
167
- this.ulDOM = document.createElement('ul');
168
- this.ulDOM.className = 'ev-chart-tooltip-ul';
169
-
170
- this.tooltipDOM.appendChild(this.tooltipTitleDOM);
171
- this.tooltipDOM.appendChild(this.ulDOM);
172
-
173
- if (groups.length) {
174
- for (let ix = 0, ixLen = groups.length; ix < ixLen; ix++) {
175
- const group = groups[ix];
176
- for (let jx = group.length - 1; jx >= 0; jx--) {
177
- series = this.seriesList[group[jx]];
178
-
179
- if (series.show) {
180
- this.createTooltipDOM(group[jx]);
181
- }
182
- }
183
- }
184
- }
185
-
186
- for (let ix = 0, ixLen = skey.length; ix < ixLen; ix++) {
187
- series = this.seriesList[skey[ix]];
188
-
189
- if (!series.isExistGrp && series.show) {
190
- this.createTooltipDOM(skey[ix]);
191
- }
192
- }
193
- document.body.appendChild(this.tooltipDOM);
194
- }
195
-
196
- createTooltipDOM(seriesId) {
197
- const series = this.seriesList[seriesId];
198
-
199
- const liDOM = document.createElement('li');
200
- liDOM.className = 'ev-chart-tooltip-li';
201
- liDOM.setAttribute('data-series-id', seriesId);
202
-
203
- const colorDOM = document.createElement('span');
204
- colorDOM.className = 'ev-chart-tooltip-color';
205
- colorDOM.style.backgroundColor = series.color;
206
-
207
- const nameDOM = document.createElement('span');
208
- nameDOM.className = 'ev-chart-tooltip-name';
209
- nameDOM.textContent = series.name;
210
-
211
- const colonDOM = document.createElement('span');
212
- colonDOM.className = 'ev-chart-tooltip-colon';
213
- colonDOM.textContent = ' : ';
214
-
215
- const valueDOM = document.createElement('span');
216
- valueDOM.className = 'ev-chart-tooltip-value';
217
-
218
- liDOM.appendChild(colorDOM);
219
- liDOM.appendChild(nameDOM);
220
- liDOM.appendChild(colonDOM);
221
- liDOM.appendChild(valueDOM);
222
- this.ulDOM.appendChild(liDOM);
223
- }
224
-
225
- setAxesOptions() {
226
- const paramXAxes = this.options.xAxes;
227
- const paramYAxes = this.options.yAxes;
228
- const type = this.options.type;
229
- const hasGroup = !!this.data.groups.length;
230
-
231
- const defaultXAxis = {
232
- position: 'bottom',
233
- min: null,
234
- max: null,
235
- autoScaleRatio: null,
236
- isSetMinZero: type === 'bar' || hasGroup,
237
- showGrid: false,
238
- axisLineColor: '#b4b6ba',
239
- gridLineColor: '#e7e9ed',
240
- labelIndicatorColor: '#e7e9ed',
241
- gridLineWidth: 1,
242
- ticks: null,
243
- timeFormat: null,
244
- tickSize: null,
245
- range: null,
246
- labelHeight: 20,
247
- labelStyle: {
248
- fontSize: 12,
249
- color: '#333',
250
- fontFamily: 'Droid Sans',
251
- },
252
- };
253
-
254
- const defaultYAxis = {
255
- position: 'left',
256
- min: null,
257
- max: null,
258
- autoScaleRatio: null,
259
- isSetMinZero: type === 'bar' || hasGroup,
260
- showGrid: true,
261
- axisLineColor: '#b4b6ba',
262
- gridLineColor: '#e7e9ed',
263
- labelIndicatorColor: '#e7e9ed',
264
- gridLineWidth: 1,
265
- ticks: null,
266
- timeFormat: null,
267
- tickSize: null,
268
- range: null,
269
- labelWidth: null,
270
- labelStyle: {
271
- fontSize: 12,
272
- color: '#333',
273
- fontFamily: 'Droid Sans',
274
- },
275
- };
276
-
277
- if (paramXAxes) {
278
- for (let ix = 0, ixLen = paramXAxes.length; ix < ixLen; ix++) {
279
- paramXAxes[ix] = _.merge({}, defaultXAxis, paramXAxes[ix]);
280
- }
281
- } else {
282
- this.options.xAxes = [defaultXAxis];
283
- }
284
-
285
- if (paramYAxes) {
286
- for (let ix = 0, ixLen = paramYAxes.length; ix < ixLen; ix++) {
287
- paramYAxes[ix] = _.merge({}, defaultYAxis, paramYAxes[ix]);
288
- }
289
- } else {
290
- this.options.yAxes = [defaultYAxis];
291
- }
292
- }
293
-
294
- getChartRect() {
295
- const padding = this.constructor.getPadding(this.options.padding);
296
-
297
- let width = this.chartDOM.getBoundingClientRect().width || 10;
298
- let height = this.chartDOM.getBoundingClientRect().height || 10;
299
-
300
- const legendOption = this.options.legend;
301
-
302
- if (legendOption.show) {
303
- switch (legendOption.position) {
304
- case 'top':
305
- case 'bottom':
306
- height -= (this.legend.legendHeight + 12);
307
- break;
308
- case 'left':
309
- case 'right':
310
- width -= this.legend.legendWidth;
311
- this.legend.legendDOM.style.height = `${height}px`;
312
- this.legend.resizeDOM.style.height = `${height}px`;
313
- break;
314
- default:
315
- break;
316
- }
317
- }
318
-
319
- this.setWidth(width);
320
- this.setHeight(height);
321
-
322
- const chartWidth = width - (padding.left + padding.right);
323
- const chartHeight = height - (padding.top + padding.bottom);
324
-
325
- const x1 = padding.left;
326
- const x2 = Math.max(width - padding.right, x1 + 1);
327
- const y1 = padding.top;
328
- const y2 = Math.max(height - padding.bottom, y1 + 1);
329
-
330
- return {
331
- x1,
332
- x2,
333
- y1,
334
- y2,
335
- padding,
336
- chartWidth,
337
- chartHeight,
338
- width,
339
- height,
340
- };
341
- }
342
-
343
- setLabelOffset() {
344
- let labelText;
345
- let labelSize;
346
-
347
- const labelBuffer = 20;
348
- const xAxes = this.options.xAxes;
349
- const yAxes = this.options.yAxes;
350
-
351
- const ctx = this.bufferCtx;
352
- const xMinMax = this.xMinMax.length ? this.xMinMax : [{ max: 1, min: 0 }];
353
- const yMinMax = this.yMinMax.length ? this.yMinMax : [{ max: 1, min: 0 }];
354
-
355
- // 축의 Label 길이 중 가장 큰 value를 기준으로 label offset을 계산.
356
- // label offset의 buffer size 20px
357
- for (let ix = 0, ixLen = yAxes.length; ix < ixLen; ix++) {
358
- ctx.font = Util.getLabelStyle(yAxes[ix]);
359
-
360
- if (yAxes[ix].timeFormat !== null) {
361
- labelText = `${moment(yMinMax[ix].max).format(yAxes[ix].timeFormat)}`;
362
- } else {
363
- labelText = `${Util.labelFormat(yMinMax[ix].max)}`;
364
- }
365
-
366
- labelSize = Math.ceil(this.bufferCtx.measureText(labelText).width) || 0;
367
-
368
- if (yAxes[ix].position === 'left') {
369
- if (labelSize > this.labelOffset.left) {
370
- this.labelOffset.left = labelSize + labelBuffer;
371
- }
372
- } else if (yAxes[ix].position === 'right') {
373
- if (labelSize > this.labelOffset.right) {
374
- this.labelOffset.right = labelSize + labelBuffer;
375
- }
376
- }
377
- }
378
-
379
- for (let ix = 0, ixLen = xAxes.length; ix < ixLen; ix++) {
380
- ctx.font = Util.getLabelStyle(xAxes[ix]);
381
-
382
- if (xAxes[ix].timeFormat !== null) {
383
- labelText = `${moment(xMinMax[ix].max).format(xAxes[ix].timeFormat)}`;
384
- } else {
385
- labelText = `${xMinMax[ix].max}`;
386
- }
387
-
388
- labelSize = Math.ceil(this.bufferCtx.measureText(labelText).width) || 0;
389
-
390
- if (Math.round(labelSize / 2) > this.labelOffset.right) {
391
- this.labelOffset.right = Math.round(labelSize / 2) + labelBuffer;
392
- }
393
-
394
- if (Math.round(labelSize / 2) > this.labelOffset.left) {
395
- this.labelOffset.left = Math.round(labelSize / 2) + labelBuffer;
396
- }
397
-
398
- labelSize = this.options.xAxes[ix].labelStyle.fontSize * 2 || 2;
399
- if (xAxes[ix].position === 'bottom') {
400
- if (labelSize > this.labelOffset.bottom) {
401
- this.labelOffset.bottom = labelSize;
402
- }
403
- } else if (xAxes[ix].position === 'top') {
404
- if (labelSize > this.labelOffset.top) {
405
- this.labelOffset.top = labelSize;
406
- }
407
- }
408
- }
409
- }
410
-
411
- createTitle() {
412
- const titleObj = this.options.title;
413
- this.titleDOM = document.createElement('div');
414
- this.titleDOM.style.fontSize = titleObj.style.fontSize;
415
- this.titleDOM.style.color = titleObj.style.color;
416
- this.titleDOM.style.fontFamily = titleObj.style.fontFamily;
417
- this.titleDOM.textContent = titleObj.text;
418
-
419
- const height = this.chartDOM.getBoundingClientRect().height;
420
-
421
- if (titleObj.show) {
422
- this.titleDOM.style.display = 'block';
423
- this.wrapperDOM.style.paddingTop = `${titleObj.height}px`;
424
- this.chartDOM.style.height = `${height - titleObj.height}px`;
425
- } else {
426
- this.titleDOM.style.display = 'none';
427
- this.wrapperDOM.style.paddingTop = '0';
428
- this.chartDOM.style.height = `${height + titleObj.height}px`;
429
- }
430
-
431
- this.titleDOM.className = 'ev-chart-title';
432
- this.titleDOM.style.height = `${titleObj.height}px`;
433
- this.titleDOM.style.lineHeight = `${titleObj.height}px`;
434
- this.wrapperDOM.appendChild(this.titleDOM);
435
- }
436
-
437
- setWidth(width) {
438
- if (!this.displayCanvas) {
439
- return;
440
- }
441
- this.displayCanvas.width = width * this.pixelRatio;
442
- this.displayCanvas.style.width = `${width}px`;
443
- this.bufferCanvas.width = width * this.pixelRatio;
444
- this.bufferCanvas.style.width = `${width}px`;
445
- this.overlayCanvas.width = width * this.pixelRatio;
446
- this.overlayCanvas.style.width = `${width}px`;
447
- }
448
-
449
- setHeight(height) {
450
- if (!this.displayCanvas) {
451
- return;
452
- }
453
- this.displayCanvas.height = height * this.pixelRatio;
454
- this.displayCanvas.style.height = `${height}px`;
455
- this.bufferCanvas.height = height * this.pixelRatio;
456
- this.bufferCanvas.style.height = `${height}px`;
457
- this.overlayCanvas.height = height * this.pixelRatio;
458
- this.overlayCanvas.style.height = `${height}px`;
459
- }
460
-
461
- createAxis() {
462
- let xAxisObj;
463
- let yAxisObj;
464
-
465
- this.xAxes = [];
466
- this.yAxes = [];
467
-
468
- for (let ix = 0, ixLen = this.options.xAxes.length; ix < ixLen; ix++) {
469
- switch (this.options.xAxes[ix].scaleType) {
470
- case 'fix':
471
- xAxisObj = new AxisFixedScale({
472
- type: 'x',
473
- chartRect: this.chartRect,
474
- options: this.options.xAxes[ix],
475
- ctx: this.bufferCtx,
476
- labelOffset: this.labelOffset,
477
- });
478
- break;
479
- case 'step':
480
- xAxisObj = new AxisStepsScale({
481
- type: 'x',
482
- chartRect: this.chartRect,
483
- options: this.options.xAxes[ix],
484
- ctx: this.bufferCtx,
485
- labelOffset: this.labelOffset,
486
- axisData: this.labelList || [],
487
- });
488
- break;
489
- case 'auto':
490
- default:
491
- xAxisObj = new AxisAutoScale({
492
- type: 'x',
493
- chartRect: this.chartRect,
494
- options: this.options.xAxes[ix],
495
- ctx: this.bufferCtx,
496
- labelOffset: this.labelOffset,
497
- });
498
- break;
499
- }
500
-
501
- this.xAxes.push(xAxisObj);
502
- }
503
-
504
- for (let ix = 0, ixLen = this.options.yAxes.length; ix < ixLen; ix++) {
505
- switch (this.options.yAxes[ix].scaleType) {
506
- case 'fix':
507
- yAxisObj = new AxisFixedScale({
508
- type: 'y',
509
- chartRect: this.chartRect,
510
- options: this.options.yAxes[ix],
511
- ctx: this.bufferCtx,
512
- labelOffset: this.labelOffset,
513
- });
514
- break;
515
- case 'step':
516
- yAxisObj = new AxisStepsScale({
517
- type: 'y',
518
- chartRect: this.chartRect,
519
- options: this.options.yAxes[ix],
520
- ctx: this.bufferCtx,
521
- labelOffset: this.labelOffset,
522
- axisData: this.labelList || [],
523
- });
524
- break;
525
- case 'auto':
526
- default:
527
- yAxisObj = new AxisAutoScale({
528
- type: 'y',
529
- chartRect: this.chartRect,
530
- options: this.options.yAxes[ix],
531
- ctx: this.bufferCtx,
532
- labelOffset: this.labelOffset,
533
- });
534
- break;
535
- }
536
-
537
- this.yAxes.push(yAxisObj);
538
- }
539
-
540
- for (let ix = 0, ixLen = this.xAxes.length; ix < ixLen; ix++) {
541
- this.xAxes[ix].createAxis(this.xMinMax[ix]);
542
- }
543
-
544
- for (let ix = 0, ixLen = this.yAxes.length; ix < ixLen; ix++) {
545
- this.yAxes[ix].createAxis(this.yMinMax[ix]);
546
- }
547
- }
548
-
549
- calculateX(value, xAxisIndex, isReqSp) {
550
- const maxValue = this.xAxes[xAxisIndex].axisMax;
551
- const minValue = this.xAxes[xAxisIndex].axisMin;
552
- let convertValue;
553
-
554
- if (value === null) {
555
- return null;
556
- }
557
-
558
- if (this.options.xAxes[xAxisIndex].labelType === 'time') {
559
- convertValue = +moment(value);
560
- } else {
561
- convertValue = value;
562
- }
563
-
564
- if (convertValue > maxValue || convertValue < minValue) {
565
- return null;
566
- }
567
-
568
- const sp = isReqSp ? this.chartRect.x1 + this.labelOffset.left : 0;
569
- const scalingFactor = this.drawingXArea() / (maxValue - minValue);
570
- return Math.ceil(sp + (scalingFactor * (convertValue - (minValue || 0))));
571
- }
572
-
573
- calculateY(value, yAxisIndex, invert) {
574
- const maxValue = this.yAxes[yAxisIndex].axisMax;
575
- const minValue = this.yAxes[yAxisIndex].axisMin;
576
- let convertValue;
577
- let calcY;
578
-
579
- if (value === null) {
580
- return null;
581
- }
582
-
583
- if (this.options.yAxes[yAxisIndex].labelType === 'time') {
584
- convertValue = +moment(value);
585
- } else {
586
- convertValue = value;
587
- }
588
-
589
- if (convertValue > maxValue || convertValue < minValue) {
590
- return null;
591
- }
592
- // Bar차트의 fillRect처리를 위해 invert값 추가 하여 Y값을 처리
593
- const scalingFactor = this.drawingYArea() / (maxValue - minValue);
594
- if (invert) {
595
- calcY = -(scalingFactor * (convertValue - (minValue || 0)));
596
- } else {
597
- calcY = (this.chartRect.y2 - this.labelOffset.bottom) -
598
- (scalingFactor * (convertValue - (minValue || 0)));
599
- }
600
-
601
- return Math.floor(calcY);
602
- }
603
-
604
- calculateXP(point, xAxisIndex, isReqSp) {
605
- const maxValue = this.xAxes[xAxisIndex].axisMax;
606
- const minValue = this.xAxes[xAxisIndex].axisMin;
607
- let convertValue;
608
-
609
- if (point === null) {
610
- return null;
611
- }
612
-
613
- const sp = isReqSp ? this.chartRect.x1 + this.labelOffset.left : 0;
614
- const value = Math.ceil((((point - sp) * (maxValue - minValue)) /
615
- this.drawingXArea()) + minValue);
616
-
617
-
618
- if (this.options.xAxes[xAxisIndex].labelType === 'time') {
619
- convertValue = +moment(value);
620
- } else {
621
- convertValue = value;
622
- }
623
-
624
- return convertValue;
625
- }
626
-
627
- calculateYP(point, yAxisIndex, invert) {
628
- const maxValue = this.yAxes[yAxisIndex].axisMax;
629
- const minValue = this.yAxes[yAxisIndex].axisMin;
630
- let convertValue;
631
-
632
- if (point === null) {
633
- return null;
634
- }
635
- const sp = this.chartRect.y1 + this.labelOffset.top;
636
- const value = Math.ceil((((point - sp) * (maxValue - minValue)) / this.drawingYArea()));
637
-
638
-
639
- if (this.options.yAxes[yAxisIndex].labelType === 'time') {
640
- convertValue = +moment(value);
641
- } else {
642
- convertValue = value;
643
- }
644
-
645
- if (!invert) {
646
- convertValue = maxValue - convertValue;
647
- }
648
-
649
- return convertValue;
650
- }
651
-
652
- drawingXArea() {
653
- return this.chartRect.chartWidth - (this.labelOffset.left + this.labelOffset.right);
654
- }
655
-
656
- drawingYArea() {
657
- return this.chartRect.chartHeight - (this.labelOffset.top + this.labelOffset.bottom);
658
- }
659
-
660
- drawPoint(ctx, style, radius, x, y) {
661
- let edgeLength;
662
- let xOffset;
663
- let yOffset;
664
- let height;
665
- let size;
666
-
667
- if (isNaN(radius) || radius <= 0) {
668
- return;
669
- }
670
-
671
- let offset;
672
- let leftX;
673
- let topY;
674
- let sideSize;
675
-
676
- switch (style) {
677
- // Default includes circle
678
- case 'triangle':
679
- ctx.beginPath();
680
- edgeLength = (3 * radius) / Math.sqrt(3);
681
- height = (edgeLength * Math.sqrt(3)) / 2;
682
- ctx.moveTo(x - (edgeLength / 2), y + (height / 3));
683
- ctx.lineTo(x + (edgeLength / 2), y + (height / 3));
684
- ctx.lineTo(x, y - ((2 * height) / 3));
685
- ctx.closePath();
686
- ctx.fill();
687
- break;
688
- case 'rect':
689
- size = (1 / Math.SQRT2) * radius;
690
- ctx.beginPath();
691
- ctx.fillRect(x - size, y - size, 2 * size, 2 * size);
692
- ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
693
- break;
694
- case 'rectRounded':
695
- offset = radius / Math.SQRT2;
696
- leftX = x - offset;
697
- topY = y - offset;
698
- sideSize = Math.SQRT2 * radius;
699
- ctx.beginPath();
700
- this.roundedRect(ctx, leftX, topY, sideSize, sideSize, radius / 2);
701
- ctx.closePath();
702
- ctx.fill();
703
- break;
704
- case 'rectRot':
705
- size = (1 / Math.SQRT2) * radius;
706
- ctx.beginPath();
707
- ctx.moveTo(x - size, y);
708
- ctx.lineTo(x, y + size);
709
- ctx.lineTo(x + size, y);
710
- ctx.lineTo(x, y - size);
711
- ctx.closePath();
712
- ctx.fill();
713
- break;
714
- case 'cross':
715
- ctx.beginPath();
716
- ctx.moveTo(x, y + radius);
717
- ctx.lineTo(x, y - radius);
718
- ctx.moveTo(x - radius, y);
719
- ctx.lineTo(x + radius, y);
720
- ctx.closePath();
721
- break;
722
- case 'crossRot':
723
- ctx.beginPath();
724
- xOffset = Math.cos(Math.PI / 4) * radius;
725
- yOffset = Math.sin(Math.PI / 4) * radius;
726
- ctx.moveTo(x - xOffset, y - yOffset);
727
- ctx.lineTo(x + xOffset, y + yOffset);
728
- ctx.moveTo(x - xOffset, y + yOffset);
729
- ctx.lineTo(x + xOffset, y - yOffset);
730
- ctx.closePath();
731
- break;
732
- case 'star':
733
- ctx.beginPath();
734
- ctx.moveTo(x, y + radius);
735
- ctx.lineTo(x, y - radius);
736
- ctx.moveTo(x - radius, y);
737
- ctx.lineTo(x + radius, y);
738
- xOffset = Math.cos(Math.PI / 4) * radius;
739
- yOffset = Math.sin(Math.PI / 4) * radius;
740
- ctx.moveTo(x - xOffset, y - yOffset);
741
- ctx.lineTo(x + xOffset, y + yOffset);
742
- ctx.moveTo(x - xOffset, y + yOffset);
743
- ctx.lineTo(x + xOffset, y - yOffset);
744
- ctx.closePath();
745
- break;
746
- case 'line':
747
- ctx.beginPath();
748
- ctx.moveTo(x - radius, y);
749
- ctx.lineTo(x + radius, y);
750
- ctx.closePath();
751
- break;
752
- case 'dash':
753
- ctx.beginPath();
754
- ctx.moveTo(x, y);
755
- ctx.lineTo(x + radius, y);
756
- ctx.closePath();
757
- break;
758
- default:
759
- ctx.beginPath();
760
- ctx.arc(x, y, radius, 0, Math.PI * 2);
761
- ctx.closePath();
762
- ctx.fill();
763
- break;
764
- }
765
-
766
- ctx.stroke();
767
- }
768
-
769
- findHitItem(offset, graphData) {
770
- const mouseY = offset[1];
771
- const index = this.findHitAxisX(offset[0], graphData);
772
- const skey = Object.keys(graphData);
773
-
774
- let gdata;
775
- let sId = null;
776
-
777
- if (index !== null && index > -1) {
778
- for (let ix = 0, ixLen = skey.length; ix < ixLen; ix++) {
779
- gdata = graphData[skey[ix]];
780
-
781
- if (gdata[index] && gdata[index].yp !== null &&
782
- mouseY >= (gdata[index].yp - 10) && mouseY <= (gdata[index].yp + 10)) {
783
- sId = skey[ix];
784
- break;
785
- }
786
- }
787
- }
788
-
789
- return { index, sId };
790
- }
791
-
792
- findHitAxisX(mouseX, graphData) {
793
- const x2 = this.chartRect.x2 - this.labelOffset.right;
794
- const x1 = this.chartRect.x1 + this.labelOffset.left;
795
- const width = x2 - x1;
796
-
797
- const skey = Object.keys(graphData);
798
- let sId;
799
-
800
- for (let ix = 0, ixLen = skey.length; ix < ixLen; ix++) {
801
- if (this.seriesList[skey[ix]].show) {
802
- sId = skey[ix];
803
- break;
804
- }
805
- }
806
-
807
- const gdata = graphData[sId];
808
- if (gdata && gdata.length) {
809
- if (mouseX >= (x1 - 10) && mouseX <= (x2 + 10)) {
810
- const index = Math.round(((gdata.length - 1) / width) * (mouseX - x1));
811
- if (!gdata[index]) {
812
- return null;
813
- }
814
-
815
- if (mouseX <= (gdata[index].xp + 10) && mouseX >= (gdata[index].xp - 10)) {
816
- return index;
817
- }
818
- }
819
- }
820
-
821
- return null;
822
- }
823
-
824
- initScale() {
825
- const devicePixelRatio = window.devicePixelRatio || 1;
826
- const backingStoreRatio =
827
- this.displayCtx.webkitBackingStorePixelRatio ||
828
- this.displayCtx.mozBackingStorePixelRatio ||
829
- this.displayCtx.msBackingStorePixelRatio ||
830
- this.displayCtx.oBackingStorePixelRatio ||
831
- this.displayCtx.backingStorePixelRatio || 1;
832
-
833
- this.pixelRatio = devicePixelRatio / backingStoreRatio;
834
-
835
- if (this.oldPixelRatio !== this.pixelRatio) {
836
- this.oldPixelRatio = this.pixelRatio;
837
- this.resize();
838
- }
839
- if (devicePixelRatio !== backingStoreRatio) {
840
- this.bufferCtx.scale(this.pixelRatio, this.pixelRatio);
841
- this.overlayCtx.scale(this.pixelRatio, this.pixelRatio);
842
- }
843
- }
844
-
845
- resize() {
846
- if (!this.chartDOM) {
847
- return;
848
- }
849
- // target
850
- const targetRect = this.target.getBoundingClientRect();
851
-
852
- const targetWidth = targetRect.width - 10 || 10;
853
- const targetHeight = targetRect.height - 10 || 10;
854
-
855
- this.wrapperDOM.style.width = `${targetWidth}px`;
856
- this.wrapperDOM.style.height = `${targetHeight}px`;
857
- this.chartDOM.style.width = `${targetWidth}px`;
858
- this.chartDOM.style.height = `${targetHeight}px`;
859
-
860
- if (this.options.title.show) {
861
- const titleObj = this.options.title;
862
- this.chartDOM.style.height = `${targetHeight - titleObj.height}px`;
863
- }
864
-
865
- const offset = this.chartDOM.getBoundingClientRect();
866
- const bufferCtx = this.bufferCtx;
867
-
868
- if (offset) {
869
- bufferCtx.restore();
870
- bufferCtx.save();
871
- bufferCtx.scale(this.pixelRatio, this.pixelRatio);
872
-
873
- if (this.resizeTimer) {
874
- clearTimeout(this.resizeTimer);
875
- }
876
- this.legend.updateLegendPosition();
877
- this.resizeTimer = setTimeout(this.updateChart.bind(this)(true), 50);
878
- }
879
-
880
- window.removeEventListener('mousemove', this.resizeEvent, false);
881
- }
882
-
883
- updateChart(isResize) {
884
- this.store.updateData();
885
- this.seriesList = this.store.getSeriesList();
886
- this.graphData = this.store.getGraphData();
887
- this.xMinMax = this.store.getXMinMax();
888
- this.yMinMax = this.store.getYMinMax();
889
- this.labelList = this.store.getLabelList();
890
-
891
- if (!isResize) {
892
- this.legend.seriesList = this.seriesList;
893
- this.legend.updateLegend();
894
- }
895
-
896
- this.chartRect = this.getChartRect();
897
-
898
- if (!this.chartRect.width || !this.chartRect.height ||
899
- this.chartRect.width < 1 || this.chartRect.height < 1) {
900
- return;
901
- }
902
-
903
- this.initScale();
904
- this.clearDraw();
905
- this.drawChart();
906
- }
907
-
908
- overlayClear() {
909
- this.clearRectRatio = (this.pixelRatio < 1) ? this.pixelRatio : 1;
910
-
911
- this.overlayCtx.clearRect(0, 0, this.overlayCanvas.width / this.clearRectRatio,
912
- this.overlayCanvas.height / this.clearRectRatio);
913
- }
914
-
915
- clearDraw() {
916
- this.clearRectRatio = (this.pixelRatio < 1) ? this.pixelRatio : 1;
917
-
918
- this.displayCtx.clearRect(0, 0, this.displayCanvas.width / this.clearRectRatio,
919
- this.displayCanvas.height / this.clearRectRatio);
920
- this.bufferCtx.clearRect(0, 0, this.bufferCanvas.width / this.clearRectRatio,
921
- this.bufferCanvas.height / this.clearRectRatio);
922
- this.overlayCtx.clearRect(0, 0, this.overlayCanvas.width / this.clearRectRatio,
923
- this.overlayCanvas.height / this.clearRectRatio);
924
- }
925
-
926
- mouseMoveEvent(e) {
927
- const graphData = this.graphData;
928
- const offset = this.getMousePosition(e);
929
- const item = this.findHitItem(offset, graphData);
930
-
931
- if (this.selectBox && this.selectBox.active) {
932
- return;
933
- }
934
-
935
- this.overlayClear();
936
-
937
- if (this.options.useTooltip && item.sId !== null) {
938
- if (this.options.type === 'pie') {
939
- this.showTooltip(offset, e, item);
940
- } else {
941
- const ldata = this.labelList[item.index];
942
- this.showTooltip(offset, e, item, graphData, ldata);
943
- }
944
- } else {
945
- this.hideTooltip();
946
- }
947
-
948
- if (this.options.itemHighlight) {
949
- if (item && this.itemHighlight) {
950
- this.itemHighlight(item);
951
- }
952
- }
953
- }
954
-
955
- showTooltip(offset, e, item, graphData, adata) {
956
- const index = item.index;
957
-
958
- if (index === null) {
959
- this.tooltipDOM.style.display = 'none';
960
- return;
961
- }
962
-
963
- const offsetX = offset[0];
964
- const offsetY = offset[1];
965
-
966
- const mouseX = e.pageX;
967
- const mouseY = e.pageY;
968
- const clientX = e.clientX;
969
- const clientY = e.clientY;
970
- const bodyWidth = document.body.clientWidth;
971
- const bodyHeight = document.body.clientHeight;
972
-
973
- const graphPos = {
974
- x1: this.chartRect.x1 + this.labelOffset.left,
975
- x2: this.chartRect.x2 - this.labelOffset.right,
976
- y1: this.chartRect.y1 + this.labelOffset.top,
977
- y2: this.chartRect.y2 - this.labelOffset.bottom,
978
- };
979
-
980
- if ((offsetX >= (graphPos.x1 - 1) && offsetX <= (graphPos.x2))
981
- && (offsetY >= (graphPos.y1 - 1) && offsetY <= (graphPos.y2 + 1))) {
982
- this.tooltipTitleDOM.textContent = adata || '';
983
-
984
- const listDOM = this.ulDOM.children;
985
- let sId;
986
- let series;
987
- let valueDOM;
988
- let gdata;
989
-
990
- for (let ix = 0, ixLen = listDOM.length; ix < ixLen; ix++) {
991
- sId = listDOM[ix].dataset.seriesId;
992
- series = this.seriesList[sId];
993
-
994
- if (series.groupIndex === null) {
995
- gdata = graphData[sId][index].y;
996
- } else {
997
- gdata = graphData[sId][index].i;
998
- }
999
-
1000
-
1001
- if (series && series.show) {
1002
- listDOM[ix].style.display = 'block';
1003
- valueDOM = listDOM[ix].children[3];
1004
- valueDOM.textContent = gdata;
1005
- } else {
1006
- listDOM[ix].style.display = 'none';
1007
- }
1008
- }
1009
-
1010
- this.tooltipDOM.style.display = 'block';
1011
-
1012
- if (offsetX > ((graphPos.x2 * 4) / 5) || clientX > ((bodyWidth * 4) / 5)) {
1013
- this.tooltipDOM.style.left = `${mouseX - (this.tooltipDOM.clientWidth + 10)}px`;
1014
- } else {
1015
- this.tooltipDOM.style.left = `${mouseX + 15}px`;
1016
- }
1017
-
1018
- if (offsetY > ((graphPos.y2 * 3) / 4) || clientY > ((bodyHeight * 3) / 4)) {
1019
- this.tooltipDOM.style.top = `${mouseY - (this.tooltipDOM.clientHeight + 5)}px`;
1020
- } else {
1021
- this.tooltipDOM.style.top = `${mouseY + 10}px`;
1022
- }
1023
- } else {
1024
- this.tooltipDOM.style.display = 'none';
1025
- }
1026
- }
1027
-
1028
- hideTooltip() {
1029
- this.tooltipDOM.style.display = 'none';
1030
- }
1031
-
1032
- getMousePosition(evt) {
1033
- let mouseX;
1034
- let mouseY;
1035
-
1036
- const e = evt.originalEvent || evt;
1037
- const boundingRect = this.overlayCanvas.getBoundingClientRect();
1038
-
1039
- if (e.touches) {
1040
- mouseX = e.touches[0].clientX - boundingRect.left;
1041
- mouseY = e.touches[0].clientY - boundingRect.top;
1042
- } else {
1043
- mouseX = e.clientX - boundingRect.left;
1044
- mouseY = e.clientY - boundingRect.top;
1045
- }
1046
-
1047
- return [mouseX, mouseY];
1048
- }
1049
-
1050
- mouseOutEvent() {
1051
- if (!this.selectBox || (this.selectBox && !this.selectBox.active)) {
1052
- this.overlayClear();
1053
- }
1054
-
1055
- if (this.options.useTooltip) {
1056
- this.hideTooltip();
1057
- }
1058
- }
1059
-
1060
- static getPadding(padding) {
1061
- return typeof padding === 'number' ? {
1062
- top: padding,
1063
- right: padding,
1064
- bottom: padding,
1065
- left: padding,
1066
- } : {
1067
- top: padding.top,
1068
- right: padding.right,
1069
- bottom: padding.bottom,
1070
- left: padding.left,
1071
- };
1072
- }
1073
- }
1074
-
1075
- export default BaseChart;