-
-
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] Pie chart tooltip runtime warning #11679
Comments
Hi @ledevinchi, Please provide a minimal reproduction test case with the latest version. This would help a lot 👷. A live example would be perfect. This codesandbox.io template may be a good starting point. You can find more codesandbox templates in our docs. Thank you! 🙇🏼 |
For a reason I ignore the Proptypes generated have a series with
|
Hi, forgot to mention i'm using next v13.5.6 (Typescript) |
@ledevinchi Yes, The typing seems ok. We have a script that generate proptypes to avoid maintaining TS and Proptypes. But seems it does not support well nested unions. I reproduced the error in a test. Will see if I succeed to make it pass 😁 A quick solution could be to remove those proptypes for now to avoid having a useless error message 🤔 |
A just-as-quick and more correct solution would be to update the proptype manually and add the |
i'm kind of new to the industry, what next? is something that is going to be fix in the next version or where should i use @michaldudak |
It's something that needs to be fixed on our side and will be available in following version. When the fix is done, this issue will be closed, and you will get the fix in the version coming after the issue closed (usualy on thursday) |
I am running into something similar with a very simple LineChart. I get following console warning in Chrome DevTools:
Chart def.: <LineChart
xAxis={[
{
data: [1, 2, 3],
},
]}
series={[
{
data: [1, 2, 3],
},
]}
width={500}
height={300}
/>
Full stack trace:
Looking here: https://mui.com/x/api/charts/default-charts-axis-tooltip-content/#props I see: I guess other values than |
I'm having the same issue with PieChart:
It seems the shape of data is same as described in documentation, not sure what is actually wrong. Here is implementation: const ScoreChart = ({
correctAnswers,
wrongAnswers,
score,
width = 150,
height = 150,
}: ScoreChartProps): JSX.Element => {
const theme = useTheme();
const getScoreChartData = (correctAnswers: number, wrongAnswers: number): ChartItem[] => {
return [
{ value: correctAnswers, label: 'Correct answers' },
{ value: wrongAnswers, label: 'Wrong answers' },
];
};
const data = useMemo(() => {
return getScoreChartData(correctAnswers, wrongAnswers);
}, [correctAnswers, wrongAnswers]);
return (
<PieChart
series={[{ data, innerRadius: 50, outerRadius: 70 }]}
width={width}
height={height}
sx={{ border: 0 }}
margin={{ top: 0, bottom: 0, left: 0, right: 0 }}
slotProps={{
legend: {
hidden: true,
direction: 'row',
position: {
vertical: 'bottom',
horizontal: 'middle',
},
},
}}
colors={[theme.palette.success.main, theme.palette.error.main]}
>
<ScoreLabel>{score.toFixed(0)}</ScoreLabel>
</PieChart>
);
}; As a temporary workaround I'm casting series={[{ data: data.slice(), innerRadius: 50, outerRadius: 70 }]} Dependencies:@mui/material 5.15.5 |
It is reproducible on the codesandbox example from the official doc.
|
It's fixed in v7. It's a bit trickier. The fix is ready. I can't reproduce the bug. But because the fix was done in github.com/mui/material-ui (and bumping the monorepo) We've seen no modification in the changelog and so we did not release a v6.19.2 of the charts. The fix will be available in 2 days with the next release |
Should be fixed now for both |
Hi, just updated to v6.19.3 and also tried v7.0.0-beta.1 and getting the same problem, crashes on hover over pie charts and bar charts. |
On
|
@Aqkotz @konrad-jamrozik For the pie chart, I can see the following error
Which can be fixed by using string for series ids However I don't see warning when the tooltip get displayed: https://stackblitz.com/edit/react-a1vkus?file=Demo.tsx bug_ttoltip.mp4.webm |
@alexfauquette Apologies, looks like there is no problem after all. I was trying to reproduce the issue on a new machine and I am unable to. The problem appears only on the older version of relevant MUI package. Looks like this was perhaps local caching issue on my part, sorry about that! Later today (in about 10 hours) I will double-check on my primary dev machine if it behaves the same way, but I fully expect that. |
@alexfauquette I changed the ids to strings, but still get this error when I hover the pie chart. I've cleared the npm cache and updated to 6.19.3.
|
@Aqkotz Your error is unreleated to this issue. It's not a proptypes error. Coudl you open an issue with a reproduction example either in codesandbox or stackblitz such that I can reproduce and debug it? @konrad-jamrozik Thanks for confirmation. I let you close this issue it it works on your other computer, or report the error if it does not 👍 |
@alexfauquette Is https://codesandbox.io/p/sandbox/flamboyant-rain-d246n5?file=%252Fsrc%252FDemo.js |
@enlznep No, this one is another one that will need a distinct fix, because it's the TS definition which is wrong |
@alexfauquette I see. Is this ticket going to be enough to track the fixes for |
That's enough. This PR #11953 should solve it 👍 I was puzzled because I spoted and fixed it on v7 but forgot to back port it to v6 |
@alexfauquette I've checked on another machine and the problem I mentioned is indeed absent. Thank you for the quick fix! Much appreciated! ❤️ (note I don't have permissions to close this issue myself) |
Steps to reproduce
Hi,
i'm using MUI-Charts pie chart.
on runtime, when the tooltip is active (hovering above the chart) i get a warning:
Warning: Failed prop type: Invalid prop 'series.data[0]' of type 'object' supplied to 'DefaultChartsItemTooltipContent', expected 'number'.
here is part of my code:
<PieChart series={[ { data: testData, valueFormatter(item) { return '$' + item.value.toFixed(2); }, }, ]} slotProps={{ legend: { hidden: true } }} width={400} height={200} />
the testData is
{id: number, label: string, value: number, color: string}
, no nulls.by trying to fix the problem i changed the testData to be an array of number, but then i get a syntax error.
i read the documentation and didn't find anything to fix it.
THE CODE IS WORKING but i can't get rid of the warning.
any ideas?
Current behavior
No response
Expected behavior
No response
Context
No response
Your environment
npx @mui/envinfo
Search keywords: tooltip runtime warning
The text was updated successfully, but these errors were encountered: