We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the individual legend item based on a condition in Xamarin.Forms Chart?

You can customize all the legend items by setting individual style using the LegendItemCreated event. This event will be fired when a chart legend item is created. For more details about the event arguments, refer to this documentation.

The following code sample demonstrates how to set individual style to all the legend items and you can download the complete sample here.


<chart:SfChart x:Name="chart" LegendItemCreated="Chart_LegendItemCreated">


chart.LegendItemCreated += Chart_LegendItemCreated;
private void Chart_LegendItemCreated(object sender, ChartLegendItemCreatedEventArgs e)
   Model model = e.LegendItem.DataPoint as Model;
   e.LegendItem.Label = model.XValue + ": " + model.YValue.ToString();
   e.LegendItem.LabelStyle = new ChartLegendLabelStyle()
        TextColor = model.YValue > 50 ? Color.Green : Color.Red,
        FontFamily = model.YValue > 50 ? "Times New Roman" : "Arial"


Pie Chart with customized legend items in Xamarin.Forms

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile