-
-
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 - Tooltip - custom item content #10352
Comments
In brief, to unlock you:
And it expects a component that get following props:
Not sure it's a "correct UI", but this codesandbox should help to understand how to use it https://codesandbox.io/s/determined-dew-mkctjw?file=/Demo.tsx |
Hey @alexfauquette Thanks for this. I succeeded to use the itemContent component in my ScatterChart. However, in my serie, I have object with a lot of attributes and in the CustomItemTooltipContent function passed to the trigger.ItemContent param, I can only have access to x, y and id parameters (ScatterValueType), not the all object attributes. Do you know I can work around that? |
Sorry for the delay, I just saw I did not answer your last question. The tooltip item content gets Here is an example with additional information https://codesandbox.io/s/vibrant-violet-nj83jr?file=/Demo.tsx const CustomItemTooltipContent = (props) => {
const { itemData, series } = props;
return (
<Paper sx={{ padding: 3, backgroundColor: series.color }}>
<p>{series.label}</p>
<p>x: {series.data[itemData.dataIndex].x.toFixed(2)}</p>
<p>y: {series.data[itemData.dataIndex].y.toFixed(2)}</p>
<p>
additional value: {series.data[itemData.dataIndex].other.toFixed(2)}
</p>
<p>
other additional value:{" "}
{series.data[itemData.dataIndex].other2.toFixed(2)}
</p>
</Paper>
);
}; |
Thanks, working as espected. Two things on a side note:
|
Yes, I moved it to
You mean that you're manually triggering the |
I mean The tooltip code is triggered only if you put your mouse over the data point in the chart. If you have some rendering conditions in this part, it's run only on mouse over. |
How did we do @wascou? |
@alexfauquette hi there! In the bar chart this value is available but not in line chart. |
Because the notion of item tooltip for the line chart is not well defined. I would not recommend using item tooltip for line chart You could get a more advance customization example in #13944 If it does not solve your issue, please consider opening another one in which you explain what you try to achieve. |
I am currently trying to manipulate the Tooltip for a BarChart. The problem seems to be that When I hover over both x axis groups, it displays all the data in the series instead of just the items I am wanting to display that are relevant to group. I was wanting to attempt to keep it as one chart rather than breaking it up into two charts.
And I tried passing in a custom Tooltip:
|
@ThreeCrown This issue is closed since a long time. Could you please open a new one with a codesandbox reproduction such that we can experiment with your issue. This one should be a good starting point: https://codesandbox.io/p/sandbox/wqd5xt?file=%2Fsrc%2FDemo.tsx%3A6%2C14 |
Duplicates
Latest version
Summary 💡
I would like to have documentation to know how to implement this.
Examples 🌈
There's no documentation at the moment or example in all the example pieces of code.
Tooltip page is not mentionning it:https://mui.com/x/react-charts/tooltip/
It's specified in https://mui.com/x/api/charts/charts-tooltip/ as "itemContent".
I've also tried to figure out how it works by coding an example.
Motivation 🔦
I would like to enrich the chart experience with a correct UI.
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: