Skip to content

Conversation

@Srajan-Sanjay-Saxena
Copy link
Contributor

fix(axis): honor showMinLabel/showMaxLabel for broken axis with time/value scales

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Fixes broken axis ignoring showMinLabel/showMaxLabel options on time/value axes, causing extent boundary labels to disappear when breaks are positioned nearby.

Fixed issues

  • Fixes issue where axisLabel.showMinLabel: true was not honored on broken axes
  • Resolves 00:00 label disappearing with time axis when break starts at 02:00

Details

Before: What was the problem?

When using a line chart with a broken axis (time or value scale):

  • Setting axisLabel: { showMinLabel: true } had no effect
  • Extent boundary labels (e.g., 00:00) would disappear when breaks were positioned close to them
  • Example: axis from 00:00 to 23:59:59 with break from 02:00 to 09:00 would not show the 00:00 label
  • Moving the break to 03:00 would make 00:00 appear (inconsistent behavior)
  • Only affected time/value axes; category axes worked correctly

Root Cause:
The makeRealNumberLabels() function in axisTickLabelBuilder.ts lacked the logic to honor showMinLabel/showMaxLabel options, unlike the category axis implementation (makeLabelsByNumericCategoryInterval). When pruneTicksByBreak() executed during scale.getTicks(), it removed ticks within a gap distance (interval * 3/4) of break boundaries to prevent visual overlap with zigzag break indicators. This pruning could inadvertently remove extent boundary ticks when breaks were positioned near the axis start or end.

Example Issue Breakdown:

  • Axis extent: 00:00 to 23:59:59 with 2-hour interval
  • Break: 02:00 to 09:00
  • Pruning gap: 2h * 3/4 = 1.5 hours
  • Buffer zone: (02:00 - 1.5h = 00:30) to (02:00 + 1.5h = 03:30)
  • Result: 00:00 label disappeared because it fell within the pruning gap
  • Workaround: Setting break at 03:00 would show 00:00 (falls outside gap)

After: How does it behave after the fixing?

  • showMinLabel and showMaxLabel options are now properly respected on time and value axes with breaks
  • Extent boundary labels display consistently regardless of break positioning
  • The fix uses pruneByBreak: 'preserve_extent_bound' mode which protects extent boundary ticks from removal
  • Defensively adds min/max labels if they're missing or if first/last tick is a break marker
  • Time axis metadata is preserved for proper label formatting
  • Behavior now matches category axis implementation

Solution Implementation:

  1. Added showMinLabel/showMaxLabel option checking in makeRealNumberLabels()
  2. Pass pruneByBreak: 'preserve_extent_bound' to scale.getTicks() when these options are enabled, instructing the pruning logic to skip extent boundary ticks even if they fall within the gap zone
  3. Defensively add missing min/max labels if the first/last tick is a break marker or not positioned at the extent boundary
  4. Preserve time metadata when adding extent labels for proper formatting on time axes

This aligns real number/time axis behavior with the existing category axis implementation and ensures consistent label display regardless of break positioning.

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

Test case: Line chart with time axis (00:00 to 23:59:59), break from 02:00 to 09:00, axisLabel.showMinLabel: true should display 00:00 label.

Merging options

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

Other information

This fix aligns the real number/time axis implementation with the existing category axis behavior, ensuring feature parity across all axis types. The change is backward compatible and only affects behavior when showMinLabel/showMaxLabel is explicitly set with broken axes.

I am attaching a video of the fix

2025-11-15.01-45-08.mp4

…value scales

Fixed an issue where axisLabel.showMinLabel and axisLabel.showMaxLabel options
were not respected on time and value (interval) axes when using broken axis
(axisPointer.data with breaks). This caused extent boundary labels (e.g., 00:00)
to disappear when breaks were positioned close to them.

Root Cause:
- makeRealNumberLabels() did not check showMinLabel/showMaxLabel options
- pruneTicksByBreak() removed ticks within gap distance (interval * 3/4) of
  break boundaries, which could inadvertently remove extent boundary ticks
- Category axes had this logic but real number/time axes did not

Example Issue:
- Axis extent: 00:00 to 23:59:59 with 2-hour interval
- Break: 02:00 to 09:00
- Result: 00:00 label disappeared because it fell within the 1.5-hour pruning
  gap around the break start (02:00 - 1.5h = 00:30)
- Moving break to 03:00 would show 00:00 because it fell outside the gap

Solution:
1. Check showMinLabel/showMaxLabel options in makeRealNumberLabels()
2. Pass pruneByBreak: 'preserve_extent_bound' to scale.getTicks() when these
   options are enabled, preventing removal of extent boundary ticks
3. Defensively add missing min/max labels if first/last tick is a break marker
   or not at the extent boundary
4. Preserve time metadata for proper formatting on time axes

This aligns real number/time axis behavior with category axis implementation
and ensures consistent label display regardless of break positioning.

Fixes: Issue where axisLabel.showMinLabel: true was not honored on broken axes
Related: Time axis, interval axis, broken axis, axis breaks
@echarts-bot
Copy link

echarts-bot bot commented Nov 14, 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.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

This PR depends on ZRender changes. Please update the ZRender dependency to the latest nightly version including this change, which takes place everyday at 8:00 UTC (16:00 Beijing Time).
You can use npm i zrender@npm:zrender-nightly@dev to update package.json.
If you have any question about this, please leave a comment and we will give you extra help on this.

* specific language governing permissions and limitations
* under the License.
*/
* Licensed to the Apache Software Foundation (ASF) under one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the code style changes and turn off auto formatting tools if you are using any.

"dependencies": {
"tslib": "2.3.0",
"zrender": "6.0.0"
"zrender": "npm:zrender-nightly@^6.0.1-dev.20251114"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR depends on a specific PR of zrender, please write thte issue in the description. Otherwise, don't change the version here.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants