MCPcopy
hub / github.com/apache/echarts / intervalScaleCalcNiceTicks

Function intervalScaleCalcNiceTicks

src/coord/axisNiceTicks.ts:118–150  ·  view source on GitHub ↗
(
    scale: IntervalScale,
    opt: Pick<ScaleCalcNiceMethodOpt, 'splitNumber' | 'minInterval' | 'maxInterval' | 'userInterval'>
)

Source from the content-addressed store, hash-verified

116// ------ START: IntervalScale Nice ------
117
118function intervalScaleCalcNiceTicks(
119 scale: IntervalScale,
120 opt: Pick<ScaleCalcNiceMethodOpt, 'splitNumber' | 'minInterval' | 'maxInterval' | 'userInterval'>
121): IntervalScaleConfig {
122 const splitNumber = ensureValidSplitNumber(opt.splitNumber, 5);
123 // Use the span in the innermost linear space to calculate nice ticks.
124 const span = getScaleLinearSpanEffective(scale);
125
126 if (__DEV__) {
127 assert(isFinite(span) && span > 0); // It should have been ensured by `intervalScaleEnsureValidExtent`.
128 }
129
130 const minInterval = opt.minInterval;
131 const maxInterval = opt.maxInterval;
132
133 let interval = nice(span / splitNumber, true);
134 if (minInterval != null && interval < minInterval) {
135 interval = minInterval;
136 }
137 if (maxInterval != null && interval > maxInterval) {
138 interval = maxInterval;
139 }
140
141 const intervalPrecision = getIntervalPrecision(interval);
142 const extent = scale.getExtent();
143 // By design, the `niceExtent` is inside the original extent
144 const niceExtent = [
145 round(mathCeil(extent[0] / interval) * interval, intervalPrecision),
146 round(mathFloor(extent[1] / interval) * interval, intervalPrecision)
147 ];
148
149 return {interval, intervalPrecision, niceExtent};
150};
151
152// ------ END: IntervalScale Nice ------
153

Callers 1

Calls 7

ensureValidSplitNumberFunction · 0.90
niceFunction · 0.90
getIntervalPrecisionFunction · 0.90
roundFunction · 0.90
getExtentMethod · 0.65
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…