Skip to content

Conversation

bernardobelchior
Copy link
Member

@bernardobelchior bernardobelchior commented Jul 30, 2025

Fix #18991.

Before:

Screen.Recording.2025-07-30.at.17.20.56.mov

After:

Screen.Recording.2025-07-30.at.17.27.24.mov

@mui-bot
Copy link

mui-bot commented Jul 30, 2025

Deploy preview: https://deploy-preview-18992--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/DataGrid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro/DataGridPro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium/DataGridPremium 0B(0.00%) 0B(0.00%)
@mui/x-charts ▼-14B(0.00%) ▼-11B(-0.01%)
@mui/x-charts-pro ▼-14B(0.00%) ▼-12B(-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 8a48188

if (axis.scaleType === 'point' || axis.scaleType === 'band' || typeof val === 'string') {
return dataIndex >= minVal && dataIndex <= maxVal;
}
if (typeof val === 'string') {
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 wonder if we can remove this from continuous scales 🤔

I kept it because I didn't want to cause a breaking change, but it doesn't make sense for val to be a string here if we're using a continuous scale (which only supports numeric values).

If we can remove this, it should simplify this method since we'll no longer need to depend on axisData.

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 see why we would leave it here. It was probably added as a way to tell typescript to stop complaining about the last return, since checking axis.scaleType doesn't typecheck val

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, makes sense. I separated the refactor into this PR so we can focus on the fix here.

That should allow me to test this use case more thoroughly without worrying whether the culprit is the refactor or the fix

@bernardobelchior bernardobelchior added type: bug It doesn't behave as expected. scope: charts Changes related to the charts. labels Jul 30, 2025
Copy link

codspeed-hq bot commented Jul 30, 2025

CodSpeed Performance Report

Merging #18992 will not alter performance

Comparing bernardobelchior:refactor-axis-filter (8a48188) with master (359c486)1

Summary

✅ 10 untouched benchmarks

Footnotes

  1. No successful run was found on master (b62e79d) during the generation of this report, so 359c486 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Comment on lines 91 to 92
const minVal = (zoomStart * max) / 100;
const maxVal = (zoomEnd * max) / 100;
Copy link
Member

Choose a reason for hiding this comment

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

Since we are considering discret value, what about keeping every thing as before (accept equality) and just rounding the min/max

Suggested change
const minVal = (zoomStart * max) / 100;
const maxVal = (zoomEnd * max) / 100;
const minVal = Math.floor((zoomStart * max) / 100);
const maxVal = Math.ceil((zoomEnd * max) / 100);

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I didn't get what you mean. What are you suggesting?

Copy link
Member

Choose a reason for hiding this comment

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

Your current solution is about doing the math in a continuous space, going from the first tick (the 0) to the last tick (the data.length) and then you do comarison with array indexes thanks to the -1

My proposal was to only consider indexes and manage extremes by rounding up and down
image

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, makes sense 👍

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jul 31, 2025
Copy link

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

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jul 31, 2025
@bernardobelchior bernardobelchior marked this pull request as ready for review July 31, 2025 13:27
@bernardobelchior bernardobelchior merged commit ceaa46b into mui:master Aug 1, 2025
23 checks passed
@bernardobelchior bernardobelchior deleted the refactor-axis-filter branch August 1, 2025 13:42
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.

[charts] Zoom filtering adjusts y axis too soon
4 participants