Repository navigation
fix(grid): respect axisLabel align in containLabel reserved space. close #21140 - #21822
Open
Raman-Katiyar wants to merge 1 commit into
Open
Raman-Katiyar wants to merge 1 commit into
Raman-Katiyar wants to merge 1 commit into
Conversation
|
Thanks for your contribution! 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 branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief Information
This pull request is in the type of:
What does this PR do?
Fixes
grid.containLabelreserving the full axis label width/height even whenaxisLabel.align/axisLabel.verticalAlignmakes the labels extend inwards from their anchor point, which left unwanted dead space next to the axis.Fixed issues
Details
Before
The legacy containLabel layout (
legacyLayOutGridByContainedinsrc/coord/cartesian/legacyContainLabel.ts) always reserves the full label size plus margin, regardless of label alignment. WithyAxis.axisLabel: {align: 'left', margin: 100}andgrid.containLabel: true, the grid starts 120.16px from the chart edge instead of 100px — 20.16px of dead space, exactly the widest label's width (foralign: 'center'the dead space is half the label width).After
The reserved size now accounts for alignment via a new
estimateOuterLabelSizehelper: only the part of the label that extends outwards from its anchor point is reserved (full size for the default/outward alignment, half for center/middle, zero for inward alignment). With the fix, the grid starts exactly at 100px in the issue's configuration and the labels begin at the chart edge. Nothing changes for the default/outward alignment, and the full size is still reserved whenaxisLabel.rotateis set. The newer outer-bounds layout path already accounts for real label geometry and is unaffected.Validation results:
test/ut/spec/component/axis/containLabel.test.ts: 5 cases fail without the fix, all 11 pass with it.npm run checktype, ESLint on the changed files, andnpm run buildall pass. Regenerateddist/output is not included in this PR.Document Info
One of the following should be checked.
Misc
Security
ZRender Changes
Related test cases or examples to use the new APIs
New regression test:
test/ut/spec/component/axis/containLabel.test.ts, covering the #21140 reproduction plus guard cases for the default, center, and inward alignments.Others
This PR is a single commit.
Could a maintainer please approve the CI workflow run for this PR? Thank you!