xh123637 opened a new pull request, #21842:
URL: https://github.com/apache/echarts/pull/21842

   <!-- 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?
   
   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
   
   <!--
   - #xxxx: ...
   -->
   
   - #21839: Inverse axis collapses the grid with outerBoundsContain when a 
tick is near the axis edge
   
   
   ## Details
   
   ### Before: What was the problem?
   
   `layOutGridByOuterBounds` in `src/coord/cartesian/Grid.ts` computed each 
label's `proportion` with `axis.scale.normalize(...)`, which is a data-space 
proportion that ignores `axis.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, so 
`applyProportion` divided 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 without `inverse`).
   
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ### After: How does it behave after the fixing?
   
   The proportion is flipped (`1 - proportion`) when `axis.inverse` is 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 without `inverse`.
   
   A new unit test `test/ut/spec/component/grid.test.ts` reproduces the issue's 
option: before the fix the inverse grid height was 63.75px versus 245.5px 
without `inverse`; after the fix the test passes. 
`test/ut/spec/api/converter.test.ts` and 
`test/ut/spec/api/containPixel.test.ts` also pass (9 tests total across the 
three files). ESLint is clean on both changed files.
   
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ## 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
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   <!-- PLEASE CHECK IT AGAINST: 
<https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors>
 -->
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### 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
   
   - [x] Please squash the commits into a single one when merging.
   
   ### Other information
   


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

Reply via email to