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,16 +1,21 @@
1
1
  <template>
2
2
  <div
3
3
  ref="wrapper"
4
+ v-resize.debounce="onResize"
4
5
  :style="wrapperStyle"
5
6
  class="ev-chart"
6
7
  />
7
8
  </template>
8
9
  <script>
9
- import _ from 'lodash-es';
10
+ import resize from 'vue-resize-directive';
11
+ import { cloneDeep, defaultsDeep, isEqual } from 'lodash-es';
10
12
  import { getQuantity } from '@/common/utils';
11
13
  import EvChart from './chart.core';
12
14
 
13
15
  export default {
16
+ directives: {
17
+ resize,
18
+ },
14
19
  props: {
15
20
  options: {
16
21
  type: Object,
@@ -20,12 +25,17 @@
20
25
  type: Object,
21
26
  default: () => {},
22
27
  },
28
+ listeners: {
29
+ type: Object,
30
+ default: () => {},
31
+ },
23
32
  },
24
33
  data() {
25
34
  return {
26
35
  chart: null,
27
36
  normalizedOption: null,
28
37
  normalizedData: null,
38
+ isInit: false,
29
39
  };
30
40
  },
31
41
  computed: {
@@ -38,53 +48,71 @@
38
48
  },
39
49
  watch: {
40
50
  data: {
41
- handler(newVal, oldVal) {
42
- let isSeriesUpdate = false;
43
- this.normalizedData = {
44
- series: {},
45
- data: {},
46
- groups: [],
47
- labels: [],
48
- };
51
+ handler(newVal) {
52
+ const newData = defaultsDeep({}, newVal, this.normalizedData);
53
+ const isUpdateSeries = !isEqual(newData.series, this.evChart.data.series);
49
54
 
50
- if (!this.isEqualObject(newVal.series, oldVal.series)) {
51
- isSeriesUpdate = true;
52
- }
53
- this.evChart.data = _.merge(this.getDefaultData(), newVal);
54
- this.evChart.update(isSeriesUpdate);
55
+ this.evChart.data = cloneDeep(newData);
56
+ this.evChart.update({
57
+ updateSeries: isUpdateSeries,
58
+ updateSelTip: { update: true, keepDomain: false },
59
+ });
55
60
  },
61
+ deep: true,
56
62
  },
57
63
  options: {
58
64
  handler(newVal) {
59
- this.evChart.options = _.merge(this.getDefaultOptions(), newVal);
60
- this.evChart.update();
65
+ const newOpt = defaultsDeep({}, newVal, this.normalizedOption);
66
+
67
+ this.evChart.options = cloneDeep(newOpt);
68
+ this.evChart.update({
69
+ updateSeries: false,
70
+ updateSelTip: { update: false, keepDomain: false },
71
+ });
61
72
  },
73
+ deep: true,
62
74
  },
63
75
  },
64
76
  created() {
65
- this.normalizedOption = _.merge(this.getDefaultOptions(), this.options);
66
- this.normalizedData = _.merge(this.getDefaultData(), this.data);
77
+ this.data.series = cloneDeep(this.data.series || {});
78
+ this.options.legend = cloneDeep(this.options.legend || {});
79
+
80
+ this.normalizedOption = defaultsDeep({}, this.options, this.getDefaultOptions());
81
+ this.normalizedData = defaultsDeep(this.data, this.getDefaultData());
67
82
  },
68
83
  mounted() {
69
84
  const wrapper = this.$refs.wrapper;
70
85
  const options = this.normalizedOption;
71
86
  const data = this.normalizedData;
72
87
 
73
- this.evChart = new EvChart(wrapper, data, options);
88
+ this.evChart = new EvChart(wrapper, data, options, this.createEventListener());
74
89
 
75
- this.store = this.evChart.store;
76
90
  const timer = setTimeout(() => {
77
- this.evChart.init();
91
+ if (this.evChart) {
92
+ this.evChart.init();
93
+ this.isInit = true;
94
+ }
78
95
  clearTimeout(timer);
79
96
  }, 1);
80
97
  },
81
98
  beforeDestroy() {
82
- if (this.evChart.tooltipDOM) {
83
- this.evChart.tooltipDOM.remove();
84
- }
85
- delete this.evChart;
99
+ this.evChart.destroy();
100
+ this.evChart = null;
86
101
  },
87
102
  methods: {
103
+ createEventListener() {
104
+ const listeners = this.listeners || {};
105
+ const evtList = ['dblclick', 'click'];
106
+ const cbMap = {};
107
+
108
+ evtList.forEach((fnKey) => {
109
+ if (Object.prototype.hasOwnProperty.call(listeners, fnKey)) {
110
+ cbMap[fnKey] = listeners[fnKey];
111
+ }
112
+ });
113
+
114
+ return cbMap;
115
+ },
88
116
  getDefaultOptions() {
89
117
  return {
90
118
  border: 2,
@@ -95,13 +123,13 @@
95
123
  style: {
96
124
  fontSize: 15,
97
125
  color: '#000',
98
- fontFamily: 'Droid Sans',
126
+ fontFamily: 'Roboto',
99
127
  },
100
128
  },
101
129
  legend: {
102
130
  show: true,
103
131
  position: 'right',
104
- color: '#000',
132
+ color: '#353740',
105
133
  inactive: '#aaa',
106
134
  width: 140,
107
135
  height: 24,
@@ -111,14 +139,43 @@
111
139
  useSelect: false,
112
140
  doughnutHoleSize: 0,
113
141
  reverse: false,
114
- bufferSize: null,
115
142
  horizontal: false,
116
143
  width: '100%',
117
144
  height: '100%',
118
145
  thickness: 1,
119
- useTooltip: true,
120
- useSelectionData: false,
121
- type: 'line',
146
+ combo: false,
147
+ tooltip: {
148
+ use: true,
149
+ backgroundColor: '#4C4C4C',
150
+ borderColor: '#666666',
151
+ shadowOpacity: 0.25,
152
+ useShadow: false,
153
+ throttledMove: false,
154
+ debouncedHide: false,
155
+ },
156
+ indicator: {
157
+ use: true,
158
+ color: '#EE7F44',
159
+ },
160
+ maxTip: {
161
+ use: false,
162
+ fixedPosTop: false,
163
+ showIndicator: false,
164
+ indicatorColor: '#000000',
165
+ tipBackground: '#000000',
166
+ tipTextColor: '#FFFFFF',
167
+ },
168
+ selectItem: {
169
+ use: false,
170
+ showTextTip: false,
171
+ showTip: false,
172
+ showIndicator: false,
173
+ fixedPosTop: false,
174
+ useApproximateValue: false,
175
+ indicatorColor: '#000000',
176
+ tipBackground: '#000000',
177
+ tipTextColor: '#FFFFFF',
178
+ },
122
179
  };
123
180
  },
124
181
  getDefaultData() {
@@ -139,28 +196,34 @@
139
196
  }
140
197
  return sizeValue;
141
198
  },
142
- isEqualObject(newVal, oldVal) {
143
- const nKey = Object.keys(newVal).sort();
144
- const oKey = Object.keys(oldVal).sort();
145
-
146
- if (nKey.length !== oKey.length) {
147
- return false;
199
+ onResize() {
200
+ if (this.isInit) {
201
+ this.evChart.resize();
148
202
  }
149
-
150
- for (let ix = 0; ix < nKey.length; ix++) {
151
- if (nKey[ix] !== oKey[ix]) {
152
- return false;
153
- } else if (!_.isEqual(newVal[nKey[ix]], oldVal[oKey[ix]])) {
154
- return false;
155
- }
203
+ },
204
+ forceUpdate() {
205
+ if (this.isInit) {
206
+ this.evChart.update({
207
+ updateSeries: false,
208
+ updateSelTip: { update: false, keepDomain: false },
209
+ });
156
210
  }
157
-
158
- return true;
211
+ },
212
+ onDblClick(e) {
213
+ this.$emit('on-dblclick', e);
214
+ },
215
+ onClick(e) {
216
+ this.$emit('on-click', e);
217
+ },
218
+ selectItemByLabel(label) {
219
+ return this.evChart.selectItemByLabel(label);
159
220
  },
160
221
  },
161
222
  };
162
223
  </script>
163
- <style>
224
+ <style lang="scss">
225
+ @import '~@/styles/default';
226
+
164
227
  .ev-chart-wrapper {
165
228
  position: relative;
166
229
  width: 100%;
@@ -207,14 +270,9 @@
207
270
  top: 50%;
208
271
  left: 0;
209
272
  transform: translate(0, -50%);
210
- width: 8px;
211
- height: 8px;
273
+ width: 18px;
274
+ height: 4px;
212
275
  position: absolute;
213
- border-radius: 50%;
214
- }
215
-
216
- .ev-chart-legend-color.inactive {
217
- /*background-color: #555 !important;*/
218
276
  }
219
277
 
220
278
  .ev-chart-legend-name {
@@ -223,14 +281,20 @@
223
281
  white-space: nowrap;
224
282
  overflow: hidden;
225
283
  font-size: 12px;
226
- margin-left: 16px;
284
+ margin-left: 24px;
227
285
  padding-right: 16px;
228
- user-select:none;
286
+ user-select: none;
229
287
  top: 50%;
230
288
  left: 0;
231
289
  width: 100%;
290
+ font-family: 'Roboto';
291
+ font-weight: 400;
232
292
  transform: translate(0, -50%);
233
293
  position: absolute;
294
+
295
+ &:hover {
296
+ font-weight: bold;
297
+ }
234
298
  }
235
299
 
236
300
  .ev-chart-legend-value {
@@ -245,11 +309,11 @@
245
309
  position: absolute;
246
310
  background: transparent;
247
311
  opacity: 0.5;
248
- z-index: 1;
312
+ z-index: 10;
249
313
  }
250
314
 
251
315
  .ev-chart-resize-bar:hover {
252
- background-color: #e2e2e2;
316
+ background-color: #E2E2E2;
253
317
  }
254
318
 
255
319
  .ev-chart-resize-ghost {
@@ -258,7 +322,7 @@
258
322
  height: 100%;
259
323
  cursor: col-resize;
260
324
  opacity: 0.5;
261
- background-color: #e2e2e2;
325
+ background-color: #E2E2E2;
262
326
  }
263
327
 
264
328
  .ev-chart-resize-ghost.horizontal {
@@ -269,64 +333,18 @@
269
333
 
270
334
  .ev-chart-tooltip {
271
335
  position: absolute;
272
- z-index: 100000;
273
- color: #000;
274
- border-radius: 4px;
275
- border: 1px solid #D8D8D8;
276
- background: #fff;
277
- overflow-y: auto;
278
- max-height: 500px;
279
- padding: 10px;
280
- }
281
-
282
- .ev-chart-tooltip-title {
283
- font-size: 14px;
284
- text-align: center;
285
- margin: 0 5px 3px 5px;
286
- padding-bottom: 2px;
287
- border-bottom: 1px solid #D2D2D2;
288
- user-select: none;
289
- }
290
-
291
- .ev-chart-tooltip-ul {
292
- list-style: none;
293
- display: block;
294
- user-select: none;
295
- }
296
-
297
- .ev-chart-tooltip-li {
298
- border: none;
299
- padding: 0;
300
- margin: 0;
336
+ z-index: 850;
337
+ top: 0;
338
+ left: 0;
339
+ overflow-y: hidden;
340
+ overflow-x: hidden;
341
+ padding-right: 17px;
301
342
  }
302
343
 
303
- .ev-chart-tooltip-color {
304
- width: 10px;
305
- height: 10px;
344
+ .ev-chart-tooltip-canvas {
306
345
  position: absolute;
307
- margin: 8px 0 0 5px;
308
- border-radius: 5px;
309
- }
310
-
311
- .ev-chart-tooltip-name {
312
- text-align: left;
313
- text-overflow: ellipsis;
314
- white-space: nowrap;
315
- overflow: hidden;
316
- font-size: 12px;
317
- margin-left: 20px;
318
- width: 100%;
319
- user-select: none;
320
- color: #000;
321
- }
322
-
323
- .ev-chart-tooltip-colon {
324
- width: 100%;
325
- }
326
-
327
- .ev-chart-tooltip-value {
328
- font-size: 12px;
329
- margin-right: 5px;
346
+ top: 0;
347
+ left: 0;
348
+ display: block;
330
349
  }
331
-
332
350
  </style>
@@ -1,10 +1,11 @@
1
- import _merge from 'lodash/merge';
1
+ import { defaultsDeep } from 'lodash-es';
2
+ import { numberWithComma } from '@/common/utils';
2
3
  import { COLOR, BAR_OPTION } from '../helpers/helpers.constant';
3
4
  import Canvas from '../helpers/helpers.canvas';
4
5
 
5
6
  class Bar {
6
- constructor(sId, opt, sIdx) {
7
- const merged = _merge({}, BAR_OPTION, opt);
7
+ constructor(sId, opt, sIdx, isHorizontal) {
8
+ const merged = defaultsDeep({}, opt, BAR_OPTION);
8
9
  Object.keys(merged).forEach((key) => {
9
10
  this[key] = merged[key];
10
11
  });
@@ -17,22 +18,39 @@ class Bar {
17
18
  this.color = COLOR[sIdx];
18
19
  }
19
20
 
21
+ this.type = 'bar';
20
22
  this.sId = sId;
21
23
  this.data = [];
24
+ this.isHorizontal = isHorizontal;
25
+ this.size = {
26
+ cat: 0,
27
+ bar: 0,
28
+ cPad: 0,
29
+ bPad: 0,
30
+ w: 0,
31
+ h: 0,
32
+ ix: 0,
33
+ };
22
34
  }
23
35
 
36
+ /**
37
+ * Draw series data
38
+ * @param {object} param object for drawing series data
39
+ *
40
+ * @returns {undefined}
41
+ */
24
42
  draw(param) {
25
43
  if (!this.show) {
26
44
  return;
27
45
  }
28
46
 
47
+ const { isHorizontal, showValue } = this;
48
+
29
49
  const ctx = param.ctx;
30
50
  const chartRect = param.chartRect;
31
51
  const labelOffset = param.labelOffset;
32
52
  const axesSteps = param.axesSteps;
33
- const index = param.showIndex;
34
- const isHorizontal = param.isHorizontal;
35
- const labels = param.integLabels;
53
+ const showIndex = param.showIndex;
36
54
  const thickness = param.thickness;
37
55
  const showSeriesCount = param.showSeriesCount;
38
56
 
@@ -48,38 +66,41 @@ class Bar {
48
66
  const ysp = chartRect.y2 - labelOffset.bottom;
49
67
 
50
68
  const dArea = isHorizontal ? yArea : xArea;
51
- const cArea = dArea / (labels.length || 1);
69
+ const cArea = dArea / (this.data.length || 1);
52
70
  const cPad = 2;
53
71
 
54
72
  let bArea;
55
- if (this.isExistGrp) {
56
- bArea = (cArea - (cPad * 2));
57
- } else {
58
- bArea = (cArea - (cPad * 2)) / showSeriesCount;
59
- }
60
- let w = isHorizontal ? null : Math.round(bArea * thickness);
61
- let h = isHorizontal ? Math.round(bArea * thickness) : null;
73
+ let w;
74
+ let h;
75
+
76
+ bArea = (cArea - (cPad * 2));
77
+ bArea = this.isExistGrp ? bArea : bArea / showSeriesCount;
78
+
79
+ const size = Math.round(bArea * thickness);
80
+
81
+ w = isHorizontal ? null : size;
82
+ h = isHorizontal ? size : null;
62
83
 
63
- // barArea내에서 barWidth로 빠진 부분을 계산.
64
84
  const bPad = isHorizontal ? (bArea - h) / 2 : (bArea - w) / 2;
65
- // series index에 따라 시작 X값 보정을 위한 변수.
66
- const barSeriesX = this.isExistGrp ? 1 : index + 1;
85
+ const barSeriesX = this.isExistGrp ? 1 : showIndex + 1;
86
+
87
+ this.size.cat = cArea;
88
+ this.size.bar = bArea;
89
+ this.size.cPad = cPad;
90
+ this.size.bPad = bPad;
91
+ this.size.w = w;
92
+ this.size.ix = barSeriesX;
67
93
 
68
94
  let categoryPoint = null;
69
95
 
70
96
  ctx.beginPath();
71
97
  ctx.fillStyle = this.color;
72
98
 
73
- this.data.forEach((item) => {
74
- const posIdx = labels.indexOf(isHorizontal ? item.y : item.x);
75
- if (posIdx < 0) {
76
- return;
77
- }
78
-
99
+ this.data.forEach((item, index) => {
79
100
  if (isHorizontal) {
80
- categoryPoint = ysp - (cArea * posIdx) - cPad;
101
+ categoryPoint = ysp - (cArea * index) - cPad;
81
102
  } else {
82
- categoryPoint = xsp + (cArea * posIdx) + cPad;
103
+ categoryPoint = xsp + (cArea * index) + cPad;
83
104
  }
84
105
 
85
106
  if (isHorizontal) {
@@ -106,12 +127,185 @@ class Bar {
106
127
 
107
128
  ctx.fillRect(x, y, w, isHorizontal ? -h : h);
108
129
 
130
+
131
+ if (showValue.use) {
132
+ ctx.save();
133
+
134
+ const value = numberWithComma(isHorizontal ? item.x : item.y);
135
+
136
+ ctx.font = `normal normal normal ${showValue.fontSize}px Roboto`;
137
+ ctx.fillStyle = showValue.textColor;
138
+ ctx.lineWidth = 1;
139
+ ctx.textBaseline = isHorizontal ? 'middle' : 'bottom';
140
+ ctx.textAlign = 'center';
141
+
142
+ const vw = Math.round(ctx.measureText(value).width);
143
+ const vh = showValue.fontSize + 4;
144
+
145
+ if (vw < w && vh < Math.abs(h)) {
146
+ if (isHorizontal) {
147
+ ctx.fillText(value, x + w - vw, y - (h / 2));
148
+ } else {
149
+ ctx.fillText(value, x + (w / 2), y + h + vh);
150
+ }
151
+ }
152
+
153
+ ctx.restore();
154
+ }
155
+
109
156
  item.xp = x; // eslint-disable-line
110
157
  item.yp = y; // eslint-disable-line
111
158
  item.w = w; // eslint-disable-line
112
159
  item.h = isHorizontal ? -h : h; // eslint-disable-line
113
160
  });
114
161
  }
162
+
163
+ /**
164
+ * Draw item highlight
165
+ * @param {object} item object for drawing series data
166
+ * @param {object} context canvas context
167
+ *
168
+ * @returns {undefined}
169
+ */
170
+ itemHighlight(item, context) {
171
+ const isHorizontal = this.isHorizontal;
172
+ const showValue = this.showValue;
173
+
174
+ const gdata = item.data;
175
+ const ctx = context;
176
+
177
+ const x = gdata.xp;
178
+ const y = gdata.yp;
179
+ const w = gdata.w;
180
+ const h = gdata.h;
181
+
182
+ ctx.save();
183
+ ctx.fillStyle = this.color;
184
+ ctx.shadowOffsetX = 0;
185
+ ctx.shadowOffsetY = 0;
186
+ ctx.shadowBlur = 4;
187
+ ctx.shadowColor = this.color;
188
+
189
+ ctx.fillRect(x, y, w, h);
190
+
191
+ if (showValue.use) {
192
+ ctx.save();
193
+
194
+ const value = numberWithComma(isHorizontal ? gdata.x : gdata.y);
195
+
196
+ ctx.font = `normal normal normal ${showValue.fontSize}px Roboto`;
197
+ ctx.fillStyle = showValue.textColor;
198
+ ctx.lineWidth = 1;
199
+ ctx.textBaseline = isHorizontal ? 'middle' : 'bottom';
200
+ ctx.textAlign = 'center';
201
+
202
+ const vw = Math.round(ctx.measureText(value).width);
203
+ const vh = showValue.fontSize + 4;
204
+
205
+ if (vw < w && vh < Math.abs(h)) {
206
+ if (isHorizontal) {
207
+ ctx.fillText(value, x + w - vw, y + (h / 2));
208
+ } else {
209
+ ctx.fillText(value, x + (w / 2), y + h + vh);
210
+ }
211
+ }
212
+
213
+ ctx.restore();
214
+ }
215
+
216
+ ctx.restore();
217
+ }
218
+
219
+ /**
220
+ * Find graph item
221
+ * @param {array} offset mouse position
222
+ * @param {boolean} isHorizontal determines if a horizontal option's value
223
+ *
224
+ * @returns {object} graph item
225
+ */
226
+ findGraphData(offset, isHorizontal) {
227
+ return isHorizontal ? this.findGraphRangeCount(offset) : this.findGraphRange(offset);
228
+ }
229
+
230
+ /**
231
+ * Find graph item
232
+ * @param {array} offset mouse position
233
+ *
234
+ * @returns {object} graph item
235
+ */
236
+ findGraphRange(offset) {
237
+ const xp = offset[0];
238
+ const yp = offset[1];
239
+ const item = { data: null, hit: false, color: this.color };
240
+ const gdata = this.data;
241
+
242
+ let s = 0;
243
+ let e = gdata.length - 1;
244
+
245
+ while (s <= e) {
246
+ const m = Math.floor((s + e) / 2);
247
+ const sx = gdata[m].xp;
248
+ const sy = gdata[m].yp;
249
+ const ex = sx + gdata[m].w;
250
+ const ey = sy + gdata[m].h;
251
+
252
+ if ((sx <= xp) && (xp <= ex)) {
253
+ item.data = gdata[m];
254
+ item.index = m;
255
+
256
+ if ((ey <= yp) && (yp <= sy)) {
257
+ item.hit = true;
258
+ }
259
+ return item;
260
+ } else if (sx + 4 < xp) {
261
+ s = m + 1;
262
+ } else {
263
+ e = m - 1;
264
+ }
265
+ }
266
+
267
+ return item;
268
+ }
269
+
270
+ /**
271
+ * Find graph item (horizontal)
272
+ * @param {array} offset mouse position
273
+ *
274
+ * @returns {object} graph item
275
+ */
276
+ findGraphRangeCount(offset) {
277
+ const xp = offset[0];
278
+ const yp = offset[1];
279
+ const item = { data: null, hit: false, color: this.color };
280
+ const gdata = this.data;
281
+
282
+ let s = 0;
283
+ let e = gdata.length - 1;
284
+
285
+ while (s <= e) {
286
+ const m = Math.floor((s + e) / 2);
287
+ const sx = gdata[m].xp;
288
+ const sy = gdata[m].yp;
289
+ const ex = sx + gdata[m].w;
290
+ const ey = sy + gdata[m].h;
291
+
292
+ if ((ey <= yp) && (yp <= sy)) {
293
+ item.data = gdata[m];
294
+ item.index = m;
295
+
296
+ if ((sx <= xp) && (xp <= ex)) {
297
+ item.hit = true;
298
+ }
299
+ return item;
300
+ } else if (ey < yp) {
301
+ e = m - 1;
302
+ } else {
303
+ s = m + 1;
304
+ }
305
+ }
306
+
307
+ return item;
308
+ }
115
309
  }
116
310
 
117
311
  export default Bar;