chartjs / chartjs/chartjs-plugin-zoom
Add mouseButton for zoom reset to Zoom Options
- Dominant language
- JavaScript
- Stars
- 623
- Forks
- 331
- Avg merge
- 7h 5m
- Merged PRs (30d)
- 7
Description
It would be very handy to have some settings for zoom reset in [Zoom Options](https://www.chartjs.org/chartjs-plugin-zoom/guide/options.html#zoom-options).
From my point of view it could be at least `mouseButton` (maybe also `modifierKey` but I'm not sure about it).
Generating special button for zoom reset that simply uses `chart.resetZoom();` [API call](https://www.chartjs.org/chartjs-plugin-zoom/guide/developers.html) is not always possible (it can break the design of HTLM page for example). Some time ago I even had to modify **chartjs-plugin-zoom.js** file [to add this functionality ](https://github.com/chartjs/chartjs-plugin-zoom/issues/325#issuecomment-678038851) - but that is not the best practice I think:
```
chartInstance.$zoom._mouseDownHandler = function (event) {
node.addEventListener('mousemove', chartInstance.$zoom._mouseMoveHandler);
chartInstance.$zoom._dragZoomStart = event;
// CHANGED: middle mouse button is clicked - for resetting zoom
if (event.button === 1) {
chartInstance.resetZoom();
}
};
```
Maybe now it's time to add some options?
Thank you in advance.
Relates to #325
Contributor guide
Assessment
This issue has not been assessed yet.