-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Warn if axis data don't have enough elements #16830
Conversation
Deploy preview: https://deploy-preview-16830--material-ui-x.netlify.app/ |
CodSpeed Performance ReportMerging #16830 will not alter performanceComparing Summary
|
@@ -41,6 +43,11 @@ export function checkScaleErrors( | |||
`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should have data property.`, | |||
); | |||
} | |||
if (discreteAxisConfig.data.length < series.stackedData.length) { | |||
throw new Error( | |||
`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should have more data than the bar series of id "${seriesId}".`, |
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.
`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should have more data than the bar series of id "${seriesId}".`, | |
`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should not have less data than the bar series of id "${seriesId}".`, |
have more data than
is not correct, as the correct is >=
, but putting that into words can become confusing. So we could just invert the phrase and say !<
I guess a warning makes sense, but shouldn't we still render the chart? It seems that isn't happening in the docs: Screen.Recording.2025-03-05.at.13.56.59.movAlso, shouldn't the fix be to render only the correct number of bars? The warning is useful, but what happens if a user incorrectly spreads some wrong data? Shouldn't we chart still render properly? |
I agree for still rendering the charts. By replacing the IMO, hiding the extra data points would be hiding the devs error, making bugs harder to spot and fix. |
Great!
Yeah, that's a tough trade-off. I think if we show a warning in dev, then it's fine to hide the error by rendering the chart correctly, but it's a matter of preference so not a blocker |
I realised line chart altready had similar behavior. Si I replace for line chart the |
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.
Seems to be fixed, thank you 😄
Fix #16740
If we agree on the idea, this could be extended to the line charts