evui 3.4.207 → 3.4.208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -33
- package/dist/404.html +44 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.js +22645 -0
- package/dist/index.umd.cjs +28 -0
- package/dist/style.css +1 -0
- package/package.json +46 -43
- package/dist/evui.common.js +0 -63681
- package/dist/evui.common.js.map +0 -1
- package/dist/evui.umd.js +0 -63691
- package/dist/evui.umd.js.map +0 -1
- package/dist/evui.umd.min.js +0 -2
- package/dist/evui.umd.min.js.map +0 -1
- package/dist/img/EVUI.b82ee81a.svg +0 -293
- package/src/assets/logo.png +0 -0
- package/src/common/emitter.js +0 -20
- package/src/common/utils.bignumber.js +0 -67
- package/src/common/utils.debounce.js +0 -223
- package/src/common/utils.js +0 -151
- package/src/common/utils.table.js +0 -78
- package/src/common/utils.throttle.js +0 -83
- package/src/common/utils.tree.js +0 -18
- package/src/components/button/Button.vue +0 -195
- package/src/components/button/index.js +0 -7
- package/src/components/buttonGroup/ButtonGroup.vue +0 -11
- package/src/components/buttonGroup/index.js +0 -7
- package/src/components/calendar/Calendar.vue +0 -725
- package/src/components/calendar/index.js +0 -7
- package/src/components/calendar/uses.js +0 -1410
- package/src/components/chart/Chart.vue +0 -363
- package/src/components/chart/ChartToolbar.vue +0 -52
- package/src/components/chart/chart.core.js +0 -1170
- package/src/components/chart/chartZoom.core.js +0 -540
- package/src/components/chart/element/element.bar.js +0 -672
- package/src/components/chart/element/element.bar.time.js +0 -166
- package/src/components/chart/element/element.heatmap.js +0 -743
- package/src/components/chart/element/element.line.js +0 -611
- package/src/components/chart/element/element.pie.js +0 -197
- package/src/components/chart/element/element.scatter.js +0 -320
- package/src/components/chart/element/element.tip.js +0 -717
- package/src/components/chart/helpers/helpers.canvas.js +0 -265
- package/src/components/chart/helpers/helpers.constant.js +0 -235
- package/src/components/chart/helpers/helpers.util.js +0 -400
- package/src/components/chart/index.js +0 -9
- package/src/components/chart/model/index.js +0 -50
- package/src/components/chart/model/model.series.js +0 -125
- package/src/components/chart/model/model.store.js +0 -1427
- package/src/components/chart/plugins/plugins.interaction.js +0 -1659
- package/src/components/chart/plugins/plugins.legend.gradient.js +0 -606
- package/src/components/chart/plugins/plugins.legend.js +0 -1543
- package/src/components/chart/plugins/plugins.pie.js +0 -254
- package/src/components/chart/plugins/plugins.scrollbar.js +0 -732
- package/src/components/chart/plugins/plugins.title.js +0 -61
- package/src/components/chart/plugins/plugins.tooltip.js +0 -1041
- package/src/components/chart/scale/scale.js +0 -951
- package/src/components/chart/scale/scale.linear.js +0 -268
- package/src/components/chart/scale/scale.logarithmic.js +0 -135
- package/src/components/chart/scale/scale.step.js +0 -430
- package/src/components/chart/scale/scale.time.category.js +0 -338
- package/src/components/chart/scale/scale.time.js +0 -49
- package/src/components/chart/style/chart.scss +0 -405
- package/src/components/chart/uses.js +0 -721
- package/src/components/chartBrush/ChartBrush.vue +0 -323
- package/src/components/chartBrush/chartBrush.core.js +0 -691
- package/src/components/chartBrush/index.js +0 -9
- package/src/components/chartBrush/uses.js +0 -23
- package/src/components/chartGroup/ChartGroup.vue +0 -144
- package/src/components/chartGroup/index.js +0 -9
- package/src/components/chartGroup/style/chartGroup.scss +0 -5
- package/src/components/chartGroup/uses.js +0 -53
- package/src/components/checkbox/Checkbox.vue +0 -229
- package/src/components/checkbox/index.js +0 -7
- package/src/components/checkboxGroup/CheckboxGroup.vue +0 -44
- package/src/components/checkboxGroup/index.js +0 -7
- package/src/components/contextMenu/ContextMenu.vue +0 -95
- package/src/components/contextMenu/MenuList.vue +0 -182
- package/src/components/contextMenu/index.js +0 -7
- package/src/components/contextMenu/uses.js +0 -223
- package/src/components/datePicker/DatePicker.vue +0 -504
- package/src/components/datePicker/index.js +0 -7
- package/src/components/datePicker/uses.js +0 -460
- package/src/components/grid/Grid.vue +0 -1535
- package/src/components/grid/GridColumnSetting.vue +0 -358
- package/src/components/grid/GridFilterSetting.vue +0 -323
- package/src/components/grid/GridPagination.vue +0 -75
- package/src/components/grid/GridSummary.vue +0 -314
- package/src/components/grid/GridToolbar.vue +0 -35
- package/src/components/grid/icon/icon-option-button.vue +0 -17
- package/src/components/grid/icon/icon-sort-button.vue +0 -67
- package/src/components/grid/index.js +0 -11
- package/src/components/grid/style/grid.scss +0 -417
- package/src/components/grid/uses.js +0 -1629
- package/src/components/icon/Icon.vue +0 -53
- package/src/components/icon/index.js +0 -8
- package/src/components/inputNumber/InputNumber.vue +0 -212
- package/src/components/inputNumber/index.js +0 -7
- package/src/components/inputNumber/uses.js +0 -217
- package/src/components/loading/Loading.vue +0 -125
- package/src/components/loading/index.js +0 -7
- package/src/components/menu/Menu.vue +0 -79
- package/src/components/menu/MenuItem.vue +0 -201
- package/src/components/menu/index.js +0 -7
- package/src/components/message/Message.vue +0 -229
- package/src/components/message/index.js +0 -34
- package/src/components/messageBox/MessageBox.vue +0 -358
- package/src/components/messageBox/index.js +0 -22
- package/src/components/notification/Notification.vue +0 -316
- package/src/components/notification/index.js +0 -49
- package/src/components/pagination/Pagination.vue +0 -317
- package/src/components/pagination/index.js +0 -7
- package/src/components/pagination/pageButton.vue +0 -31
- package/src/components/progress/Progress.vue +0 -139
- package/src/components/progress/index.js +0 -7
- package/src/components/radio/Radio.vue +0 -159
- package/src/components/radio/index.js +0 -7
- package/src/components/radioGroup/RadioGroup.vue +0 -41
- package/src/components/radioGroup/index.js +0 -7
- package/src/components/scheduler/Scheduler.vue +0 -149
- package/src/components/scheduler/index.js +0 -7
- package/src/components/scheduler/uses.js +0 -183
- package/src/components/select/Select.vue +0 -556
- package/src/components/select/index.js +0 -7
- package/src/components/select/uses.js +0 -379
- package/src/components/slider/Slider.vue +0 -505
- package/src/components/slider/index.js +0 -7
- package/src/components/slider/uses.js +0 -391
- package/src/components/tabPanel/TabPanel.vue +0 -74
- package/src/components/tabPanel/index.js +0 -7
- package/src/components/tabs/Tabs.vue +0 -517
- package/src/components/tabs/index.js +0 -7
- package/src/components/textField/TextField.vue +0 -399
- package/src/components/textField/index.js +0 -7
- package/src/components/timePicker/TimePicker.vue +0 -364
- package/src/components/timePicker/index.js +0 -7
- package/src/components/toggle/Toggle.vue +0 -115
- package/src/components/toggle/index.js +0 -7
- package/src/components/tree/Tree.vue +0 -338
- package/src/components/tree/TreeNode.vue +0 -293
- package/src/components/tree/index.js +0 -7
- package/src/components/treeGrid/TreeGrid.vue +0 -1074
- package/src/components/treeGrid/TreeGridNode.vue +0 -349
- package/src/components/treeGrid/TreeGridToolbar.vue +0 -35
- package/src/components/treeGrid/icon/icon-tree.png +0 -0
- package/src/components/treeGrid/index.js +0 -9
- package/src/components/treeGrid/style/treeGrid.scss +0 -277
- package/src/components/treeGrid/uses.js +0 -1178
- package/src/components/window/Window.vue +0 -329
- package/src/components/window/index.js +0 -7
- package/src/components/window/uses.js +0 -908
- package/src/directives/clickoutside.js +0 -90
- package/src/main.js +0 -120
- package/src/style/components/input.scss +0 -108
- package/src/style/functions.scss +0 -3
- package/src/style/index.scss +0 -6
- package/src/style/lib/fonts/EVUI.eot +0 -0
- package/src/style/lib/fonts/EVUI.svg +0 -293
- package/src/style/lib/fonts/EVUI.ttf +0 -0
- package/src/style/lib/fonts/EVUI.woff +0 -0
- package/src/style/lib/icon.css +0 -888
- package/src/style/mixins.scss +0 -94
- package/src/style/themes.scss +0 -69
- package/src/style/variables.scss +0 -22
|
@@ -1,338 +0,0 @@
|
|
|
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, axisOpt, ctx, labels, options) {
|
|
8
|
-
super(type, axisOpt, 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
|
-
* @param {object} data data for formatting
|
|
17
|
-
*
|
|
18
|
-
* @returns {string} formatted label
|
|
19
|
-
*/
|
|
20
|
-
getLabelFormat(value, data = {}) {
|
|
21
|
-
if (this.formatter) {
|
|
22
|
-
const formattedLabel = this.formatter(value, data);
|
|
23
|
-
|
|
24
|
-
if (typeof formattedLabel === 'string') {
|
|
25
|
-
return formattedLabel;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return dayjs(value).format(this.timeFormat);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Calculate interval
|
|
34
|
-
* @param {object} range range information
|
|
35
|
-
*
|
|
36
|
-
* @returns {number} interval
|
|
37
|
-
*/
|
|
38
|
-
getInterval(range) {
|
|
39
|
-
const max = range.maxValue;
|
|
40
|
-
const min = range.minValue;
|
|
41
|
-
const step = range.maxSteps;
|
|
42
|
-
|
|
43
|
-
if (this.interval) {
|
|
44
|
-
if (typeof this.interval === 'string') {
|
|
45
|
-
return TIME_INTERVALS[this.interval].size;
|
|
46
|
-
} else if (typeof this.interval === 'object') {
|
|
47
|
-
return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
|
|
48
|
-
} else if (typeof this.interval === 'number') {
|
|
49
|
-
return this.interval;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return Math.ceil((max - min) / step);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* With range information, calculate how many labels in axis
|
|
57
|
-
* @param {object} range min/max information
|
|
58
|
-
*
|
|
59
|
-
* @returns {object} steps, interval, min/max graph value
|
|
60
|
-
*/
|
|
61
|
-
calculateSteps(range) {
|
|
62
|
-
const { maxValue, minValue, maxSteps } = range;
|
|
63
|
-
const rawInterval = this.getInterval(range);
|
|
64
|
-
|
|
65
|
-
let interval = rawInterval;
|
|
66
|
-
let increase = minValue;
|
|
67
|
-
let numberOfSteps;
|
|
68
|
-
|
|
69
|
-
while (increase < maxValue) {
|
|
70
|
-
increase += interval;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const graphMax = increase > maxValue ? maxValue : increase;
|
|
74
|
-
const graphMin = minValue;
|
|
75
|
-
const graphRange = graphMax - graphMin;
|
|
76
|
-
|
|
77
|
-
numberOfSteps = Math.round(graphRange / interval) + 1;
|
|
78
|
-
const oriSteps = numberOfSteps;
|
|
79
|
-
|
|
80
|
-
if (maxValue === 1) {
|
|
81
|
-
interval = 0.2;
|
|
82
|
-
numberOfSteps = 5;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
while (numberOfSteps > maxSteps) {
|
|
86
|
-
interval *= 2;
|
|
87
|
-
numberOfSteps = Math.round(graphRange / interval);
|
|
88
|
-
interval = Math.ceil(graphRange / numberOfSteps);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (graphMax - graphMin > (numberOfSteps * interval)) {
|
|
92
|
-
interval = Math.ceil((graphMax - graphMin) / numberOfSteps);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
steps: numberOfSteps,
|
|
98
|
-
oriSteps,
|
|
99
|
-
interval,
|
|
100
|
-
rawInterval,
|
|
101
|
-
graphMin,
|
|
102
|
-
graphMax,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Draw axis
|
|
108
|
-
* @param {object} chartRect min/max information
|
|
109
|
-
* @param {object} labelOffset label offset information
|
|
110
|
-
* @param {object} stepInfo label steps information
|
|
111
|
-
*
|
|
112
|
-
* @returns {undefined}
|
|
113
|
-
*/
|
|
114
|
-
draw(chartRect, labelOffset, stepInfo, hitInfo, selectLabelInfo) {
|
|
115
|
-
const ctx = this.ctx;
|
|
116
|
-
const labels = this.labels;
|
|
117
|
-
const aPos = {
|
|
118
|
-
x1: chartRect.x1 + labelOffset.left,
|
|
119
|
-
x2: chartRect.x2 - labelOffset.right,
|
|
120
|
-
y1: chartRect.y1 + labelOffset.top,
|
|
121
|
-
y2: chartRect.y2 - labelOffset.bottom,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const steps = stepInfo.steps;
|
|
125
|
-
const axisMin = stepInfo.graphMin;
|
|
126
|
-
const axisMax = stepInfo.graphMax;
|
|
127
|
-
const stepValue = stepInfo.rawInterval;
|
|
128
|
-
const oriSteps = stepInfo.oriSteps;
|
|
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
|
-
const AXIS_TICK_LENGTH = 5;
|
|
136
|
-
|
|
137
|
-
this.drawAxisTitle(chartRect, labelOffset);
|
|
138
|
-
|
|
139
|
-
// label font 설정
|
|
140
|
-
ctx.font = Util.getLabelStyle(this.labelStyle);
|
|
141
|
-
|
|
142
|
-
if (this.type === 'x') {
|
|
143
|
-
ctx.textAlign = 'center';
|
|
144
|
-
ctx.textBaseline = this.position === 'top' ? 'bottom' : 'top';
|
|
145
|
-
} else {
|
|
146
|
-
ctx.textAlign = this.position === 'left' ? 'right' : 'left';
|
|
147
|
-
ctx.textBaseline = 'middle';
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
ctx.fillStyle = this.labelStyle.color;
|
|
151
|
-
ctx.lineWidth = this.axisLineWidth;
|
|
152
|
-
const aliasPixel = Util.aliasPixel(ctx.lineWidth);
|
|
153
|
-
|
|
154
|
-
ctx.beginPath();
|
|
155
|
-
ctx.strokeStyle = this.axisLineColor;
|
|
156
|
-
if (this.type === 'x') {
|
|
157
|
-
ctx.moveTo(startPoint, offsetPoint + aliasPixel);
|
|
158
|
-
ctx.lineTo(endPoint, offsetPoint + aliasPixel);
|
|
159
|
-
} else {
|
|
160
|
-
ctx.moveTo(offsetPoint + aliasPixel, startPoint);
|
|
161
|
-
ctx.lineTo(offsetPoint + aliasPixel, endPoint);
|
|
162
|
-
}
|
|
163
|
-
ctx.stroke();
|
|
164
|
-
ctx.closePath();
|
|
165
|
-
|
|
166
|
-
if (steps === 0 || axisMin === null) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const alignToGridLine = this.labelStyle.alignToGridLine;
|
|
171
|
-
const graphGap = (endPoint - startPoint) / (oriSteps || 1);
|
|
172
|
-
if (this.categoryMode && !alignToGridLine) {
|
|
173
|
-
startPoint += Math.ceil(graphGap / 2) - 2;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const ticks = [];
|
|
177
|
-
let labelCenter = null;
|
|
178
|
-
let linePosition = null;
|
|
179
|
-
|
|
180
|
-
ctx.beginPath();
|
|
181
|
-
ctx.strokeStyle = this.gridLineColor;
|
|
182
|
-
|
|
183
|
-
let labelText;
|
|
184
|
-
let labelPoint;
|
|
185
|
-
let ix;
|
|
186
|
-
|
|
187
|
-
// 2개 이하일 경우, 첫번째와 마지막 라벨만 표시
|
|
188
|
-
let count = steps <= 2 ? oriSteps : Math.round(oriSteps / steps);
|
|
189
|
-
|
|
190
|
-
// 첫번째 라벨이 축 시작점보다 오른쪽에 있을 경우, count를 1로 설정
|
|
191
|
-
// 추후 개선 필요: 근본적 문제는 라벨이 2개인 경우 oriSteps가 1로 와야하는데 2로 옴. horizontal일 때 예외처리 필요.
|
|
192
|
-
const isStartPointRightOfRectStart = startPoint > Math.ceil(aPos[this.units.rectStart]);
|
|
193
|
-
if (this.type === 'x' && isStartPointRightOfRectStart && count === oriSteps) {
|
|
194
|
-
count = 1;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const maxIndex = count === oriSteps ? oriSteps : oriSteps - 1;
|
|
198
|
-
|
|
199
|
-
for (ix = 0; ix <= maxIndex; ix += count) {
|
|
200
|
-
ticks[ix] = dayjs(axisMin).valueOf() + (ix * stepValue);
|
|
201
|
-
|
|
202
|
-
labelCenter = Math.round(startPoint + (graphGap * ix));
|
|
203
|
-
linePosition = labelCenter + aliasPixel;
|
|
204
|
-
|
|
205
|
-
let prev;
|
|
206
|
-
for (let jx = 0; jx < ticks.length; jx++) {
|
|
207
|
-
if (ticks[jx] !== undefined && jx !== ix) {
|
|
208
|
-
prev = ticks[jx];
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
labelText = this.getLabelFormat(Math.min(axisMax, ticks[ix]), { prev });
|
|
213
|
-
|
|
214
|
-
const isBlurredLabel = this.options?.selectLabel?.use
|
|
215
|
-
&& this.options?.selectLabel?.useLabelOpacity
|
|
216
|
-
&& (this.options.horizontal === (this.type === 'y'))
|
|
217
|
-
&& selectLabelInfo?.dataIndex?.length
|
|
218
|
-
&& !selectLabelInfo?.label
|
|
219
|
-
.map(t => this.getLabelFormat(Math.min(axisMax, t), {
|
|
220
|
-
prev,
|
|
221
|
-
})).includes(labelText);
|
|
222
|
-
|
|
223
|
-
const labelColor = this.labelStyle.color;
|
|
224
|
-
let defaultOpacity = 1;
|
|
225
|
-
|
|
226
|
-
if (Util.getColorStringType(labelColor) === 'RGBA') {
|
|
227
|
-
defaultOpacity = Util.getOpacity(labelColor);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
ctx.fillStyle = Util.colorStringToRgba(labelColor, isBlurredLabel ? 0.1 : defaultOpacity);
|
|
231
|
-
|
|
232
|
-
if (this.type === 'x') {
|
|
233
|
-
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
234
|
-
ctx.fillText(labelText, labelCenter, labelPoint);
|
|
235
|
-
if (!isBlurredLabel
|
|
236
|
-
&& this.options?.selectItem?.showLabelTip
|
|
237
|
-
&& hitInfo?.label
|
|
238
|
-
&& !this.options?.horizontal) {
|
|
239
|
-
const selectedLabel = this.getLabelFormat(
|
|
240
|
-
Math.min(axisMax, hitInfo.label + (0 * stepValue)),
|
|
241
|
-
);
|
|
242
|
-
if (selectedLabel === labelText) {
|
|
243
|
-
const height = Math.round(ctx.measureText(this.labelStyle?.fontSize).width);
|
|
244
|
-
Util.showLabelTip({
|
|
245
|
-
ctx: this.ctx,
|
|
246
|
-
width: Math.round(ctx.measureText(selectedLabel).width) + 10,
|
|
247
|
-
height,
|
|
248
|
-
x: labelCenter,
|
|
249
|
-
y: labelPoint + (height - 2),
|
|
250
|
-
borderRadius: 2,
|
|
251
|
-
arrowSize: 3,
|
|
252
|
-
text: labelText,
|
|
253
|
-
backgroundColor: this.options?.selectItem?.labelTipStyle?.backgroundColor,
|
|
254
|
-
textColor: this.options?.selectItem?.labelTipStyle?.textColor,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (this.showAxisTick) {
|
|
260
|
-
ctx.beginPath();
|
|
261
|
-
ctx.strokeStyle = this.axisLineColor;
|
|
262
|
-
ctx.moveTo(linePosition, offsetPoint);
|
|
263
|
-
ctx.lineTo(linePosition, offsetPoint + AXIS_TICK_LENGTH);
|
|
264
|
-
ctx.stroke();
|
|
265
|
-
ctx.closePath();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
ix < oriSteps && this.showGrid && (
|
|
270
|
-
isStartPointRightOfRectStart || (!isStartPointRightOfRectStart && ix !== 0)
|
|
271
|
-
)
|
|
272
|
-
) {
|
|
273
|
-
ctx.beginPath();
|
|
274
|
-
ctx.strokeStyle = this.gridLineColor;
|
|
275
|
-
ctx.moveTo(linePosition, offsetPoint);
|
|
276
|
-
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
277
|
-
ctx.stroke();
|
|
278
|
-
ctx.closePath();
|
|
279
|
-
}
|
|
280
|
-
} else {
|
|
281
|
-
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
282
|
-
ctx.fillText(labelText, labelPoint, labelCenter);
|
|
283
|
-
|
|
284
|
-
if (this.showAxisTick) {
|
|
285
|
-
ctx.beginPath();
|
|
286
|
-
ctx.strokeStyle = this.axisLineColor;
|
|
287
|
-
ctx.moveTo(offsetPoint + (this.axisLineWidth ?? 1), linePosition);
|
|
288
|
-
ctx.lineTo(offsetPoint - AXIS_TICK_LENGTH, linePosition);
|
|
289
|
-
ctx.stroke();
|
|
290
|
-
ctx.closePath();
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
ix < oriSteps && this.showGrid && (
|
|
295
|
-
isStartPointRightOfRectStart || (!isStartPointRightOfRectStart && ix !== 0)
|
|
296
|
-
)) {
|
|
297
|
-
ctx.beginPath();
|
|
298
|
-
ctx.strokeStyle = this.gridLineColor;
|
|
299
|
-
ctx.moveTo(offsetPoint, linePosition);
|
|
300
|
-
ctx.lineTo(offsetCounterPoint, linePosition);
|
|
301
|
-
ctx.stroke();
|
|
302
|
-
ctx.closePath();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
ctx.stroke();
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (this.categoryMode && alignToGridLine && (ix * count) === oriSteps) {
|
|
310
|
-
const diffTime = dayjs(labels[1]).diff(dayjs(labels[0]));
|
|
311
|
-
const labelLastText = this.getLabelFormat(
|
|
312
|
-
dayjs(ticks[oriSteps - 1] + diffTime),
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
labelCenter = Math.round(startPoint + (graphGap * oriSteps));
|
|
316
|
-
linePosition = labelCenter + aliasPixel;
|
|
317
|
-
|
|
318
|
-
if (this.type === 'x') {
|
|
319
|
-
ctx.fillText(labelLastText, labelCenter, labelPoint);
|
|
320
|
-
if (this.showGrid) {
|
|
321
|
-
ctx.moveTo(linePosition, offsetPoint);
|
|
322
|
-
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
323
|
-
}
|
|
324
|
-
} else {
|
|
325
|
-
ctx.fillText(labelLastText, labelPoint, labelCenter);
|
|
326
|
-
if (this.showGrid) {
|
|
327
|
-
ctx.moveTo(offsetPoint, linePosition);
|
|
328
|
-
ctx.lineTo(offsetCounterPoint, linePosition);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
ctx.stroke();
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
ctx.closePath();
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export default TimeCategoryScale;
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
* @param {object} data data for formatting
|
|
10
|
-
*
|
|
11
|
-
* @returns {string} formatted label
|
|
12
|
-
*/
|
|
13
|
-
getLabelFormat(value, data = {}) {
|
|
14
|
-
if (this.formatter) {
|
|
15
|
-
const formattedLabel = this.formatter(value, data);
|
|
16
|
-
|
|
17
|
-
if (typeof formattedLabel === 'string') {
|
|
18
|
-
return formattedLabel;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return dayjs(value).format(this.timeFormat);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Calculate interval
|
|
27
|
-
* @param {object} range range information
|
|
28
|
-
*
|
|
29
|
-
* @returns {number} interval
|
|
30
|
-
*/
|
|
31
|
-
getInterval(range) {
|
|
32
|
-
const max = range.maxValue;
|
|
33
|
-
const min = range.minValue;
|
|
34
|
-
const step = range.maxSteps;
|
|
35
|
-
|
|
36
|
-
if (this.interval) {
|
|
37
|
-
if (typeof this.interval === 'string') {
|
|
38
|
-
return TIME_INTERVALS[this.interval].size;
|
|
39
|
-
} else if (typeof this.interval === 'object') {
|
|
40
|
-
return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
|
|
41
|
-
} else if (typeof this.interval === 'number') {
|
|
42
|
-
return this.interval;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return Math.ceil((max - min) / step);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default TimeScale;
|