Skip to content

Conversation

JCQuintas
Copy link
Member

@JCQuintas JCQuintas commented Jul 1, 2025

Allow configuring with simple strings for accepting defaults or with full configuration.
Goal is to allow a more fine-grained customisation of the gestures, while also making the PR that adds more supported gestures smaller :)

Changelog

  • Charts now allow fine-grained control for zoom interactions
    // default values
    <BarChartPro
      zoomInteractionConfig={{
        // Enable both wheel and pinch zoom
        zoom: ['wheel', 'onPinch'],
        // Enable drag panning
        pan: ['drag'],
      }}
    />
    
    // custom (no pinch)
    <BarChartPro
      zoomInteractionConfig={{
        // Only zoom when Control key is pressed
        zoom: [{ type: 'wheel', keys: ['Control'] }],
        // Only pan when Shift key is pressed
        pan: [{ type: 'drag', keys: ['Shift'] }],
      }}
    />

@JCQuintas JCQuintas self-assigned this Jul 1, 2025
@JCQuintas JCQuintas added type: new feature Expand the scope of the product to solve a new problem. plan: Pro Impact at least one Pro user. scope: charts Changes related to the charts. labels Jul 1, 2025
@mui-bot
Copy link

mui-bot commented Jul 1, 2025

Deploy preview: https://deploy-preview-18646--material-ui-x.netlify.app/

Updated pages:

Bundle size report

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 🔺+356B(+0.11%) 🔺+124B(+0.12%)
@mui/x-charts-pro 🔺+2.19KB(+0.52%) 🔺+657B(+0.50%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 1f330b1

Copy link

codspeed-hq bot commented Jul 1, 2025

CodSpeed Performance Report

Merging #18646 will not alter performance

Comparing JCQuintas:zoom-configuration-simplified (1f330b1) with master (ba2428d)

Summary

✅ 12 untouched

@JCQuintas JCQuintas marked this pull request as ready for review July 1, 2025 22:13
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jul 2, 2025
Copy link

github-actions bot commented Jul 2, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API and the code structure look good. Just had one question

Copy link

github-actions bot commented Aug 2, 2025

This pull request has been inactive for 30 days. Please remove the stale label or leave a comment to keep it open. Otherwise, it will be closed in 15 days.

@github-actions github-actions bot added the stale Inactive for 7 days (issues) or 30 days (PRs); closed after 5 or 15 more days if no update. label Aug 2, 2025
@github-actions github-actions bot removed PR: out-of-date The pull request has merge conflicts and can't be merged. stale Inactive for 7 days (issues) or 30 days (PRs); closed after 5 or 15 more days if no update. labels Aug 11, 2025
@JCQuintas JCQuintas marked this pull request as draft August 12, 2025 22:04
export type AddInteractionListener = {
<CustomData extends Record<string, unknown> = Record<string, unknown>>(
interaction: 'pan' | 'panStart' | 'panEnd',
interaction: 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get what are doing those new interactions. What's the difference between a pan and a zoomPan?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've divided them because the gesture settings are now configurable on the gesture level, this is so the zoom configuration doesn't affect tooltip behaviour.

@alexfauquette
Copy link
Member

Nice fix 👍

Copy link
Member

@bernardobelchior bernardobelchior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor curiosity, otherwise looks good 👍

const onZoomChange = useEventCallback(onZoomChangeProp ?? (() => {}));
const optionsLookup = useSelector(store, selectorChartZoomOptionsLookup);

useEffectAfterFirstRender(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want this use effect to only run after the first render? What happens if it runs in the first render as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook synchronise the props in the store.

Every time a user update a props saved in the store, we need to update it.

But we don't need that at the first run because the store is already in sync thanks to the plugin's getInitialState()
So we skip the first run of the useEffect

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying!
It would probably be useful to have this explanation in the code 😄

Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@JCQuintas JCQuintas merged commit 5154e31 into mui:master Sep 25, 2025
22 checks passed
@JCQuintas JCQuintas deleted the zoom-configuration-simplified branch September 25, 2025 16:51
@arminmeh arminmeh mentioned this pull request Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan: Pro Impact at least one Pro user. scope: charts Changes related to the charts. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants