Replies: 5 comments 4 replies
-
Same here - I'd like to pass a percentage sign to e.g. a Pie chart, but since the payload value can only be a number (logical), I'd like to have a possibility to format the value |
Beta Was this translation helpful? Give feedback.
-
A bit of clarification for anyone else stumbling on this. You can use <ChartTooltipContent formatter={(value) => `${value.toLocaleString()} %`} /> Alternatively, see #4542 for a potential implementation |
Beta Was this translation helpful? Give feedback.
-
One work around I found other than using the formatter suggested by DeividasJackus which overwrites the prestyled tooltip is to add a class name in the ChartToolTipContent e.g. then go into the ChartTooltipContent class and add a className to the value span: Then just go to your global.css and add: Then whenever you have a chart where you want to add percentage, just make sure you pass the className to the ChartToolTip class, else if you don't pass it, nothing is added. |
Beta Was this translation helpful? Give feedback.
-
@MD-AZMAL i got the same issue but i saw this section of the shadcn charts https://ui.shadcn.com/charts#tooltip There is last option |
Beta Was this translation helpful? Give feedback.
-
You can actually update the payload value as you wish. It's something like this This way you don't have to use the formatter just to change the tooltip value and also you can keep the styles unchanged. Define the formatValue function to return the updated value with the percentage |
Beta Was this translation helpful? Give feedback.
-
The default chart tooltip component
displays the value as it is, is it possible to format the value like the tickformater, I checked the docs it only has labelFormatter and not the valueFormatter and the only option left is the formatter prop which requires returning your own component which is not ideal in most cases
Beta Was this translation helpful? Give feedback.
All reactions