jayzhou2309 opened a new pull request, #21782:
URL: https://github.com/apache/echarts/pull/21782
<!-- 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?
Let the toolbox `dataZoom` zoom a grid when its `yAxisIndex` (or
`xAxisIndex`) names only some of the grid's axes, instead of throwing on brush
end.
### Fixed issues
- #19402: dataZoom feature in toolbox doesn't work when set yAxisIndex to
contain only part of y axis
## Details
### Before: What was the problem?
With two y axes and `toolbox.feature.dataZoom.yAxisIndex: [0]`, dragging a
zoom rect did nothing and threw `TypeError: Cannot read properties of undefined
(reading 'findRepresentativeAxisProxy')`.
The brush covers every cartesian in the grid, so `_onBrush` in
`src/component/toolbox/feature/DataZoom.ts` also runs `setBatch('y', ...)` for
the (xAxis 0, yAxis 1) cartesian. yAxis 1 has no toolbox dataZoom, so
`findDataZoom` returns `undefined`. `setBatch` already guarded the snapshot
write with `dataZoomModel && ...`, but it called
`dataZoomModel.findRepresentativeAxisProxy(axisModel)` a few lines before that
guard.
### After: How does it behave after the fixing?
`setBatch` returns early when the axis has no toolbox dataZoom, and the
later `dataZoomModel &&` guard goes away. The declared yAxis and the x axis
zoom, and yAxis 1 keeps its range. Options that declare every axis take the
same path as before.
## 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
`test/ut/spec/component/toolbox/dataZoom.test.ts` sets the option from the
issue's editor link, fires a rect brush on the toolbox brush controller, and
checks the resulting dataZoom windows.
- On `master` (34f4d927e) the test fails with the TypeError from the issue.
With this fix, x zooms to 0 to 6, yAxis 0 to 180 to 240, and yAxis 1 has no
window.
- Full unit suite: 194 of 195 pass. The one failure, `time.test.ts`
`roundTime_locale`, fails the same way on `master` without this change (it
depends on the local timezone).
- The pre-commit hook's `npm run lint` and `npm run checktype` are clean.
Not verified: a manual drag in a browser. The test drives the same `brush`
event the mouse handler fires.
### Merging options
- [x] Please squash the commits into a single one when merging.
### Other information
AI disclosure: an AI agent (Claude Code) reproduced the issue on `master`,
wrote the test and the fix, and ran `npx jest --config
test/ut/jest.config.cjs`, `npm run lint`, and `npm run checktype`.
<!-- oss-agent -->
🤖 Written and posted by an AI agent (Claude Code) on behalf of @jayzhou2309.
--
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]