-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[charts] Default bar chart x-axis scale type to band #17519
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
base: master
Are you sure you want to change the base?
[charts] Default bar chart x-axis scale type to band #17519
Conversation
Thanks for adding a type label to the PR! 👍 |
Deploy preview: https://deploy-preview-17519--material-ui-x.netlify.app/ |
CodSpeed Performance ReportMerging #17519 will not alter performanceComparing Summary
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
6392f2a
to
c23dab3
Compare
const defaultXAxis = hasHorizontalSeries ? undefined : defaultBandXAxis; | ||
const processedXAxis = React.useMemo( | ||
() => (xAxis ? xAxis.map((axis) => ({ scaleType: 'band' as const, ...axis })) : defaultXAxis), | ||
[defaultXAxis, xAxis], | ||
); |
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.
If I get it correctly, this causes issues with the following config. Even if the layout is horizontal, the xAxis will get a band scale, which is not the expected behavior
<BarChart
xAxis={[{ min: 0, max: 100 }]}
layout="horizontal"
{...}
/>
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.
Good point. Didn't think of the horizontal case. Will fix
Fixes #13794.
This fix surfaced an issue that applies to all charts when
scaleType
isn't defined andvalueFormatter
is. In that case, a type error will show because the values will implicitly haveany
as a type. To fix that, I added backscaleType: 'band'
in some examples (commit).We either have wrong types or are facing a limit in TypeScript, not sure which. However, this seems to only apply for certain TypeScript configurations (
noImplicitAny: true
), so this isn't a major issue IMO and this PR is an improvement over the current state of things.