Skip to content

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

Open
plainheart wants to merge 33 commits intoreleasefrom
fix/alignTicks-precision
Open

fix(axis): fix axis label may have inappropriate precision or take too much unexpected space when alignTicks is enabled#21430
plainheart wants to merge 33 commits intoreleasefrom
fix/alignTicks-precision

Conversation

@plainheart
Copy link
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

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
Contributor

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

@nuteu
Copy link

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
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
Member

100pah commented Jan 15, 2026

(Work in progress ...)

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

Series data disappear in some cases

image image

Rounding error occur on min/max/ticks

image image

Better auto precision

image image

Incorrect ticks for small series data

image image

Lay out series data to the center of Y

image

Bad cases when alignTo axis min or max is set

image

Reasonable effect when dataZoom controls all yAxis

image image image

Radar bad case

image

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.
(1) feature: Enable uniform bandWidth calculation in numeric axis (e.g., for tooltip shadow); it previously only applicable to category axis, but buggy in numeric axis with bar series. And enable the clip of tooltip shadow.
(2) refactor: Introduce a dedicated workflow phase for series aggregation and data statistics computation on a single axis, allowting the results to be reused across multiple features.
(3) fix: Fix duplicate ticks in TimeScale and customValues, which cause jitter of splitArea.
(4) fix: Fix category showMin/MaxLabel handling when step > 1 and showMin/MaxLabel: false
(5) chore: Tweak bad effects introduced by the previous implementation of SCALE_EXTENT_KIND_MAPPING.
(6) chore: Clean some code.
(1) feature: Add option boxplot.clip
(2) feature: Enable boxplot and candlestick containShape for "value"/"time"/"log" axis, enable proper shadow axisPointer. (candlestick-case.html, boxplot-multi.html)
(3) fix: Fix candlestick ends shapes can not be displayed on "value"/"time" axis. (candlestick-case.html)
(4) fix: candlestick shape width is inappropriate when datazoom filterMode is 'none'/'empty'.  (candlestick-case.html)
(5) fix: In polar coordinate system, support "value"/"time" axis as angle/radius axis, enable propere bandWidth for bar series, enable proper shadow axisPointer. (bar-polar-multi-series-radial.html, bar-polar-multi-series.html)
…EC_CYCLE. (2) Fix dataZoom in `appendData`, introduced by recent commits.
…Data is executed. And clarify the usage of appendData in comments.
…2) Restrict the triggering of hoverLayer to only canvas renderer.
…to update when mousewheel, since dataZoomInside can modify views on mousewheel, and cause highlighted element to be not able to restore. (2) Fix axisPointer highlighted item can not restore due to outdated dataIndexIndex.
@100pah 100pah changed the base branch from master to release March 15, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment