evui 3.3.36 → 3.3.39

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 (141) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +40 -40
  3. package/dist/evui.common.js +1907 -1832
  4. package/dist/evui.common.js.map +1 -1
  5. package/dist/evui.umd.js +1907 -1832
  6. package/dist/evui.umd.js.map +1 -1
  7. package/dist/evui.umd.min.js +1 -1
  8. package/dist/evui.umd.min.js.map +1 -1
  9. package/dist/img/{EVUI.7f3588fb.svg → EVUI.b82ee81a.svg} +292 -292
  10. package/dist/img/{icon_mysql.7ea26d5d.svg → icon_mysql.1085fdc9.svg} +78 -78
  11. package/dist/img/{icon_oracle.9009b108.svg → icon_oracle.0572d3ee.svg} +13 -13
  12. package/dist/img/{icon_postgresql.f8fffba9.svg → icon_postgresql.ee12bde8.svg} +58 -58
  13. package/package.json +61 -61
  14. package/src/common/emitter.js +20 -20
  15. package/src/common/utils.debounce.js +223 -223
  16. package/src/common/utils.js +134 -134
  17. package/src/common/utils.table.js +78 -78
  18. package/src/common/utils.throttle.js +83 -83
  19. package/src/common/utils.tree.js +18 -18
  20. package/src/components/button/Button.vue +198 -198
  21. package/src/components/button/index.js +7 -7
  22. package/src/components/buttonGroup/ButtonGroup.vue +11 -11
  23. package/src/components/buttonGroup/index.js +7 -7
  24. package/src/components/calendar/Calendar.vue +661 -661
  25. package/src/components/calendar/index.js +7 -7
  26. package/src/components/calendar/uses.js +1272 -1272
  27. package/src/components/chart/Chart.vue +189 -192
  28. package/src/components/chart/chart.core.js +870 -870
  29. package/src/components/chart/element/element.bar.js +524 -524
  30. package/src/components/chart/element/element.bar.time.js +156 -156
  31. package/src/components/chart/element/element.heatmap.js +533 -533
  32. package/src/components/chart/element/element.line.js +339 -339
  33. package/src/components/chart/element/element.pie.js +197 -197
  34. package/src/components/chart/element/element.scatter.js +184 -184
  35. package/src/components/chart/element/element.tip.js +550 -542
  36. package/src/components/chart/helpers/helpers.canvas.js +265 -265
  37. package/src/components/chart/helpers/helpers.constant.js +206 -206
  38. package/src/components/chart/helpers/helpers.util.js +346 -338
  39. package/src/components/chart/index.js +9 -9
  40. package/src/components/chart/model/index.js +4 -4
  41. package/src/components/chart/model/model.series.js +93 -93
  42. package/src/components/chart/model/model.store.js +977 -967
  43. package/src/components/chart/plugins/plugins.interaction.js +769 -769
  44. package/src/components/chart/plugins/plugins.legend.gradient.js +602 -602
  45. package/src/components/chart/plugins/plugins.legend.js +1155 -1151
  46. package/src/components/chart/plugins/plugins.pie.js +254 -254
  47. package/src/components/chart/plugins/plugins.title.js +56 -56
  48. package/src/components/chart/plugins/plugins.tooltip.js +692 -692
  49. package/src/components/chart/scale/scale.js +848 -848
  50. package/src/components/chart/scale/scale.linear.js +38 -38
  51. package/src/components/chart/scale/scale.logarithmic.js +128 -128
  52. package/src/components/chart/scale/scale.step.js +336 -336
  53. package/src/components/chart/scale/scale.time.category.js +277 -277
  54. package/src/components/chart/scale/scale.time.js +48 -48
  55. package/src/components/chart/style/chart.scss +312 -312
  56. package/src/components/chart/uses.js +264 -252
  57. package/src/components/checkbox/Checkbox.vue +200 -200
  58. package/src/components/checkbox/index.js +7 -7
  59. package/src/components/checkboxGroup/CheckboxGroup.vue +44 -44
  60. package/src/components/checkboxGroup/index.js +7 -7
  61. package/src/components/contextMenu/ContextMenu.vue +80 -80
  62. package/src/components/contextMenu/MenuList.vue +149 -149
  63. package/src/components/contextMenu/index.js +7 -7
  64. package/src/components/contextMenu/uses.js +203 -203
  65. package/src/components/datePicker/DatePicker.vue +437 -437
  66. package/src/components/datePicker/index.js +7 -7
  67. package/src/components/datePicker/uses.js +419 -419
  68. package/src/components/grid/Grid.vue +827 -827
  69. package/src/components/grid/grid.filter.window.vue +493 -493
  70. package/src/components/grid/grid.pagination.vue +75 -75
  71. package/src/components/grid/grid.summary.vue +265 -265
  72. package/src/components/grid/grid.toolbar.vue +26 -26
  73. package/src/components/grid/index.js +11 -11
  74. package/src/components/grid/style/grid.scss +263 -263
  75. package/src/components/grid/uses.js +1002 -1007
  76. package/src/components/icon/Icon.vue +49 -49
  77. package/src/components/icon/index.js +8 -8
  78. package/src/components/inputNumber/InputNumber.vue +212 -212
  79. package/src/components/inputNumber/index.js +7 -7
  80. package/src/components/inputNumber/uses.js +217 -217
  81. package/src/components/loading/Loading.vue +125 -125
  82. package/src/components/loading/index.js +7 -7
  83. package/src/components/menu/Menu.vue +68 -68
  84. package/src/components/menu/MenuItem.vue +187 -187
  85. package/src/components/menu/index.js +7 -7
  86. package/src/components/message/Message.vue +223 -223
  87. package/src/components/message/index.js +31 -31
  88. package/src/components/messageBox/MessageBox.vue +358 -358
  89. package/src/components/messageBox/index.js +22 -22
  90. package/src/components/notification/Notification.vue +316 -316
  91. package/src/components/notification/index.js +49 -49
  92. package/src/components/pagination/Pagination.vue +271 -271
  93. package/src/components/pagination/index.js +7 -7
  94. package/src/components/pagination/pageButton.vue +30 -30
  95. package/src/components/progress/Progress.vue +139 -139
  96. package/src/components/progress/index.js +7 -7
  97. package/src/components/radio/Radio.vue +159 -159
  98. package/src/components/radio/index.js +7 -7
  99. package/src/components/radioGroup/RadioGroup.vue +41 -41
  100. package/src/components/radioGroup/index.js +7 -7
  101. package/src/components/scheduler/Scheduler.vue +149 -149
  102. package/src/components/scheduler/index.js +7 -7
  103. package/src/components/scheduler/uses.js +183 -183
  104. package/src/components/select/Select.vue +440 -440
  105. package/src/components/select/index.js +7 -7
  106. package/src/components/select/uses.js +270 -270
  107. package/src/components/slider/Slider.vue +505 -505
  108. package/src/components/slider/index.js +7 -7
  109. package/src/components/slider/uses.js +390 -390
  110. package/src/components/tabPanel/TabPanel.vue +74 -74
  111. package/src/components/tabPanel/index.js +7 -7
  112. package/src/components/tabs/Tabs.vue +517 -517
  113. package/src/components/tabs/index.js +7 -7
  114. package/src/components/textField/TextField.vue +375 -375
  115. package/src/components/textField/index.js +7 -7
  116. package/src/components/timePicker/TimePicker.vue +352 -352
  117. package/src/components/timePicker/index.js +7 -7
  118. package/src/components/toggle/Toggle.vue +115 -115
  119. package/src/components/toggle/index.js +7 -7
  120. package/src/components/tree/Tree.vue +313 -313
  121. package/src/components/tree/TreeNode.vue +293 -293
  122. package/src/components/tree/index.js +7 -7
  123. package/src/components/treeGrid/TreeGrid.vue +758 -758
  124. package/src/components/treeGrid/TreeGridNode.vue +275 -275
  125. package/src/components/treeGrid/index.js +9 -9
  126. package/src/components/treeGrid/style/treeGrid.scss +261 -261
  127. package/src/components/treeGrid/treeGrid.toolbar.vue +26 -26
  128. package/src/components/treeGrid/uses.js +867 -867
  129. package/src/components/window/Window.vue +329 -329
  130. package/src/components/window/index.js +7 -7
  131. package/src/components/window/uses.js +899 -899
  132. package/src/directives/clickoutside.js +90 -90
  133. package/src/main.js +116 -116
  134. package/src/style/components/input.scss +108 -108
  135. package/src/style/functions.scss +3 -3
  136. package/src/style/index.scss +6 -6
  137. package/src/style/lib/fonts/EVUI.svg +292 -292
  138. package/src/style/lib/icon.css +888 -888
  139. package/src/style/mixins.scss +94 -94
  140. package/src/style/themes.scss +67 -67
  141. package/src/style/variables.scss +22 -22
@@ -1,277 +1,277 @@
1
- import dayjs from 'dayjs';
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, options) {
8
- super(type, opt, ctx);
9
- this.labels = labels;
10
- this.options = options;
11
- }
12
-
13
- /**
14
- * Transforming label by designated format
15
- * @param {number} value label value
16
- *
17
- * @returns {string} formatted label
18
- */
19
- getLabelFormat(value) {
20
- if (this.formatter) {
21
- const formattedLabel = this.formatter(value);
22
-
23
- if (typeof formattedLabel === 'string') {
24
- return formattedLabel;
25
- }
26
- }
27
-
28
- return dayjs(value).format(this.timeFormat);
29
- }
30
-
31
- /**
32
- * Calculate interval
33
- * @param {object} range range information
34
- *
35
- * @returns {number} interval
36
- */
37
- getInterval(range) {
38
- const max = range.maxValue;
39
- const min = range.minValue;
40
- const step = range.maxSteps;
41
-
42
- if (this.interval) {
43
- if (typeof this.interval === 'string') {
44
- return TIME_INTERVALS[this.interval].size;
45
- } else if (typeof this.interval === 'object') {
46
- return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
47
- } else if (typeof this.interval === 'number') {
48
- return this.interval;
49
- }
50
- }
51
- return Math.ceil((max - min) / step);
52
- }
53
-
54
- /**
55
- * With range information, calculate how many labels in axis
56
- * @param {object} range min/max information
57
- *
58
- * @returns {object} steps, interval, min/max graph value
59
- */
60
- calculateSteps(range) {
61
- const { maxValue, minValue, maxSteps } = range;
62
- const rawInterval = this.getInterval(range);
63
-
64
- let interval = rawInterval;
65
- let increase = minValue;
66
- let numberOfSteps;
67
-
68
- while (increase < maxValue) {
69
- increase += interval;
70
- }
71
-
72
- const graphMax = increase > maxValue ? maxValue : increase;
73
- const graphMin = minValue;
74
- const graphRange = graphMax - graphMin;
75
-
76
- numberOfSteps = Math.round(graphRange / interval) + 1;
77
- const oriSteps = numberOfSteps;
78
-
79
- if (maxValue === 1) {
80
- interval = 0.2;
81
- numberOfSteps = 5;
82
- }
83
-
84
- while (numberOfSteps > maxSteps) {
85
- interval *= 2;
86
- numberOfSteps = Math.round(graphRange / interval);
87
- interval = Math.ceil(graphRange / numberOfSteps);
88
- }
89
-
90
- if (graphMax - graphMin > (numberOfSteps * interval)) {
91
- interval = Math.ceil((graphMax - graphMin) / numberOfSteps);
92
- }
93
-
94
-
95
- return {
96
- steps: numberOfSteps,
97
- oriSteps,
98
- interval,
99
- rawInterval,
100
- graphMin,
101
- graphMax,
102
- };
103
- }
104
-
105
- /**
106
- * Draw axis
107
- * @param {object} chartRect min/max information
108
- * @param {object} labelOffset label offset information
109
- * @param {object} stepInfo label steps information
110
- *
111
- * @returns {undefined}
112
- */
113
- draw(chartRect, labelOffset, stepInfo, hitInfo, selectLabelInfo) {
114
- const ctx = this.ctx;
115
- const labels = this.labels;
116
- const aPos = {
117
- x1: chartRect.x1 + labelOffset.left,
118
- x2: chartRect.x2 - labelOffset.right,
119
- y1: chartRect.y1 + labelOffset.top,
120
- y2: chartRect.y2 - labelOffset.bottom,
121
- };
122
-
123
- const steps = stepInfo.steps;
124
- const axisMin = stepInfo.graphMin;
125
- const axisMax = stepInfo.graphMax;
126
- const stepValue = stepInfo.rawInterval;
127
- const oriSteps = stepInfo.oriSteps;
128
- const count = Math.round(oriSteps / steps);
129
-
130
- let startPoint = aPos[this.units.rectStart];
131
- const endPoint = aPos[this.units.rectEnd];
132
- const offsetPoint = aPos[this.units.rectOffset(this.position)];
133
- const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
134
-
135
- this.drawAxisTitle(chartRect, labelOffset);
136
-
137
- // label font 설정
138
- ctx.font = Util.getLabelStyle(this.labelStyle);
139
-
140
- if (this.type === 'x') {
141
- ctx.textAlign = 'center';
142
- ctx.textBaseline = this.position === 'top' ? 'bottom' : 'top';
143
- } else {
144
- ctx.textAlign = this.position === 'left' ? 'right' : 'left';
145
- ctx.textBaseline = 'middle';
146
- }
147
-
148
- ctx.fillStyle = this.labelStyle.color;
149
- ctx.lineWidth = 1;
150
- const aliasPixel = Util.aliasPixel(ctx.lineWidth);
151
-
152
- ctx.beginPath();
153
- ctx.strokeStyle = this.axisLineColor;
154
- if (this.type === 'x') {
155
- ctx.moveTo(startPoint, offsetPoint + aliasPixel);
156
- ctx.lineTo(endPoint, offsetPoint + aliasPixel);
157
- } else {
158
- ctx.moveTo(offsetPoint + aliasPixel, startPoint);
159
- ctx.lineTo(offsetPoint + aliasPixel, endPoint);
160
- }
161
- ctx.stroke();
162
- ctx.closePath();
163
-
164
- if (steps === 0 || axisMin === null) {
165
- return;
166
- }
167
-
168
- const alignToGridLine = this.labelStyle.alignToGridLine;
169
- const graphGap = (endPoint - startPoint) / (labels.length || 1);
170
- if (this.categoryMode && !alignToGridLine) {
171
- startPoint += Math.ceil(graphGap / 2) - 2;
172
- }
173
-
174
- const ticks = [];
175
- let labelCenter = null;
176
- let linePosition = null;
177
-
178
- ctx.beginPath();
179
- ctx.strokeStyle = this.gridLineColor;
180
-
181
- let labelText;
182
- let labelPoint;
183
- for (let ix = 0; ix < oriSteps; ix += count) {
184
- ticks[ix] = axisMin + (ix * stepValue);
185
-
186
- labelCenter = Math.round(startPoint + (graphGap * ix));
187
- linePosition = labelCenter + aliasPixel;
188
- labelText = this.getLabelFormat(Math.min(axisMax, ticks[ix]));
189
-
190
- const isBlurredLabel = this.options?.selectLabel?.use
191
- && this.options?.selectLabel?.useLabelOpacity
192
- && (this.options.horizontal === (this.type === 'y'))
193
- && selectLabelInfo?.dataIndex?.length
194
- && !selectLabelInfo?.dataIndex?.includes(ix);
195
-
196
- const labelColor = this.labelStyle.color;
197
- let defaultOpacity = 1;
198
-
199
- if (Util.getColorStringType(labelColor) === 'RGBA') {
200
- defaultOpacity = Util.getOpacity(labelColor);
201
- }
202
-
203
- ctx.fillStyle = Util.colorStringToRgba(labelColor, isBlurredLabel ? 0.1 : defaultOpacity);
204
-
205
- if (this.type === 'x') {
206
- labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
207
- ctx.fillText(labelText, labelCenter, labelPoint);
208
- if (!isBlurredLabel
209
- && this.options?.selectItem?.showLabelTip
210
- && hitInfo?.label
211
- && !this.options?.horizontal) {
212
- const selectedLabel = this.getLabelFormat(
213
- Math.min(axisMax, hitInfo.label + (0 * stepValue)),
214
- );
215
- if (selectedLabel === labelText) {
216
- const height = Math.round(ctx.measureText(this.labelStyle?.fontSize).width);
217
- Util.showLabelTip({
218
- ctx: this.ctx,
219
- width: Math.round(ctx.measureText(selectedLabel).width) + 10,
220
- height,
221
- x: labelCenter,
222
- y: labelPoint + (height - 2),
223
- borderRadius: 2,
224
- arrowSize: 3,
225
- text: labelText,
226
- backgroundColor: this.options?.selectItem?.labelTipStyle?.backgroundColor,
227
- textColor: this.options?.selectItem?.labelTipStyle?.textColor,
228
- });
229
- }
230
- }
231
- if ((ix !== 0 && ix < oriSteps && this.showGrid)) {
232
- ctx.moveTo(linePosition, offsetPoint);
233
- ctx.lineTo(linePosition, offsetCounterPoint);
234
- }
235
- } else {
236
- labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
237
- ctx.fillText(labelText, labelPoint, labelCenter);
238
-
239
- if ((ix !== 0 && ix < oriSteps && this.showGrid)) {
240
- ctx.moveTo(offsetPoint, linePosition);
241
- ctx.lineTo(offsetCounterPoint, linePosition);
242
- }
243
- }
244
-
245
- ctx.stroke();
246
- }
247
-
248
- if (this.categoryMode && alignToGridLine && (count * steps) === oriSteps) {
249
- const diffTime = dayjs(labels[1]).diff(dayjs(labels[0]));
250
- const labelLastText = this.getLabelFormat(
251
- dayjs(labels[labels.length - 1] + diffTime),
252
- );
253
-
254
- labelCenter = Math.round(startPoint + (graphGap * labels.length));
255
- linePosition = labelCenter + aliasPixel;
256
-
257
- if (this.type === 'x') {
258
- ctx.fillText(labelLastText, labelCenter, labelPoint);
259
- if (this.showGrid) {
260
- ctx.moveTo(linePosition, offsetPoint);
261
- ctx.lineTo(linePosition, offsetCounterPoint);
262
- }
263
- } else {
264
- ctx.fillText(labelLastText, labelPoint, labelCenter);
265
- if (this.showGrid) {
266
- ctx.moveTo(offsetPoint, linePosition);
267
- ctx.lineTo(offsetCounterPoint, linePosition);
268
- }
269
- }
270
- ctx.stroke();
271
- }
272
-
273
- ctx.closePath();
274
- }
275
- }
276
-
277
- export default TimeCategoryScale;
1
+ import dayjs from 'dayjs';
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, options) {
8
+ super(type, opt, ctx);
9
+ this.labels = labels;
10
+ this.options = options;
11
+ }
12
+
13
+ /**
14
+ * Transforming label by designated format
15
+ * @param {number} value label value
16
+ *
17
+ * @returns {string} formatted label
18
+ */
19
+ getLabelFormat(value) {
20
+ if (this.formatter) {
21
+ const formattedLabel = this.formatter(value);
22
+
23
+ if (typeof formattedLabel === 'string') {
24
+ return formattedLabel;
25
+ }
26
+ }
27
+
28
+ return dayjs(value).format(this.timeFormat);
29
+ }
30
+
31
+ /**
32
+ * Calculate interval
33
+ * @param {object} range range information
34
+ *
35
+ * @returns {number} interval
36
+ */
37
+ getInterval(range) {
38
+ const max = range.maxValue;
39
+ const min = range.minValue;
40
+ const step = range.maxSteps;
41
+
42
+ if (this.interval) {
43
+ if (typeof this.interval === 'string') {
44
+ return TIME_INTERVALS[this.interval].size;
45
+ } else if (typeof this.interval === 'object') {
46
+ return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
47
+ } else if (typeof this.interval === 'number') {
48
+ return this.interval;
49
+ }
50
+ }
51
+ return Math.ceil((max - min) / step);
52
+ }
53
+
54
+ /**
55
+ * With range information, calculate how many labels in axis
56
+ * @param {object} range min/max information
57
+ *
58
+ * @returns {object} steps, interval, min/max graph value
59
+ */
60
+ calculateSteps(range) {
61
+ const { maxValue, minValue, maxSteps } = range;
62
+ const rawInterval = this.getInterval(range);
63
+
64
+ let interval = rawInterval;
65
+ let increase = minValue;
66
+ let numberOfSteps;
67
+
68
+ while (increase < maxValue) {
69
+ increase += interval;
70
+ }
71
+
72
+ const graphMax = increase > maxValue ? maxValue : increase;
73
+ const graphMin = minValue;
74
+ const graphRange = graphMax - graphMin;
75
+
76
+ numberOfSteps = Math.round(graphRange / interval) + 1;
77
+ const oriSteps = numberOfSteps;
78
+
79
+ if (maxValue === 1) {
80
+ interval = 0.2;
81
+ numberOfSteps = 5;
82
+ }
83
+
84
+ while (numberOfSteps > maxSteps) {
85
+ interval *= 2;
86
+ numberOfSteps = Math.round(graphRange / interval);
87
+ interval = Math.ceil(graphRange / numberOfSteps);
88
+ }
89
+
90
+ if (graphMax - graphMin > (numberOfSteps * interval)) {
91
+ interval = Math.ceil((graphMax - graphMin) / numberOfSteps);
92
+ }
93
+
94
+
95
+ return {
96
+ steps: numberOfSteps,
97
+ oriSteps,
98
+ interval,
99
+ rawInterval,
100
+ graphMin,
101
+ graphMax,
102
+ };
103
+ }
104
+
105
+ /**
106
+ * Draw axis
107
+ * @param {object} chartRect min/max information
108
+ * @param {object} labelOffset label offset information
109
+ * @param {object} stepInfo label steps information
110
+ *
111
+ * @returns {undefined}
112
+ */
113
+ draw(chartRect, labelOffset, stepInfo, hitInfo, selectLabelInfo) {
114
+ const ctx = this.ctx;
115
+ const labels = this.labels;
116
+ const aPos = {
117
+ x1: chartRect.x1 + labelOffset.left,
118
+ x2: chartRect.x2 - labelOffset.right,
119
+ y1: chartRect.y1 + labelOffset.top,
120
+ y2: chartRect.y2 - labelOffset.bottom,
121
+ };
122
+
123
+ const steps = stepInfo.steps;
124
+ const axisMin = stepInfo.graphMin;
125
+ const axisMax = stepInfo.graphMax;
126
+ const stepValue = stepInfo.rawInterval;
127
+ const oriSteps = stepInfo.oriSteps;
128
+ const count = Math.round(oriSteps / steps);
129
+
130
+ let startPoint = aPos[this.units.rectStart];
131
+ const endPoint = aPos[this.units.rectEnd];
132
+ const offsetPoint = aPos[this.units.rectOffset(this.position)];
133
+ const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
134
+
135
+ this.drawAxisTitle(chartRect, labelOffset);
136
+
137
+ // label font 설정
138
+ ctx.font = Util.getLabelStyle(this.labelStyle);
139
+
140
+ if (this.type === 'x') {
141
+ ctx.textAlign = 'center';
142
+ ctx.textBaseline = this.position === 'top' ? 'bottom' : 'top';
143
+ } else {
144
+ ctx.textAlign = this.position === 'left' ? 'right' : 'left';
145
+ ctx.textBaseline = 'middle';
146
+ }
147
+
148
+ ctx.fillStyle = this.labelStyle.color;
149
+ ctx.lineWidth = 1;
150
+ const aliasPixel = Util.aliasPixel(ctx.lineWidth);
151
+
152
+ ctx.beginPath();
153
+ ctx.strokeStyle = this.axisLineColor;
154
+ if (this.type === 'x') {
155
+ ctx.moveTo(startPoint, offsetPoint + aliasPixel);
156
+ ctx.lineTo(endPoint, offsetPoint + aliasPixel);
157
+ } else {
158
+ ctx.moveTo(offsetPoint + aliasPixel, startPoint);
159
+ ctx.lineTo(offsetPoint + aliasPixel, endPoint);
160
+ }
161
+ ctx.stroke();
162
+ ctx.closePath();
163
+
164
+ if (steps === 0 || axisMin === null) {
165
+ return;
166
+ }
167
+
168
+ const alignToGridLine = this.labelStyle.alignToGridLine;
169
+ const graphGap = (endPoint - startPoint) / (labels.length || 1);
170
+ if (this.categoryMode && !alignToGridLine) {
171
+ startPoint += Math.ceil(graphGap / 2) - 2;
172
+ }
173
+
174
+ const ticks = [];
175
+ let labelCenter = null;
176
+ let linePosition = null;
177
+
178
+ ctx.beginPath();
179
+ ctx.strokeStyle = this.gridLineColor;
180
+
181
+ let labelText;
182
+ let labelPoint;
183
+ for (let ix = 0; ix < oriSteps; ix += count) {
184
+ ticks[ix] = axisMin + (ix * stepValue);
185
+
186
+ labelCenter = Math.round(startPoint + (graphGap * ix));
187
+ linePosition = labelCenter + aliasPixel;
188
+ labelText = this.getLabelFormat(Math.min(axisMax, ticks[ix]));
189
+
190
+ const isBlurredLabel = this.options?.selectLabel?.use
191
+ && this.options?.selectLabel?.useLabelOpacity
192
+ && (this.options.horizontal === (this.type === 'y'))
193
+ && selectLabelInfo?.dataIndex?.length
194
+ && !selectLabelInfo?.dataIndex?.includes(ix);
195
+
196
+ const labelColor = this.labelStyle.color;
197
+ let defaultOpacity = 1;
198
+
199
+ if (Util.getColorStringType(labelColor) === 'RGBA') {
200
+ defaultOpacity = Util.getOpacity(labelColor);
201
+ }
202
+
203
+ ctx.fillStyle = Util.colorStringToRgba(labelColor, isBlurredLabel ? 0.1 : defaultOpacity);
204
+
205
+ if (this.type === 'x') {
206
+ labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
207
+ ctx.fillText(labelText, labelCenter, labelPoint);
208
+ if (!isBlurredLabel
209
+ && this.options?.selectItem?.showLabelTip
210
+ && hitInfo?.label
211
+ && !this.options?.horizontal) {
212
+ const selectedLabel = this.getLabelFormat(
213
+ Math.min(axisMax, hitInfo.label + (0 * stepValue)),
214
+ );
215
+ if (selectedLabel === labelText) {
216
+ const height = Math.round(ctx.measureText(this.labelStyle?.fontSize).width);
217
+ Util.showLabelTip({
218
+ ctx: this.ctx,
219
+ width: Math.round(ctx.measureText(selectedLabel).width) + 10,
220
+ height,
221
+ x: labelCenter,
222
+ y: labelPoint + (height - 2),
223
+ borderRadius: 2,
224
+ arrowSize: 3,
225
+ text: labelText,
226
+ backgroundColor: this.options?.selectItem?.labelTipStyle?.backgroundColor,
227
+ textColor: this.options?.selectItem?.labelTipStyle?.textColor,
228
+ });
229
+ }
230
+ }
231
+ if ((ix !== 0 && ix < oriSteps && this.showGrid)) {
232
+ ctx.moveTo(linePosition, offsetPoint);
233
+ ctx.lineTo(linePosition, offsetCounterPoint);
234
+ }
235
+ } else {
236
+ labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
237
+ ctx.fillText(labelText, labelPoint, labelCenter);
238
+
239
+ if ((ix !== 0 && ix < oriSteps && this.showGrid)) {
240
+ ctx.moveTo(offsetPoint, linePosition);
241
+ ctx.lineTo(offsetCounterPoint, linePosition);
242
+ }
243
+ }
244
+
245
+ ctx.stroke();
246
+ }
247
+
248
+ if (this.categoryMode && alignToGridLine && (count * steps) === oriSteps) {
249
+ const diffTime = dayjs(labels[1]).diff(dayjs(labels[0]));
250
+ const labelLastText = this.getLabelFormat(
251
+ dayjs(labels[labels.length - 1] + diffTime),
252
+ );
253
+
254
+ labelCenter = Math.round(startPoint + (graphGap * labels.length));
255
+ linePosition = labelCenter + aliasPixel;
256
+
257
+ if (this.type === 'x') {
258
+ ctx.fillText(labelLastText, labelCenter, labelPoint);
259
+ if (this.showGrid) {
260
+ ctx.moveTo(linePosition, offsetPoint);
261
+ ctx.lineTo(linePosition, offsetCounterPoint);
262
+ }
263
+ } else {
264
+ ctx.fillText(labelLastText, labelPoint, labelCenter);
265
+ if (this.showGrid) {
266
+ ctx.moveTo(offsetPoint, linePosition);
267
+ ctx.lineTo(offsetCounterPoint, linePosition);
268
+ }
269
+ }
270
+ ctx.stroke();
271
+ }
272
+
273
+ ctx.closePath();
274
+ }
275
+ }
276
+
277
+ export default TimeCategoryScale;
@@ -1,48 +1,48 @@
1
- import dayjs from 'dayjs';
2
- import { TIME_INTERVALS } from '../helpers/helpers.constant';
3
- import Scale from './scale';
4
-
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
- */
12
- getLabelFormat(value) {
13
- if (this.formatter) {
14
- const formattedLabel = this.formatter(value);
15
-
16
- if (typeof formattedLabel === 'string') {
17
- return formattedLabel;
18
- }
19
- }
20
-
21
- return dayjs(value).format(this.timeFormat);
22
- }
23
-
24
- /**
25
- * Calculate interval
26
- * @param {object} range range information
27
- *
28
- * @returns {number} interval
29
- */
30
- getInterval(range) {
31
- const max = range.maxValue;
32
- const min = range.minValue;
33
- const step = range.maxSteps;
34
-
35
- if (this.interval) {
36
- if (typeof this.interval === 'string') {
37
- return TIME_INTERVALS[this.interval].size;
38
- } else if (typeof this.interval === 'object') {
39
- return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
40
- } else if (typeof this.interval === 'number') {
41
- return this.interval;
42
- }
43
- }
44
- return Math.ceil((max - min) / step);
45
- }
46
- }
47
-
48
- export default TimeScale;
1
+ import dayjs from 'dayjs';
2
+ import { TIME_INTERVALS } from '../helpers/helpers.constant';
3
+ import Scale from './scale';
4
+
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
+ */
12
+ getLabelFormat(value) {
13
+ if (this.formatter) {
14
+ const formattedLabel = this.formatter(value);
15
+
16
+ if (typeof formattedLabel === 'string') {
17
+ return formattedLabel;
18
+ }
19
+ }
20
+
21
+ return dayjs(value).format(this.timeFormat);
22
+ }
23
+
24
+ /**
25
+ * Calculate interval
26
+ * @param {object} range range information
27
+ *
28
+ * @returns {number} interval
29
+ */
30
+ getInterval(range) {
31
+ const max = range.maxValue;
32
+ const min = range.minValue;
33
+ const step = range.maxSteps;
34
+
35
+ if (this.interval) {
36
+ if (typeof this.interval === 'string') {
37
+ return TIME_INTERVALS[this.interval].size;
38
+ } else if (typeof this.interval === 'object') {
39
+ return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
40
+ } else if (typeof this.interval === 'number') {
41
+ return this.interval;
42
+ }
43
+ }
44
+ return Math.ceil((max - min) / step);
45
+ }
46
+ }
47
+
48
+ export default TimeScale;