BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hello
Is there a way to display the value as a percentage of the total in a tooltip hoover. Do I have to calculate in my datasource and use the TooltipMappingName or is there an out of the box method?
Thanks
Hi Ditchford,
Greetings from Syncfusion.
We suggest you to sepcify tooltip format as ${point.percentage} to display percentage value for accumulation chart and TooltipRender event to customize the chart series tooltip text. We have prepared sample based on your requirement. Please check with below snippet and sample.
<SfChart> <ChartEvents TooltipRender="OnTooltipRender"></ChartEvents> <ChartTooltipSettings Enable=true></ChartTooltipSettings> </SfChart>
<SfAccumulationChart> <AccumulationChartTooltipSettings Format="${point.percentage}%"> </AccumulationChartTooltipSettings> </SfAccumulationChart> @code { public double totalSum = 0; protected override void OnInitialized() { for (int i = 0; i < MedalDetails.Count; i++) { totalSum = totalSum + Convert.ToInt16(MedalDetails[i].YValue); } } public void OnTooltipRender(TooltipRenderEventArgs args) { var percentage = (Convert.ToDouble(args.Data.PointY) / totalSum) * 100; args.Text = Math.Round(percentage, 2) + "%"; }} |
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/TooltipPerc-83147131.zip
Kindly revert us if you have any concerns.
Regards,
Durga Gopalakrishnan.
Ditchford,
Most welcome. Please get back to us if you need any further assistance. We are always happy in assisting you.