-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 Barchart with empty dataset throwing an error #12708
[charts] Fix Barchart with empty dataset throwing an error #12708
Conversation
Deploy preview: https://deploy-preview-12708--material-ui-x.netlify.app/ |
I agree it fixes the issue, but I'm wondering why do we have this issue with bar chart and not with line chart? They are super close, so they should have the same behavior with empty dataset. For the fallback on |
@alexfauquette In the Line chart it is divided into two functions and we check for if (stackedData.length === 0) {
return [null, null];
} also the first |
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.
Ok, if you want to add test, their is a similar one in the LineChart
folder. The only test existing for now
Added tests, odd behaviour is that vertical layout returns |
Not that surprising. It comes from
What is more surprising is that those extremes are computed. For In cartesian context, those scales got an early return before the min/max values are used. So they could return wherever they want. Maybe the correct behavior would be that in |
}; | ||
}; | ||
|
||
describe('BarChart - extremums', () => { |
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.
Time will tell if this test isn't too low level. Testing public APIs tends to scale better.
We just use optional chain and nullchecks as fallbacks.
@alexfauquette Should we add tests for these functions?
Fixes #12462