Srajan-Sanjay-Saxena opened a new pull request, #21376:
URL: https://github.com/apache/echarts/pull/21376
fix(axis): honor showMinLabel/showMaxLabel for broken axis with time/value
scales
<!-- Please fill in the following information to help us review your PR more
efficiently. -->
## Brief Information
This pull request is in the type of:
- [x] 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.
- [x] 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
- [x] This PR uses security-sensitive Web APIs.
<!-- PLEASE CHECK IT AGAINST:
<https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors>
-->
### ZRender Changes
- [x] 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
- [x] 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
https://github.com/user-attachments/assets/c94e784f-f623-4ffb-b0bf-47a2fc17eee6
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]