Skip to content

fix(axis): fix axis label may have inappropriate precision or take too much unexpected space when alignTicks is enabled#21430

Merged
100pah merged 71 commits intoreleasefrom
fix/alignTicks-precision
May 4, 2026
Merged

fix(axis): fix axis label may have inappropriate precision or take too much unexpected space when alignTicks is enabled#21430
100pah merged 71 commits intoreleasefrom
fix/alignTicks-precision

Conversation

@plainheart
Copy link
Copy Markdown
Member

@plainheart plainheart commented Dec 17, 2025

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

This PR is to fix the following issues when alignTicks is enabled:

  1. Fix axis label may have inappropriate precision.
  2. Fix axis label takes too much unexpected space.

Fixed issues

Comparison

Before After
image image
image image
image image
image image

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

Security Checking

  • This PR uses security-sensitive Web APIs.

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

See the 6th/7th/8th test cases in test/axis-align-ticks.html

Merging options

  • Please squash the commits into a single one when merging.

Other information

…o much unexpected space when `alignTicks` is enabled
@echarts-bot
Copy link
Copy Markdown

echarts-bot Bot commented Dec 17, 2025

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

The pull request is marked to be PR: author is committer because you are a committer of this project.

@plainheart plainheart added this to the 6.0.1 milestone Dec 17, 2025
@plainheart plainheart requested review from Ovilia and pissang December 17, 2025 17:54
@github-actions
Copy link
Copy Markdown
Contributor

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-21430@eb45d17

@nuteu
Copy link
Copy Markdown

nuteu commented Dec 23, 2025

@plainheart 请问这个mr后续会回合到 5.x 版本吗

100pah added 4 commits January 8, 2026 16:57
… Make the rounding result consistent between dataZoom calculated window and specified axis `determinedMin/Max`. (3) Fix unexpected behaviors when dataZoom controls axes with `alignTicks: true` - previous they are not precisely aligned and the ticks jump significantly due to inappropriate rounding when dataZoom dragging.
@plainheart
Copy link
Copy Markdown
Member Author

plainheart commented Jan 9, 2026

@nuteu 除非有安全性问题,通常不会再更新旧版本。若有需求,可以考虑使用 patch-package 工具制作一个补丁。

…s data may be out of the calculated extent and can not be displayed. (2) Previously the precision is incorrect for small float number (fixed at 10 rather than based on the magnitude of the value). (3) Make the tick precision more acceptable when min/max of axis is fixed, and remove console warning, because whey can be specified when dataZoom dragging. (4) Clarify the related code for LogScale.
…ayout. (3) Remove unreasonable clamp in Interval calcNiceExtent, and clarify the definition of `_niceExtent`.
@100pah
Copy link
Copy Markdown
Member

100pah commented Jan 15, 2026

Additional modifications:

Comprehensively fixed bad cases of "alignTicks" and "precision"

Series data disappear in some cases

(previously => now)
image

image

Rounding error occur on min/max/ticks

(previously => now)
image

image

Better auto precision

(previously => now)
image
image

Incorrect ticks for small series data

(previously => now)
image
image

Lay out series data to the center of Y

(previously => now)
image

Bad cases when alignTo axis min or max is set

(previously => now)
image

Reasonable effect when dataZoom controls all yAxis

(previously => now)
image

image image

Radar bad case

(previously => now)
image

Fix incorrect align ticks in some cases

test/axis-align-ticks-random.html

Fix dataZoom

  • Respect to axis ends and better auto-precision
  • Fix dataZoom hovering bug - previously it did not always show labels when hovering.

(previously => now)
Image

Fix toolbox theme and update

Previously, toolbox settings in theme can cause it always show, since toolbox will display if {} exists, e.g., toolbox: {feature: {some: {}}. Now enable {show: boolean} without breaking changes. And enable toolbox features change by setOption.

Fix progressive rendering

See test cases:
test/stream-basic1.html
test/stream-basic2.html
test/stream-basic3.html
test/stream-basic4.html

This fix is mainly implemented in ecomfe/zrender#1151

Fix overflow on axis and Cartesian and enable bandWidth

Previously,

  1. On "category" axis with boundaryGap: false, series like bar/candlestick/boxplot overflow Cartesian area , thereby no proper clipping, and may cover axis labels, causing visual artifacts.
  2. On "time" axis, bar overflow has been fixed but need to refactor to "register" style for code size; other similar series is not covered.
  3. On "value"/"log"/"time" axis, overflow is not fixed.
  4. Candlestick edge items (min or max items) may not be displayed.

Now, this issue is systematically resolved.

  • A new ec option xxxAxis.containShape: boolean is introduced, true by default.
  • Axis is auto expanded to contain series shape, typically by "half" bandWidth at the start and end.
  • bandWidth calculation is fixed for axisPointer: shadow in this cases.

(previously => now)
Image

Image Image Image

category Axis with boundaryGap: false:

(previously => now)
Image

dataZoom clip:

(previously => now)
Image

bandWidth incorrect:

(previously => now)
Image

Auto onZero change

(previously => now)
Image

Introduced onZero: 'auto' (by default).

Enable LogScale (axis.type: 'log') to automatically filter out non-positive values

(previously => now)
Image

Related issues: #13154 #17322

Enhance pie laying out on Cartesian

Previously, if pie was laid out on a Cartesian, its axis extent did not union pie position. Users needed to manually add some hidden series to expand the axis extent. Now auto-union pie center to axis extent is supported.

(previously => now)
Image

See also test case test/pie-coordinate-system.html

Fix hoverLayer rendering artifact bug

Fix https://github.com/apache/echarts/issue/21233
This is mainly fixed in ecomfe/zrender#1151

Fix geo roaming visual artifact

(previously => now)
Image

Image

This is caused by failing to synchronize roaming variables (center, zoom and corresponding affine matrix) while animation is applied on coord sys view (such as map).

Support scatter/effectScatter clipping on geo coord sys

(previously => now)
Image

Refactor

Corresponding refactors are performed to the changes above, mainly including:

  • Axis scale hierarchy implementation is changed to a pattern like decorator, which covers the abstraction of numeric transform composition (axis break, logarithm, ordinal sort, ...), and enables more transform to be implemented in future (like asinh)
  • Introduce axis scale extent kind SCALE_EXTENT_KIND_EFFECTIVE and SCALE_EXTENT_KIND_MAPPING for containShape.
  • Introduce axis statistics stage to collect <axis, series> for axis extent union and series like bar/boxplot/..., and bandWidth calculation on numeric Scale and reuse.
  • Introduce axis bandWidth calculation and reuse for both category axis and numeric axes.
  • Clarify axis extent calculation process (including union from series data and adopt ec options). For historical reason, it is hard to maintain and error-prone.
  • Clarify axis nice ticks implementation. For historical reason, it is hard to maintain and error-prone.

Some related test cases

  • test/toolbox-custom.html
  • test/candlestick-large3.html
  • test/bar-stack.html
  • test/bar-datazoom-filtermode-none-time-axis.html
  • test/bar-race2.html
  • test/boxplot-multi.html
  • test/bar-polar-multi-series-radial.html
  • test/bar-overflow-time-plot.html
  • test/bar-overflow-plot2.html
  • test/dataZoom-action.html
  • test/candlestick-case.html
  • test/bar-polar-multi-series.html
  • test/dataZoomHighPrecision.html
  • test/hover-style.html
  • test/stream-basic1.html
  • test/stream-basic2.html
  • test/stream-basic3.html
  • test/stream-basic4.html
  • test/stream-basic5.html
  • test/hover-layer.html
  • test/axis-interval2.html
  • test/axis-extreme2.html
  • test/clip.html

Some related issues

100pah added 11 commits January 19, 2026 02:30
…cNiceTicks` and `calcNiceExtent` from Scale class override member functions to plain functions, similar to `axisAlignTicks`. Previously it's hard to modify and error-prone. (2) Remove unnecessary override on Scale class hierarchy and limit override usage, which is difficult to understand and error-prone. (3) Simplify the inheritance - shift `LogScale` and `TimeScale` inheritance from `IntervalScale` to `Scale`. (4) Clarify the impl of `IntervalScale` - uniform the parameters setting entry for both "nice ticks" and "align ticks".
…om Scale; unify union entry and scaleRawExtentInfo creator and cache to avoid error-prone impl; simplify the impl of coord sys call extent uinon. (2) Fix LogScale precision bug introduced by previous commits.
…sitive data on LogScale - exclude non-positive series data items when calculate dataExtent on LogScale. (2) Include `Infinite` into `connectNulls` handling on line series; the `Infinite` value may be generated by `log(0)` and previously the corresponding effect in unpredictable on line series (sometimes display as connected but sometimes not).
…xes extent can not union pie center automatically. Commit 18a23a8 has supported it. This commit updates test cases.
… 'dragging'). (2) Fix dataZoom bug that data info disappear when drag release on the area that data info display should be triggered.
(1) Uniform series data union logic; previous they are implemented in several inconsistent ways and error-prone. And also strict the extent calculation with uniformed utilities.
(2) Refactor Scale - uniform the implementation of the numeric transformations (such as axis breaks, logarithm, ordinal related handling) with a decorator pattern and decouple them from Scale class hierarchy. This brings consistent handling for details and enables further extension.
(3) Refactor Scale - decouple "axis nice" logic from Scale and make the "axis nice" and "axis align" implemented in the same code style. This removes override (hard to read and maintain), and uniforms the parameters of IntervalScale (previous its parameters can be generated by itself or outside, which is confusing), and reduce scale-type-specified handling (e.g., if (isLogScale) ...) in calculation.
(4) Enable "value" axis and "log" axis to render "bar" and "pictorialBar" series without overflowing the axis. Previously only "time" axis enables that on only "bar" series. Introduce "SCALE_EXTENT_KIND_MAPPING" to cover this generalized behavior and use strict "clip" for bar series without extra margin (a previous compromise). And clarify `barGrid` code accordingly, which removes duplicated time-consuming calculation in "bandWidth" calculation. Close #19972. Close #17858. Close #12720. Close #13321. Close #20718. Close #20421. Close #20503.
# Conflicts:
#	src/chart/bar/BarView.ts
#	src/chart/treemap/treemapLayout.ts
…nable and error-prone for small float number.
…on changed. (2) Fix onZero on double value axis and dataZoom is applied on a base axis - onZero should be disabled by default.
100pah added 26 commits March 31, 2026 14:53
…p: false - use the newly added containShape handler. (2) Fix regression: Drop the previous containShape strategy on bar series, use a simple strategy for better compatibility. (3) Fix regression: Fix new added bar clip feature on single data item case. (4) Fix regression: Clarify code.
…ible. (2) Default IntervalScale extent on single data item case show not be broken. (3) LogScale filter non-positive value.
…. (2) Fix regression - containShape should be word properly in single value case. And simply the code.
…d compatibility. (2) Add guard to progressive block.
… handler to remove unnecessary throw and catch - better for debug; (2) sunburst did not use dataFilter in correct way and it did not work, therefore remove it.
…`npm prepare` is executed when npm install locally or from git, and build/build.js imports a newer version of rollup-terser, which requires newer versions of Node.js (>19). That constraints should not be imposed to users, otherwise some existing pipeline may be broken.
…oord sys and its content (e.g., scatter) should visually align during roaming animation and manual roam. (2) Refactor to uniform roaming impl (via RoamController and ViewCoordSys) and clarify `updateTransform` and related code. (3) Enable scatter and effectScatter clip in geo. (4) Fix aria: palette is modified to ec instance local rather than global, which is more reasonable. (5) Fix map series roaming bug: roam and then click legend hide the first series and then roam and then click legend to restore the first series, the map should not jump.
@100pah 100pah merged commit 3c62f0d into release May 4, 2026
2 checks passed
@echarts-bot
Copy link
Copy Markdown

echarts-bot Bot commented May 4, 2026

Congratulations! Your PR has been merged. Thanks for your contribution! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment