evui 2.0.9 → 2.1.2

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 (185) hide show
  1. package/dist/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/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/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/425399f81e4ce7cbd967685402ba0260.woff +0 -0
  19. package/dist/4730076470a665bbc7b783c56d29a72e.svg +261 -0
  20. package/dist/52e9a7f6ff3af5ad261e5292d07ebdca.eot +0 -0
  21. package/dist/5367103510b27b78482794590e1ce3b0.ttf +0 -0
  22. package/dist/57e963e3d6dd0a9cf05150b40eebf69b.svg +1008 -0
  23. package/dist/65a2fb6d9aaa164b41a039302093995b.ttf +0 -0
  24. package/dist/687a4990ea22bb1a49d469a5d9319790.woff2 +0 -0
  25. package/dist/6c1d906bf5ba48676f65b2d65e935e1a.ttf +0 -0
  26. package/dist/6dafca5a4f1e31f2bdf11939b24ff422.ttf +0 -0
  27. package/dist/752905fa5edf21fc52a10a0c1ca9c7a4.eot +0 -0
  28. package/dist/76c05d80dda67cdc5d03f345b7bd063f.ttf +0 -0
  29. package/dist/7d62eb50e7bb05eedb2a4656f7fe8f3b.svg +366 -0
  30. package/dist/a01e3f2d6c83dc3aee175e2482b3f777.eot +0 -0
  31. package/dist/b30fd8419d7e6d5918856c7531d33482.svg +1518 -0
  32. package/dist/c57dd55fa982e8940f69ca1d69a8a999.woff +0 -0
  33. package/dist/c656b8caa454ed19b9a2ef7f4f5b8fea.ttf +0 -0
  34. package/dist/cac87dc00c87a5d74711d0276713808a.woff +0 -0
  35. package/dist/d68fa3e67dbb653a13cec44b1bcabcfe.eot +0 -0
  36. package/dist/ddae9b1ba9b0b42f58809904b0b21349.woff +0 -0
  37. package/dist/evui.min.js +19 -0
  38. package/dist/evui.min.js.gz +0 -0
  39. package/dist/evui.min.js.map +1 -0
  40. package/dist/main.css +85 -0
  41. package/dist/main.css.gz +0 -0
  42. package/dist/main.css.map +1 -0
  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 +317 -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 +23 -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 +299 -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/src/components/chart/charts/chart.bar.js +0 -334
  164. package/src/components/chart/charts/chart.base.js +0 -1075
  165. package/src/components/chart/charts/chart.line.js +0 -262
  166. package/src/components/chart/charts/chart.pie.js +0 -383
  167. package/src/components/chart/charts/chart.scatter.js +0 -349
  168. package/src/components/chart/charts/chart.sunburst.js +0 -193
  169. package/src/components/chart/core/axis/axis.js +0 -217
  170. package/src/components/chart/core/axis/axis.scale.auto.js +0 -69
  171. package/src/components/chart/core/axis/axis.scale.fixed.js +0 -65
  172. package/src/components/chart/core/axis/axis.scale.steps.js +0 -149
  173. package/src/components/chart/core/core.constant.js +0 -116
  174. package/src/components/chart/core/core.legend.js +0 -473
  175. package/src/components/chart/core/core.util.js +0 -66
  176. package/src/components/chart/core/data/data.js +0 -412
  177. package/src/components/chart/core/data/data.pie.js +0 -70
  178. package/src/components/chart/core/data/data.stack.js +0 -222
  179. package/src/components/chart/core/data/data.sunburst.js +0 -172
  180. package/src/components/menu/menu.context.children.vue +0 -201
  181. package/src/components/menu/menu.context.vue +0 -144
  182. package/src/components/tabs/jun/tab.vue +0 -123
  183. package/src/components/tabs/jun/tabs.vue +0 -484
  184. package/src/styles/evui.css +0 -386
  185. package/src/styles/icon.css +0 -557
@@ -1,54 +1,63 @@
1
- import moment from 'moment';
2
1
  import Scale from './scale';
3
2
  import Util from '../helpers/helpers.util';
4
3
 
5
4
  class StepScale extends Scale {
6
5
  constructor(type, opt, ctx, labels) {
7
6
  super(type, opt, ctx);
8
- this.integratedLabels = labels;
7
+ this.labels = labels;
9
8
  }
10
9
 
11
- calculateScaleRange(minMax) {
12
- const stepMinMax = this.timeMode ? minMax : Util.getStringMinMax(this.integratedLabels);
10
+ /**
11
+ * Calculate min/max value, label and size information for step scale
12
+ * @param {object} minMax min/max information (unused on step scale)
13
+ * @param {object} chartRect chart size information
14
+ *
15
+ * @returns {object} min/max value and label
16
+ */
17
+ calculateScaleRange(minMax, chartRect) {
18
+ const stepMinMax = Util.getStringMinMax(this.labels);
13
19
  const maxValue = stepMinMax.max;
14
20
  const minValue = stepMinMax.min;
21
+ const maxWidth = chartRect.chartWidth / (this.labels.length + 2);
15
22
 
16
23
  return {
17
24
  min: minValue,
18
25
  max: maxValue,
19
- minLabel: this.getLabelFormat(minValue),
20
- maxLabel: this.getLabelFormat(maxValue),
21
- size: Util.calcTextSize(this.getLabelFormat(maxValue), Util.getLabelStyle(this.labelStyle)),
26
+ minLabel: this.getLabelFormat(minValue, maxWidth),
27
+ maxLabel: this.getLabelFormat(maxValue, maxWidth),
28
+ size: Util.calcTextSize(
29
+ this.getLabelFormat(maxValue, maxWidth),
30
+ Util.getLabelStyle(this.labelStyle),
31
+ ),
22
32
  };
23
33
  }
24
34
 
35
+ /**
36
+ * With range information, calculate how many labels in axis
37
+ * @param {object} range min/max information
38
+ *
39
+ * @returns {object} steps, interval, min/max graph value
40
+ */
25
41
  calculateSteps(range) {
26
- const labels = this.integratedLabels;
27
- const maxSteps = range.maxSteps;
28
-
29
- let interval = 1;
30
- let numberOfSteps;
31
-
32
- const graphRange = labels.length;
33
-
34
- numberOfSteps = Math.round(graphRange / interval);
35
-
36
- while (numberOfSteps > maxSteps) {
37
- interval *= 2;
38
- numberOfSteps = Math.round(graphRange / interval);
39
- }
40
-
41
42
  return {
42
- steps: numberOfSteps,
43
- interval,
43
+ steps: this.labels.length,
44
+ interval: 1,
44
45
  graphMin: range.minValue,
45
46
  graphMax: range.maxValue,
46
47
  };
47
48
  }
48
49
 
50
+ /**
51
+ * Draw axis
52
+ * @param {object} chartRect min/max information
53
+ * @param {object} labelOffset label offset information
54
+ * @param {object} stepInfo label steps information
55
+ *
56
+ * @returns {undefined}
57
+ */
49
58
  draw(chartRect, labelOffset, stepInfo) {
50
59
  const ctx = this.ctx;
51
- const labels = this.integratedLabels;
60
+ const labels = this.labels;
52
61
  const aPos = {
53
62
  x1: chartRect.x1 + labelOffset.left,
54
63
  x2: chartRect.x2 - labelOffset.right,
@@ -57,12 +66,12 @@ class StepScale extends Scale {
57
66
  };
58
67
 
59
68
  const steps = stepInfo.steps;
60
- const interval = stepInfo.interval;
61
69
 
62
70
  const startPoint = aPos[this.units.rectStart];
63
71
  const endPoint = aPos[this.units.rectEnd];
64
72
  const offsetPoint = aPos[this.units.rectOffset(this.position)];
65
73
  const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
74
+ const maxWidth = chartRect.chartWidth / (this.labels.length + 2);
66
75
 
67
76
  // label font 설정
68
77
  ctx.font = Util.getLabelStyle(this.labelStyle);
@@ -103,23 +112,15 @@ class StepScale extends Scale {
103
112
 
104
113
  let labelText;
105
114
  let labelPoint;
106
- let prevIndex = 0;
107
115
 
108
- labels.reduce((prev, curr, index) => {
116
+ labels.forEach((item, index) => {
109
117
  labelCenter = Math.round(startPoint + (labelGap * index));
110
118
  linePosition = labelCenter + aliasPixel;
111
- labelText = this.getLabelFormat(curr);
119
+ labelText = this.getLabelFormat(item, maxWidth);
112
120
 
113
121
  if (this.type === 'x') {
114
122
  labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
115
- if (this.timeMode) {
116
- if (prev.label !== labelText && (index === 0 || index - prev.index > interval)) {
117
- prevIndex = index;
118
- ctx.fillText(labelText, labelCenter + (labelGap / 2), labelPoint);
119
- }
120
- } else {
121
- ctx.fillText(labelText, labelCenter + (labelGap / 2), labelPoint);
122
- }
123
+ ctx.fillText(labelText, labelCenter + (labelGap / 2), labelPoint);
123
124
 
124
125
  if (index > 0 && this.showGrid) {
125
126
  ctx.moveTo(linePosition, offsetPoint);
@@ -127,14 +128,7 @@ class StepScale extends Scale {
127
128
  }
128
129
  } else {
129
130
  labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
130
- if (this.timeMode) {
131
- if (prev.label !== labelText && (index === 0 || index - prev.index > interval)) {
132
- prevIndex = index;
133
- ctx.fillText(labelText, labelPoint, labelCenter + (labelGap / 2));
134
- }
135
- } else {
136
- ctx.fillText(labelText, labelPoint, labelCenter + (labelGap / 2));
137
- }
131
+ ctx.fillText(labelText, labelPoint, labelCenter + (labelGap / 2));
138
132
 
139
133
  if (index > 0 && this.showGrid) {
140
134
  ctx.moveTo(offsetPoint, linePosition);
@@ -142,18 +136,61 @@ class StepScale extends Scale {
142
136
  }
143
137
  }
144
138
  ctx.stroke();
145
-
146
- return { label: labelText, index: prevIndex };
147
- }, { label: '', index: prevIndex });
139
+ });
148
140
 
149
141
  ctx.closePath();
150
142
  }
151
143
 
152
- getLabelFormat(value) {
153
- if (this.timeMode) {
154
- return moment(new Date(value)).format(this.timeFormat);
144
+ /**
145
+ * Transforming label by designated format
146
+ * @param {string} value label value
147
+ * @param {number} maxWidth max width for each label
148
+ *
149
+ * @returns {string} formatted label
150
+ */
151
+ getLabelFormat(value, maxWidth) {
152
+ return this.labelStyle.fitWidth ? this.fittingString(value, maxWidth) : value;
153
+ }
154
+
155
+ /**
156
+ * Transforming ellipsis label by designated format and specific width
157
+ * @param {string} value label value
158
+ * @param {number} maxWidth max width for each label
159
+ *
160
+ * @returns {string} formatted label
161
+ */
162
+ fittingString(value, maxWidth) {
163
+ if (!value) {
164
+ return '';
165
+ }
166
+
167
+ if (!maxWidth) {
168
+ return value;
169
+ }
170
+
171
+ const ctx = this.ctx;
172
+
173
+ ctx.save();
174
+ ctx.font = Util.getLabelStyle(this.labelStyle);
175
+ const dir = this.labelStyle.fitDir;
176
+
177
+ const ellipsis = '…';
178
+ const ellipsisWidth = ctx.measureText(ellipsis).width;
179
+
180
+ let str = value;
181
+ let width = ctx.measureText(str).width;
182
+
183
+ if (width <= maxWidth || width <= ellipsisWidth) {
184
+ return str;
155
185
  }
156
- return value;
186
+
187
+ let len = str.length;
188
+ while (width >= maxWidth - ellipsisWidth && len-- > 0) {
189
+ str = dir === 'right' ? str.substring(0, len) : str.substring(1, str.length);
190
+ width = ctx.measureText(str).width;
191
+ }
192
+
193
+ return dir === 'right' ? str + ellipsis : ellipsis + str;
157
194
  }
158
195
  }
159
196
 
@@ -0,0 +1,204 @@
1
+ import moment from 'moment';
2
+ import { TIME_INTERVALS } from '../helpers/helpers.constant';
3
+ import Scale from './scale';
4
+ import Util from '../helpers/helpers.util';
5
+
6
+ class TimeCategoryScale extends Scale {
7
+ constructor(type, opt, ctx, labels) {
8
+ super(type, opt, ctx);
9
+ this.labels = labels;
10
+ }
11
+
12
+ /**
13
+ * Transforming label by designated format
14
+ * @param {number} value label value
15
+ *
16
+ * @returns {string} formatted label
17
+ */
18
+ getLabelFormat(value) {
19
+ return moment(value).format(this.timeFormat);
20
+ }
21
+
22
+ /**
23
+ * Calculate interval
24
+ * @param {object} range range information
25
+ *
26
+ * @returns {number} interval
27
+ */
28
+ getInterval(range) {
29
+ const max = range.maxValue;
30
+ const min = range.minValue;
31
+ const step = range.maxSteps;
32
+
33
+ if (this.interval) {
34
+ if (typeof this.interval === 'string') {
35
+ return TIME_INTERVALS[this.interval].size;
36
+ } else if (typeof this.interval === 'object') {
37
+ return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
38
+ } else if (typeof this.interval === 'number') {
39
+ return this.interval;
40
+ }
41
+ }
42
+ return Math.ceil((max - min) / step);
43
+ }
44
+
45
+ /**
46
+ * With range information, calculate how many labels in axis
47
+ * @param {object} range min/max information
48
+ *
49
+ * @returns {object} steps, interval, min/max graph value
50
+ */
51
+ calculateSteps(range) {
52
+ const { maxValue, minValue, maxSteps } = range;
53
+ const rawInterval = this.getInterval(range);
54
+
55
+ let interval = rawInterval;
56
+ let increase = minValue;
57
+ let numberOfSteps;
58
+
59
+ while (increase < maxValue) {
60
+ increase += interval;
61
+ }
62
+
63
+ const graphMax = increase > maxValue ? maxValue : increase;
64
+ const graphMin = minValue;
65
+ const graphRange = graphMax - graphMin;
66
+
67
+ numberOfSteps = Math.round(graphRange / interval) + 1;
68
+ const oriSteps = numberOfSteps;
69
+
70
+ if (maxValue === 1) {
71
+ interval = 0.2;
72
+ numberOfSteps = 5;
73
+ }
74
+
75
+ while (numberOfSteps > maxSteps) {
76
+ interval *= 2;
77
+ numberOfSteps = Math.round(graphRange / interval);
78
+ interval = Math.ceil(graphRange / numberOfSteps);
79
+ }
80
+
81
+ if (graphMax - graphMin > (numberOfSteps * interval)) {
82
+ interval = Math.ceil((graphMax - graphMin) / numberOfSteps);
83
+ }
84
+
85
+
86
+ return {
87
+ steps: numberOfSteps,
88
+ oriSteps,
89
+ interval,
90
+ rawInterval,
91
+ graphMin,
92
+ graphMax,
93
+ };
94
+ }
95
+
96
+ /**
97
+ * Draw axis
98
+ * @param {object} chartRect min/max information
99
+ * @param {object} labelOffset label offset information
100
+ * @param {object} stepInfo label steps information
101
+ *
102
+ * @returns {undefined}
103
+ */
104
+ draw(chartRect, labelOffset, stepInfo) {
105
+ const ctx = this.ctx;
106
+ const labels = this.labels;
107
+ const aPos = {
108
+ x1: chartRect.x1 + labelOffset.left,
109
+ x2: chartRect.x2 - labelOffset.right,
110
+ y1: chartRect.y1 + labelOffset.top,
111
+ y2: chartRect.y2 - labelOffset.bottom,
112
+ };
113
+
114
+ const steps = stepInfo.steps;
115
+ const axisMin = stepInfo.graphMin;
116
+ const axisMax = stepInfo.graphMax;
117
+ const stepValue = stepInfo.rawInterval;
118
+ const oriSteps = stepInfo.oriSteps;
119
+ const count = Math.round(oriSteps / steps);
120
+
121
+ let startPoint = aPos[this.units.rectStart];
122
+ const endPoint = aPos[this.units.rectEnd];
123
+ const offsetPoint = aPos[this.units.rectOffset(this.position)];
124
+ const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
125
+
126
+ // label font 설정
127
+ ctx.font = Util.getLabelStyle(this.labelStyle);
128
+
129
+ if (this.type === 'x') {
130
+ ctx.textAlign = 'center';
131
+ ctx.textBaseline = this.position === 'top' ? 'bottom' : 'top';
132
+ } else {
133
+ ctx.textAlign = this.position === 'left' ? 'right' : 'left';
134
+ ctx.textBaseline = 'middle';
135
+ }
136
+
137
+ ctx.fillStyle = this.labelStyle.color;
138
+ ctx.lineWidth = 1;
139
+ const aliasPixel = Util.aliasPixel(ctx.lineWidth);
140
+
141
+ ctx.beginPath();
142
+ ctx.strokeStyle = this.axisLineColor;
143
+ if (this.type === 'x') {
144
+ ctx.moveTo(startPoint, offsetPoint + aliasPixel);
145
+ ctx.lineTo(endPoint, offsetPoint + aliasPixel);
146
+ } else {
147
+ ctx.moveTo(offsetPoint + aliasPixel, startPoint);
148
+ ctx.lineTo(offsetPoint + aliasPixel, endPoint);
149
+ }
150
+ ctx.stroke();
151
+ ctx.closePath();
152
+
153
+ if (steps === 0 || axisMin === null) {
154
+ return;
155
+ }
156
+
157
+ const graphGap = (endPoint - startPoint) / (labels.length || 1);
158
+ if (this.categoryMode) {
159
+ startPoint += Math.ceil(graphGap / 2) - 2;
160
+ }
161
+
162
+ const ticks = [];
163
+ let labelCenter = null;
164
+ let linePosition = null;
165
+
166
+ ctx.beginPath();
167
+ ctx.strokeStyle = this.gridLineColor;
168
+
169
+ let labelText;
170
+ for (let ix = 0; ix < oriSteps; ix += count) {
171
+ ticks[ix] = axisMin + (ix * stepValue);
172
+
173
+ labelCenter = Math.round(startPoint + (graphGap * ix));
174
+ linePosition = labelCenter + aliasPixel;
175
+ labelText = this.getLabelFormat(Math.min(axisMax, ticks[ix]));
176
+
177
+ let labelPoint;
178
+
179
+ if (this.type === 'x') {
180
+ labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
181
+ ctx.fillText(labelText, labelCenter, labelPoint);
182
+
183
+ if ((ix !== 0 && ix < oriSteps && this.showGrid)) {
184
+ ctx.moveTo(linePosition, offsetPoint);
185
+ ctx.lineTo(linePosition, offsetCounterPoint);
186
+ }
187
+ } else {
188
+ labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
189
+ ctx.fillText(labelText, labelPoint, labelCenter);
190
+
191
+ if ((ix !== 0 && ix < oriSteps && this.showGrid)) {
192
+ ctx.moveTo(offsetPoint, linePosition);
193
+ ctx.lineTo(offsetCounterPoint, linePosition);
194
+ }
195
+ }
196
+
197
+ ctx.stroke();
198
+ }
199
+
200
+ ctx.closePath();
201
+ }
202
+ }
203
+
204
+ export default TimeCategoryScale;
@@ -3,17 +3,35 @@ import { TIME_INTERVALS } from '../helpers/helpers.constant';
3
3
  import Scale from './scale';
4
4
 
5
5
  class TimeScale extends Scale {
6
+ /**
7
+ * Transforming label by designated format
8
+ * @param {number} value label value
9
+ *
10
+ * @returns {string} formatted label
11
+ */
6
12
  getLabelFormat(value) {
7
13
  return moment(value).format(this.timeFormat);
8
14
  }
9
15
 
16
+ /**
17
+ * Calculate interval
18
+ * @param {object} range range information
19
+ *
20
+ * @returns {number} interval
21
+ */
10
22
  getInterval(range) {
11
23
  const max = range.maxValue;
12
24
  const min = range.minValue;
13
25
  const step = range.maxSteps;
14
26
 
15
27
  if (this.interval) {
16
- return TIME_INTERVALS[this.interval].size;
28
+ if (typeof this.interval === 'string') {
29
+ return TIME_INTERVALS[this.interval].size;
30
+ } else if (typeof this.interval === 'object') {
31
+ return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
32
+ } else if (typeof this.interval === 'number') {
33
+ return this.interval;
34
+ }
17
35
  }
18
36
  return Math.ceil((max - min) / step);
19
37
  }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div>
3
- <slot/>
3
+ <slot />
4
4
  </div>
5
5
  </template>
6
6
 
@@ -41,16 +41,10 @@
41
41
  },
42
42
  mounted() {
43
43
  this.initValue();
44
- const bindValue = this.bindValue;
45
- this.$on('change-event', (e) => {
46
- const targetValue = e.target.value;
47
- if (e.currentTarget.checked && bindValue.indexOf(targetValue) === -1) {
48
- bindValue.push(targetValue);
49
- } else if (!e.currentTarget.checked && bindValue.indexOf(targetValue) > -1) {
50
- bindValue.splice(bindValue.indexOf(targetValue), 1);
51
- }
52
- this.$parent.$emit('input', bindValue);
53
- });
44
+ this.$on('on-change', this.onChange);
45
+ },
46
+ beforeDestroy() {
47
+ this.$off('on-change', this.onChange);
54
48
  },
55
49
  methods: {
56
50
  initValue(array) {
@@ -64,6 +58,16 @@
64
58
  });
65
59
  }
66
60
  },
61
+ onChange(e) {
62
+ const bindValue = this.bindValue;
63
+ const targetValue = e.target.value;
64
+ if (e.currentTarget.checked && bindValue.indexOf(targetValue) === -1) {
65
+ bindValue.push(targetValue);
66
+ } else if (!e.currentTarget.checked && bindValue.indexOf(targetValue) > -1) {
67
+ bindValue.splice(bindValue.indexOf(targetValue), 1);
68
+ }
69
+ this.$parent.$emit('input', bindValue);
70
+ },
67
71
  },
68
72
  };
69
73
  </script>