Repository navigation
Conversation
… bounds. close apache#21839 The label proportion in layOutGridByOuterBounds is measured in pixel space from the min edge of the grid, but scale.normalize returns a data-space proportion that ignores inverse. Flip the proportion for inverse axes so a tick near one edge is not treated as near the other edge, which divided a small overhang by a near-zero proportion and collapsed the grid. Signed-off-by: xh123637 <3324733895@qq.com>
|
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?
Flip the label proportion for inverse axes in
layOutGridByOuterBounds, so the grid is no longer collapsed when an inverse axis has a tick near the axis edge.Fixed issues
Details
Before: What was the problem?
layOutGridByOuterBoundsinsrc/coord/cartesian/Grid.tscomputed each label'sproportionwithaxis.scale.normalize(...), which is a data-space proportion that ignoresaxis.inverse, while the proportion is used in pixel space measured from the min edge of the grid. On an inverted axis, a tick sitting ~0.1% from one edge was treated as ~0.1% from the other edge, soapplyProportiondivided a few px of overhang by ~0.001 and the grid shrank to its minimum (64px tall in a 600x400 container in the issue's reproduction, versus 229px withoutinverse).After: How does it behave after the fixing?
The proportion is flipped (
1 - proportion) whenaxis.inverseis set, before the existing y-axis flip, so the proportion matches the label's pixel position on both inverse x and inverse y axes. The grid now lays out (nearly) the same height with and withoutinverse.A new unit test
test/ut/spec/component/grid.test.tsreproduces the issue's option: before the fix the inverse grid height was 63.75px versus 245.5px withoutinverse; after the fix the test passes.test/ut/spec/api/converter.test.tsandtest/ut/spec/api/containPixel.test.tsalso pass (9 tests total across the three files). ESLint is clean on both changed files.Document Info
One of the following should be checked.
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
New unit test:
test/ut/spec/component/grid.test.ts(outerBoundsContain should not collapse the grid on an inverse axis).Merging options
Other information