-
-
Couldn't load subscription status.
- Fork 1.7k
[charts] Fix zoom discard inconsistency #19535
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[charts] Fix zoom discard inconsistency #19535
Conversation
|
Deploy preview: https://deploy-preview-19535--material-ui-x.netlify.app/ Bundle size report
|
| context: AxisValueFormatterContext<TScaleName>, | ||
| ) => string), | ||
| }; | ||
| } as ComputedAxis<ContinuousScaleName, any, ChartsAxisProps>; |
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.
Couldn't make this work without casting, unfortunately. satisfies didn't work either.
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.
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 Performance ReportMerging #19535 will not alter performanceComparing Summary
Footnotes |
12273a3 to
22732d7
Compare
...ages/x-charts/src/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.ts
Show resolved
Hide resolved
...ages/x-charts/src/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.ts
Outdated
Show resolved
Hide resolved
| context: AxisValueFormatterContext<TScaleName>, | ||
| ) => string), | ||
| }; | ||
| } as ComputedAxis<ContinuousScaleName, any, ChartsAxisProps>; |
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.
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]); |
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 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 5domainLimit='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
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.
Should be fixed with the most recent commit 👍
ac05e1e to
297a054
Compare
|
|
||
| describe('createContinuousScaleGetAxisFilter', () => { | ||
| describe('linear scale', () => { | ||
| const scale = getScale('linear', [0, 100], [0, 100]).nice(); |
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.
All tests for createContinuousScaleGetAxisFilter use nice now.
We should also test the strict behaviour.
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.
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.
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.
Ah true, I was still thinking of the previous behaviour 🤔
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.
You have an issue with preview
Capture.video.du.2025-09-15.18-20-50.mp4
Fixed and added a visual regression test 👍 |
|
@bernardobelchior I fixed scritp issues, and added
|
Fixes #17561.
Alternative to #19332.