Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.8k
Feature/add zoom and pan support improved brush (vertical) and minimap#5934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ian' ofhttps://github.com/Fefedu973/recharts into codex/ajouter-support-zoom-et-pan-sur-graphiques-cartesian
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Wow@Fefedu973 this is a lot. Really appreciate you taking this on!
I think this is too much to change and review at once. Would you be able to split this into smaller PRs?
We'll also need to add tests with each change, we can't just add all of this untested.
The video looks really good although I'll definitely pull it down and play with it.
Fefedu973 commentedJun 9, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@ckifer I won't be able to change a lot of things before ~2 weeks because I have my finals but i can try after that. However all the changes are deeply interconnected to one another so it will be tricky |
Ok no worries, I will review the PR as is when I get a chance so that you can incorporate feedback but won't be comfortable merging since its so large |
Will also need to fix the merge conflicts |
@ckifer I will maybe have some time to clean a little bit the PR and fix the merge conflicts they are not that big. |
storybook should always auto-reload on save. Not sure what it could be if it isn't working for you |
@ckifer my setup is a bit weird I use wsl and not everything was setup property but yea I had to restart the storybook like 1000 times and waited 2 min everytime |
Weird, it hit reloads like any other app for me on Mac/Linux. Sorry about that, not sure there's anything we can do about it though unless you want to cut a bug to storybook |
if(React.isValidElement(child)){ | ||
// The child is cast to any to allow passing width and height props. | ||
// This is a specific solution for the compact chart scenario. | ||
returnReact.cloneElement(childasany,{ width, height}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No cloning please. Think of another solution that doesn't involve cloning.
Fefedu973Jun 10, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is the only option I found to prevent the too many re-enter issue. Do you know any other way ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What other options have you considered? I am positive that there is something else. We have hooks to read the chart dimensions, have you tried that? React context exists. Redux store and selectors are available.
Why does this need to inject width, height everywhere? What happens if some of the children are nested inside another children? What happens when there are some other components that receive width, height from elsewhere? This would overwrite that.
padding, | ||
brushDimensions:BrushDimensions, | ||
{padding:brushPadding}, | ||
allBrushSettings:Record<string,any>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Noany
please
Concerning the issue with hot relaoding this is due to WSL 2 that does not allow the apps to monitor files changes on windows mounted drives.
This could be nice to add into the DEVELOPING.md |
Someone had to be the one to figure that out first, thanks for that but sorry for the pain. We can document it for others sure |
no problem ! |
paologaleotti2 commentedSep 16, 2025
Any updates? |
We need to do this in smaller chunks than this PR does and it would need to incorporate any feedback |
I'm extremely busy rn, |
Yep, totally get being busy and no worries at all. Appreciate the effort here! |
feat: Implement Advanced Zoom, Pan, and Interaction Controls
Description
This pull request introduces a comprehensive and highly-configurablezoom and pan system for all Cartesian charts. It also includes major enhancements to the
Brush
component, a newMinimap
component, and improved mobile/touch interactions.Core changes
ZoomPanContainer
– A new context provider that wraps chart children and manages all zoom/pan state and logic. It handles mouse-wheel, drag, and keyboard events for seamless navigation.Minimap
component – Gives a high-level overview of the entire chart, showing the current viewport and allowing quick navigation by clicking or dragging.Brush
overhauluseZoomPan
mode lets the brush control the chart’s zoom state instead of merely slicing data.layout="vertical"
for Y-axis brushing.BrushPreview
container to prevent rendering conflicts.zoomSlice
to the Redux store to track global zoom state (scaleX
,scaleY
,offsetX
,offsetY
).CartesianAxis
now supports direct drag/scroll on axis labels to pan and zoom.Area
,Bar
,Line
,Scatter
) during zoom/pan for smooth performance (initial render excluded).Related Issue
Resolves **#710
**
Motivation and Context
Large or dense datasets were previously hard to explore interactively. These changes provide users with built-in, powerful tools for zooming, panning, and brushing, turning static charts into dynamic, responsive interfaces suitable for advanced data-exploration use cases.
How Has This Been Tested?
ZoomPanContainer
logic (test/context/zoomPanContext.spec.tsx
) to verify zoom, pan, and reset behaviors.Examples/ZoomPan.stories.tsx
: basic zoom, axis-constrained zoom, drag-to-zoom, horizontal & vertical brush integration, dual-brush controls, “follow line” feature, andMinimap
.Examples/ZoomPan/EnhancedZoomPan.stories.tsx
: custom scrollbars, mobile-optimized gestures, keyboard controls, axis-label interactions.Line
,Bar
,Area
,Scatter
) on multiple input devices (mouse, trackpad, touch screen).Screenshots
Enregistrement.2025-06-09.232749.1.mp4
Types of changes
Brush
component’s props and behavior have been significantly updated, which may affect existing implementations.Checklist