Conversation
|
This PR introduces another user unfriendly behaviour: once user zooms in intro the plot area there is no easy way to zoom out to the original plot size (see my comment: #2181 (comment)) . With zoom unlocked that could be done easily by scrolling out. Take a look how I vibecoded it in a different app: there is clear "Reset zoom" button added and JSROOT menu is completely hidden. You can vibe-dig it out from the source code here: https://github.com/APTG/dedx_web I propose to add such "reset zoom" behaviour here as well in some aestethic way, per-plot. |
grzanka
left a comment
There was a problem hiding this comment.
see comments inline, you introduce a problem here
There was a problem hiding this comment.
🔵 Needs a closer look
The reset behavior relies on undocumented JSROOT painter internals (scale_xmin/scale_ymax, zoom/unzoom) and changes interactive plotting behavior that warrants human/browser verification.
Pull request overview
This PR addresses issue #2181 by preventing accidental zooming of JSROOT plots when users scroll the results panel with the mouse wheel. It disables JSROOT's wheel-zoom globally and, since wheel zoom is a common way users reset the view, adds an explicit "Reset Zoom" control to each plot so the original view can be restored on demand.
Changes:
- Set
settings.ZoomWheel = falseinuseJsRootCanvasto block mouse-wheel zooming. - Capture the initial axis range after
redraw(now consumed as a Promise) and expose a newresetZoomcallback that restores it via the frame painter'szoom/unzoom. - Add a MUI
Chip"Reset Zoom" button above the canvas in the 1D, 2D, and Multi-1D graph components.
File summaries
| File | Description |
|---|---|
| src/JsRoot/hook/useJsRootCanvas.tsx | Disables wheel zoom, captures initial axis range from the painter, and exposes a resetZoom callback. |
| src/JsRoot/components/JsRootGraph1D.tsx | Wraps the canvas and adds a "Reset Zoom" chip wired to resetZoom. |
| src/JsRoot/components/JsRootGraph2D.tsx | Same "Reset Zoom" chip addition for the 2D graph. |
| src/JsRoot/components/JsRootMultiGraph1D.tsx | Same "Reset Zoom" chip addition for the multi-graph 1D view. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| <div> | ||
| <Box sx={{ display: 'flex', justifyContent: 'flex-start', mb: 1 }}> | ||
| <Chip | ||
| color='primary' | ||
| sx={{ fontSize: 12, margin: 0.5 }} | ||
| label='Reset Zoom' | ||
| onClick={resetZoom} | ||
| /> | ||
| </Box> |
|
|
||
| const fp = painter?.getFramePainter?.(); | ||
|
|
||
| if (fp && !initialRangeRef.current) { |

No description provided.