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

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Make `dataZoom inside` wheel zoom-out work after the toolbox has collapsed 
the range to a single category, so users can zoom back out and see all 
categories again.
   
   ### Fixed issues
   
   - close #21541
   
   ## Details
   
   ### Before: What was the problem?
   
   When the toolbox dataZoom feature brushes a single category on a category 
axis, it dispatches `startValue === endValue` and `AxisProxy` collapses the 
percent window to a zero-width range (for example `[33.33, 33.33]` for category 
index `1` of `4`).
   
   `InsideZoomView.zoom` expands the window multiplicatively around the wheel 
anchor:
   
   ```ts
   range[i] = (range[i] - percentPoint) * scale + percentPoint
   ```
   
   For a collapsed range every term is zero, so wheel-out leaves the range 
unchanged and the user is stuck looking at the single category they brushed. 
The bug was confirmed by @helgasoft and tracked in #20392.
   
   Reproducer (from the issue):
   
   1. Toolbox dataZoom → brush exactly one category.
   2. Scroll the mouse wheel up to zoom out.
   3. The window stays collapsed; wheel does nothing.
   
   ### After: How does it behave after the fixing?
   
   Detect the collapsed-range case in the zoom handler. When the user is 
wheel-zooming out (`scale > 1`), seed the range with a small percent (currently 
5%) centered on the wheel anchor before applying the multiplicative expansion:
   
   ```ts
   const SEED_HALF_PERCENT = 2.5;
   if (range[1] - range[0] < 1e-6 && scale > 1) {
       range[0] = percentPoint - SEED_HALF_PERCENT;
       range[1] = percentPoint + SEED_HALF_PERCENT;
   }
   
   range[0] = (range[0] - percentPoint) * scale + percentPoint;
   range[1] = (range[1] - percentPoint) * scale + percentPoint;
   ```
   
   After the seed, subsequent wheel ticks scale multiplicatively as before, so 
the user reaches the full range in roughly 30 ticks (default factor 1.1). The 
seed is anchored on the wheel position, then the existing `sliderMove` clamp 
ensures the range stays within `[0, 100]` even when the wheel anchor sits near 
the edge.
   
   Wheel-in on a collapsed range is intentionally left as a no-op — it cannot 
collapse the range further, and the existing math already handles that 
correctly.
   
   ### Tests
   
   `test/ut/spec/component/dataZoom/insideZoomViewWheel.test.ts` adds four unit 
tests calling the exported `getRangeHandlers.zoom` directly with mocked context:
   
   - collapsed-range wheel-out → range expands and stays centered on the wheel 
anchor.
   - collapsed-range wheel-in → handler returns `undefined` (no change).
   - non-degenerate range wheel-out → existing multiplicative behavior 
preserved (≈1.1× factor).
   - collapsed range near `100%` → seed gets clamped to `[0, 100]` without 
crashing.
   
   `test/dataZoom-wheel-zoom-out-collapsed.html` is a visual reproducer 
matching the issue's steps so reviewers can brush a single category in the 
toolbox and verify the wheel now expands the window.
   
   `InsideZoomView.ts` exports `getRangeHandlers` so the unit tests can drive 
the handler in isolation; the type alias `DataZoomGetRangeHandlers` was already 
exported, so this is purely a value export.
   
   Full unit suite: 26 suites, 196 tests, all green.
   
   ## Document Info
   
   - [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.
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   - `test/ut/spec/component/dataZoom/insideZoomViewWheel.test.ts` — unit tests
   - `test/dataZoom-wheel-zoom-out-collapsed.html` — visual reproducer
   
   ### Merging options
   
   - [x] Please squash the commits into a single one when merging.
   
   ### Other information
   
   The seed half-width (2.5% per side, 5% width on first tick) is empirical: 
small enough not to feel jumpy on the first tick, large enough that the user 
feels progress and reaches the full range in a reasonable number of ticks. 
Happy to tune this if reviewers prefer a different value.
   


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