Skip to content

Conversation

@bernardobelchior
Copy link
Member

Fixes #17561.

Alternative to #19332.

@mui-bot
Copy link

mui-bot commented Sep 11, 2025

Deploy preview: https://deploy-preview-19535--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%) ▼-1B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 🔺+1B(0.00%)
@mui/x-charts 🔺+1.31KB(+0.42%) 🔺+340B(+0.35%)
@mui/x-charts-pro 🔺+2.01KB(+0.50%) 🔺+446B(+0.35%)
@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%) 🔺+1B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 9e06422

@bernardobelchior bernardobelchior added type: bug It doesn't behave as expected. scope: charts Changes related to the charts. labels Sep 11, 2025
context: AxisValueFormatterContext<TScaleName>,
) => string),
};
} as ComputedAxis<ContinuousScaleName, any, ChartsAxisProps>;
Copy link
Member Author

Choose a reason for hiding this comment

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

Couldn't make this work without casting, unfortunately. satisfies didn't work either.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I assume it's because the scale type comes from a distinct object. So it TS cannot do the relation between the scaleType and the scale.

I don't think their is an easy workaround except the one you did previously by having some line of codes enforcing the scale and scaleType to be coherent like isBandScale(scale) && isBandScaleConfig(axis)

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 11, 2025

CodSpeed Performance Report

Merging #19535 will not alter performance

Comparing bernardobelchior:fix-zoom-discard-inconsistency (9e06422) with master (92e4dc2)1

Summary

✅ 10 untouched

Footnotes

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

@bernardobelchior bernardobelchior force-pushed the fix-zoom-discard-inconsistency branch from 12273a3 to 22732d7 Compare September 11, 2025 16:56
@bernardobelchior bernardobelchior marked this pull request as ready for review September 11, 2025 17:26
context: AxisValueFormatterContext<TScaleName>,
) => string),
};
} as ComputedAxis<ContinuousScaleName, any, ChartsAxisProps>;
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I assume it's because the scale type comes from a distinct object. So it TS cannot do the relation between the scaleType and the scale.

I don't think their is an easy workaround except the one you did previously by having some line of codes enforcing the scale and scaleType to be coherent like isBandScale(scale) && isBandScaleConfig(axis)

filter,
);
scale = scale.copy();
scale.domain([minData, maxData]);
Copy link
Member

Choose a reason for hiding this comment

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

This should be slightly more complex. The filters is here to remove some data points.

But it should still apply domainLimit strategies: nice(tickNumber) or the domainLimit(min, max) if defined.

We could add a test with a BarChart with series data set to [1, 4.5, 5] and x-axis zoom set to [0, 50] (ditch the last item)

  • domainLimit='nice': y-axis should go from 0 to 5
  • domainLimit='strict': y-axis should go from 0 to 4.5

Dark mode is the actual docs demo, light mode is this PR preview

Capture.video.du.2025-09-15.10-11-46.mp4

This will have a side effect impact: The domainLimit as a function could be called twice:

  • one when creating scales
  • one when applying the filter

Not a big deal for me

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be fixed with the most recent commit 👍


describe('createContinuousScaleGetAxisFilter', () => {
describe('linear scale', () => {
const scale = getScale('linear', [0, 100], [0, 100]).nice();
Copy link
Member

@JCQuintas JCQuintas Sep 15, 2025

Choose a reason for hiding this comment

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

All tests for createContinuousScaleGetAxisFilter use nice now.

We should also test the strict behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should also test the strict behaviour.

What issues do you think testing the strict behavior will catch? As far as I can see, createContinuousScaleGetAxisFilter isn't affected by whether the domain is nice or not.

Copy link
Member

Choose a reason for hiding this comment

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

Ah true, I was still thinking of the previous behaviour 🤔

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.

You have an issue with preview

Capture.video.du.2025-09-15.18-20-50.mp4

@bernardobelchior
Copy link
Member Author

You have an issue with preview

Capture.video.du.2025-09-15.18-20-50.mp4

Fixed and added a visual regression test 👍

@alexfauquette
Copy link
Member

@bernardobelchior I fixed scritp issues, and added filterMode: 'discard', to your visual regression test such that it now test the two regression I spotted during the review

  • preview scalling like main chart
  • discard no applying the nice() method to scale

@bernardobelchior bernardobelchior merged commit ea4d39f into mui:master Sep 17, 2025
22 checks passed
@bernardobelchior bernardobelchior deleted the fix-zoom-discard-inconsistency branch September 17, 2025 08:43
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] createAxisFilterMapper does not respect domain limit

4 participants