Skip to content

Conversation

@bernardobelchior
Copy link
Member

This happened because we were calculating the ticks based on the preview drawing area, which isn't the same as the chart drawing area. This caused different results when calling scale.nice(tickNumber) since tickNumber was different.

In this example, the domain of the preview is [0, 1] while the domain of the chart is [0, 0.8]. This happens because the preview is calling nice() with two ticks and the chart is calling it with four.

@mui-bot
Copy link

mui-bot commented Sep 26, 2025

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

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 🔺+162B(+0.05%) 🔺+6B(+0.01%)
@mui/x-charts-pro 🔺+217B(+0.05%) 🔺+1B(0.00%)
@mui/x-charts-premium 🔺+213B(+0.05%) 🔺+8B(+0.01%)
@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 a53ceb5

@bernardobelchior bernardobelchior added type: bug It doesn't behave as expected. scope: charts Changes related to the charts. labels Sep 26, 2025
@bernardobelchior bernardobelchior marked this pull request as ready for review September 26, 2025 12:42
@bernardobelchior bernardobelchior merged commit 261cc05 into mui:master Sep 29, 2025
22 of 24 checks passed
@bernardobelchior bernardobelchior deleted the fix-zoom-preview-wrong-domain branch September 29, 2025 09:41
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.

Is it really an issue that the y-axis of the x-axis preview does not match the y-axis of the drawing area?

Outside of this issue, I'm wondering if we should use selector to store an intermediate state of the axes without taking into account the zoom related stuff.

@bernardobelchior
Copy link
Member Author

Is it really an issue that the y-axis of the x-axis preview does not match the y-axis of the drawing area?

When the y-axis is zoomed out, I'd expect them to be proportional. For example, if a bar takes up 80% of the height of the chart, it should take up 80% of the height of the preview. Wouldn't you agree?

Outside of this issue, I'm wondering if we should use selector to store an intermediate state of the axes without taking into account the zoom related stuff.

Yeah, that's my plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: charts Changes related to the charts. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants