-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] PieChart crashes on hover when changing data #12540
Comments
One easy fix could be this: diff --git a/packages/x-charts/src/ChartsTooltip/DefaultChartsItemTooltipContent.tsx b/packages/x-charts/src/ChartsTooltip/DefaultChartsItemTooltipContent.tsx
index a2587dc0b..4cb677472 100644
--- a/packages/x-charts/src/ChartsTooltip/DefaultChartsItemTooltipContent.tsx
+++ b/packages/x-charts/src/ChartsTooltip/DefaultChartsItemTooltipContent.tsx
@@ -17,7 +17,7 @@ function DefaultChartsItemTooltipContent<T extends ChartSeriesType = ChartSeries
) {
const { series, itemData, sx, classes } = props;
- if (itemData.dataIndex === undefined) {
+ if (itemData.dataIndex === undefined || !series.data[itemData.dataIndex]) {
return null;
}
const { displayedLabel, color } = Would that be ok @alexfauquette ? |
Yes, that proposal make sens 👍 |
I got to the same solution on my playground just a little while ago. Patching this into the actual codebase and seeing how it goes, thanks for the help! Update: Looks like does fix it. Do you guys want me to make a PR? |
mui#12540 Signed-off-by: Rishi556 <github@rishipanthee.com>
Yes, PR are welcome |
How did we do @Rishi556? |
Steps to reproduce
Link to live example: https://stackblitz.com/edit/mui-mui-x-jep8g4?file=src%2Fdemo.tsx
Steps:
screen-capture.7.1.1.mp4
Current behavior
Piechart crashes.
Expected behavior
Chart should not crash, instead either show the tooltip for the section, or not show the tooltip and not crash.
Context
The pie chart displays data for different products, and only shows data for the product one at a time, depending on the selected product. This issue is reproducible on 4 browsers that have been tried(edge, chrome, firefox and safari).
Chrome dev tools complains about not being able to read color:
I initially thought it was due to something with the animation, but was told my coworker, that even with
skipAnimation
the issue persists(but I haven't been able to recreate that myself).Your environment
npx @mui/envinfo
Search keywords: pie charts hover
The text was updated successfully, but these errors were encountered: