evui 3.4.153 → 3.4.154
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/package.json
CHANGED
|
@@ -44,100 +44,6 @@ class TimeScale extends Scale {
|
|
|
44
44
|
}
|
|
45
45
|
return Math.ceil((max - min) / step);
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* With range information, calculate how many labels in axis
|
|
50
|
-
* @param {object} range min/max information
|
|
51
|
-
*
|
|
52
|
-
* @returns {object} steps, interval, min/max graph value
|
|
53
|
-
*/
|
|
54
|
-
calculateSteps(range) {
|
|
55
|
-
const { maxValue, minValue, maxSteps } = range;
|
|
56
|
-
|
|
57
|
-
// 사용자 interval로 인식하는 경우: 숫자 또는 객체({ time, unit }) 형태만
|
|
58
|
-
// 문자열('hour', 'second' 등)은 기존 로직(분기 D)으로 처리
|
|
59
|
-
const hasUserRange = Array.isArray(this.range) && this.range.length === 2;
|
|
60
|
-
const hasUserInterval = (
|
|
61
|
-
typeof this.interval === 'number'
|
|
62
|
-
|| (typeof this.interval === 'object' && this.interval !== null)
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const resolvedInterval = hasUserInterval ? this.getInterval(range) : null;
|
|
66
|
-
const isValidInterval = (
|
|
67
|
-
resolvedInterval != null
|
|
68
|
-
&& resolvedInterval > 0
|
|
69
|
-
&& isFinite(resolvedInterval)
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const graphMin = +minValue;
|
|
73
|
-
let graphMax = +maxValue;
|
|
74
|
-
const graphRange = graphMax - graphMin;
|
|
75
|
-
|
|
76
|
-
let interval;
|
|
77
|
-
let steps;
|
|
78
|
-
|
|
79
|
-
if (hasUserRange && isValidInterval) {
|
|
80
|
-
// 1) user range + interval
|
|
81
|
-
const candidateSteps = graphRange / resolvedInterval;
|
|
82
|
-
const isExactlyDividable = Math.abs(candidateSteps - Math.round(candidateSteps)) < 1e-10;
|
|
83
|
-
if (isExactlyDividable && candidateSteps <= maxSteps) {
|
|
84
|
-
// 1-1) interval 호환되는 경우
|
|
85
|
-
interval = resolvedInterval;
|
|
86
|
-
steps = Math.round(candidateSteps);
|
|
87
|
-
} else {
|
|
88
|
-
// 1-2) interval 호환되지 않음 -> 사용자 interval을 사용하지 않음
|
|
89
|
-
steps = maxSteps;
|
|
90
|
-
interval = graphRange / steps;
|
|
91
|
-
}
|
|
92
|
-
} else if (hasUserRange) {
|
|
93
|
-
// 2) user range only
|
|
94
|
-
steps = maxSteps;
|
|
95
|
-
interval = graphRange / steps;
|
|
96
|
-
} else if (isValidInterval) {
|
|
97
|
-
// 3) user interval only
|
|
98
|
-
interval = resolvedInterval;
|
|
99
|
-
steps = Math.ceil(graphRange / interval);
|
|
100
|
-
while (steps > maxSteps) {
|
|
101
|
-
interval *= 2;
|
|
102
|
-
steps = Math.ceil(graphRange / interval);
|
|
103
|
-
}
|
|
104
|
-
graphMax = graphMin + (interval * steps);
|
|
105
|
-
} else {
|
|
106
|
-
// 4) 기존 로직
|
|
107
|
-
interval = this.getInterval(range);
|
|
108
|
-
let increase = minValue;
|
|
109
|
-
let numberOfSteps;
|
|
110
|
-
|
|
111
|
-
while (increase < maxValue) {
|
|
112
|
-
increase += interval;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
graphMax = increase;
|
|
116
|
-
|
|
117
|
-
numberOfSteps = Math.round(graphRange / interval);
|
|
118
|
-
|
|
119
|
-
while (numberOfSteps > maxSteps) {
|
|
120
|
-
interval *= 2;
|
|
121
|
-
numberOfSteps = Math.round(graphRange / interval);
|
|
122
|
-
const tempInterval = graphRange / numberOfSteps;
|
|
123
|
-
interval = this.decimalPoint ? tempInterval : Math.ceil(tempInterval);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (graphMax - graphMin > (numberOfSteps * interval)) {
|
|
127
|
-
const tempInterval = (graphMax - graphMin) / numberOfSteps;
|
|
128
|
-
interval = this.decimalPoint ? tempInterval : Math.ceil(tempInterval);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
steps = numberOfSteps;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
steps,
|
|
136
|
-
interval,
|
|
137
|
-
graphMin,
|
|
138
|
-
graphMax,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
47
|
}
|
|
142
48
|
|
|
143
49
|
export default TimeScale;
|