[Feature] add support for horizontal mouse wheels to scroll and zoom
- Dominant language
- TypeScript
- Stars
- 67.3k
- Forks
- 19.8k
- Avg merge
- 11d 14h
- Merged PRs (30d)
- 8
Description
### What problem does this feature solve?
If you have a mouse that supports both vertical and horizontal scrolling, eCharts currently don't distinguish between both directions.
However, for users that need to navigate through large data, it would be very helpful to be able to use e.g. the two different mouse wheels to scroll both directions.
### What does the proposed API look like?
The `_mousewheelHandler()` currently just looks at `e.wheelDelta`. However, modern browsers do provide
`WheelEvent.wheelDeltaX` and `WheelEvent.wheelDeltaY` in addition, see https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
To be able to use this feature, I suggest to extend the possible values for [zoomOnMouseWheel](https://echarts.apache.org/en/option.html#dataZoom-inside.zoomOnMouseWheel) and [moveOnMouseWheel](https://echarts.apache.org/en/option.html#dataZoom-inside.moveOnMouseWheel) by:
* 'x+shift'|'x+ctrl'|'x+alt' - use the wheelDeltaX instead of wheelDelta if present and fall back to wheelDelta if the given modifier is pressed
* 'y+shift'|'y+ctrl'|'y+alt' - use the wheelDeltaY instead of wheelDelta if present and fall back to wheelDelta if the given modifier is pressed
* 'x+none' and 'y+none' to use the specific wheel delta and fall back to wheelDelta if no modifier is pressed
* Actually 'none' would also be a nice option (in addition to ' true') to be able to tell eCharts only to zoom or scroll when no modifier is pressed. Currently, if I need all 4 options (none, ctrl, shift, alt) to scroll and zoom in x and y direction, and I use "true" instead of "none", then is also scrolls (e.g.) vertically, if "shift" is held.
* Maybe, also add 'x' and 'y' for cases where one doesn't want the fallback option
This way, the chart could be scrolled / zoomed for users with and without horizontal scroll wheel.
And issues such as #15872 might also be solved as @xvaara pointed out in https://github.com/apache/echarts/issues/15872#issuecomment-1445059517.
Contributor guide
Assessment
This issue has not been assessed yet.