Articles in this section
Category / Section

How to format the pie chart tooltip y value in Blazor Charts?

2 mins read

This article explains how to format the y-value of a pie chart tooltip using an event.

Formatting Tooltip Y Value

Blazor Charts provides an option to format the pie chart tooltip y value using TooltipRender event. This can be achieved by converting the data point y value from TooltipRender event arguments using N3 and assigning the formatted text to Text argument.

The code example below demonstrates how to format a tooltip double value.

Index.razor

@using Syncfusion.Blazor.Charts
@using System.Globalization;

<div class="control-section">
   <SfAccumulationChart EnableSmartLabels="false" EnableBorderOnMouseMove="false" ID="drilldown" >
       <AccumulationChartTooltipSettings Enable="true"></AccumulationChartTooltipSettings>
       <AccumulationChartEvents TooltipRender="TooltipRenderEvent"></AccumulationChartEvents>
       <AccumulationChartLegendSettings Visible="false"></AccumulationChartLegendSettings>
       <AccumulationChartSeriesCollection>
           <AccumulationChartSeries DataSource="@StatisticsDetails" XName="XValue" YName="YValue" Name="Browser" Radius="@Radius" StartAngle="0"
                                    EndAngle="360" InnerRadius="@InnerRadius">
               <AccumulationDataLabelSettings Visible="false">
               </AccumulationDataLabelSettings>
           </AccumulationChartSeries>
       </AccumulationChartSeriesCollection>
    
   </SfAccumulationChart>
</div>


@code{

   public string FontColor = "black";
   public AccumulationLabelPosition LabelPosition { get; set; } = AccumulationLabelPosition.Inside;
   public bool Rotation { get; set; } = false;
   public string Radius = "100%";
   public string InnerRadius = "0%";

   public void TooltipRenderEvent(Syncfusion.Blazor.Charts.TooltipRenderEventArgs args)
   {
       args.Text = args.Data.PointX + " " + Convert.ToDouble(args.Data.PointY).ToString("N3", CultureInfo.InvariantCulture);
   }

   public class Statistics
   {
       public string XValue { get; set; }
       public double YValue { get; set; }
   }

   public List<Statistics> StatisticsDetails = new List<Statistics>
   {
       new Statistics { XValue = "Chrome", YValue = 374.235423423123 },
       new Statistics { XValue = "Firefox", YValue = 273.523423432321 },
       new Statistics { XValue = "Opera", YValue = 294.234423421231 },
       new Statistics { XValue = "Edge", YValue = 434.233423422312  },
     

   };
}

The following screenshot illustrates the output of the code snippet.

Output

image.png

Live Sample for Tooltip Format

Conclusion

I hope you enjoyed learning how to format the pie chart tooltip y value in Blazor Chart.

You can refer to our Blazor Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Chart example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied