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

Function updateIntervalOrLogScaleForNiceOrAligned

src/coord/axisHelper.ts:323–360  ·  view source on GitHub ↗
(
    scale: IntervalScale | LogScale,
    fixMinMax: ScaleExtentFixMinMax,
    oldIntervalExtent: number[],
    newIntervalExtent: number[],
    oldOutermostExtent: number[] | NullUndefined,
    cfg: IntervalScaleConfig
)

Source from the content-addressed store, hash-verified

321}
322
323export function updateIntervalOrLogScaleForNiceOrAligned(
324 scale: IntervalScale | LogScale,
325 fixMinMax: ScaleExtentFixMinMax,
326 oldIntervalExtent: number[],
327 newIntervalExtent: number[],
328 oldOutermostExtent: number[] | NullUndefined,
329 cfg: IntervalScaleConfig
330): void {
331 const isTargetLogScale = isLogScale(scale);
332 const intervalStub = isTargetLogScale ? scale.intervalStub : scale;
333 intervalStub.setExtent(newIntervalExtent[0], newIntervalExtent[1]);
334
335 if (isTargetLogScale) {
336 // Sync intervalStub extent to the outermost extent (i.e., `powStub` for `LogScale`).
337 const powStub = scale.powStub;
338 const opt = {depth: SCALE_MAPPER_DEPTH_OUT_OF_BREAK} as const;
339 let minPow = scale.transformOut(newIntervalExtent[0], opt);
340 let maxPow = scale.transformOut(newIntervalExtent[1], opt);
341 // Log transform is probably not inversible by rounding error, which causes min/max tick may be
342 // displayed as `5.999999999999999` unexpectedly when min/max are required to be fixed (specified
343 // by users or by dataZoom). Therefore we set `powStub` with respect to `oldOutermostExtent` if
344 // interval extent is not changed. But `intervalStub` should not be inversely changed by this
345 // handling, otherwise its monotonicity between `niceExtent` and `extent` may be broken and cause
346 // unexpected ticks generation.
347 const extentChanged = extentDiffers(oldIntervalExtent, newIntervalExtent);
348 // NOTE: extent may still be changed even when min/max are required to be fixed,
349 // e.g., by `intervalScaleEnsureValidExtent`.
350 if (fixMinMax[0] && !extentChanged[0]) {
351 minPow = oldOutermostExtent[0];
352 }
353 if (fixMinMax[1] && !extentChanged[1]) {
354 maxPow = oldOutermostExtent[1];
355 }
356 powStub.setExtent(minPow, maxPow);
357 }
358
359 intervalStub.setConfig(cfg);
360}
361
362export function getTickValueOutermost(scale: Scale, tick: ScaleTick): number {
363 return isOrdinalScale(scale)

Callers 2

scaleCalcAlignFunction · 0.90

Calls 5

isLogScaleFunction · 0.90
extentDiffersFunction · 0.90
setConfigMethod · 0.80
setExtentMethod · 0.65
transformOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…