Articles in this section

How to change the legend icons in .NET MAUI Chart (SfCartesianChart)?

This article demonstrates how to change the legend icons in a .NET MAUI Cartesian Chart. The LegendIcon can be customized with various symbols for each series using the LegendIcon property of the .NET MAUI ChartSeries. The following symbols can be set for the legend icon:

  • Circle
  • Cross
  • Diamond
  • Hexagon
  • HorizontalLine
  • InvertedTriangle
  • Pentagon
  • Plus
  • Rectangle
  • SeriesType
  • Triangle
  • VerticalLine

Note: When you set the LegendIcon property to SeriesType, the shape of the icon will be the prototype of the respective series.

XAML

<chart:SfCartesianChart>
. . .
<chart:SfCartesianChart.Legend>
   <chart:ChartLegend></chart:ChartLegend>
</chart:SfCartesianChart.Legend>

<chart:ColumnSeries ItemsSource="{Binding Data1}"
                    XBindingPath="Year"
                    YBindingPath="Temperature"
                    Label="High"
                    LegendIcon="Triangle"/>
<chart:ColumnSeries ItemsSource="{Binding Data2}"
                    XBindingPath="Year"
                    YBindingPath="Temperature"
                    Label="Moderate"
                    LegendIcon="SeriesType"/>
<chart:ColumnSeries ItemsSource="{Binding Data3}"
                    XBindingPath="Year"
                    YBindingPath="Temperature"
                    Label="Low"
                    LegendIcon="InvertedTriangle"/>                    
. . .
</chart:SfCartesianChart>

C#

SfCartesianChart chart = new SfCartesianChart();
chart.Legend = new ChartLegend();

ColumnSeries series1 = new ColumnSeries();
. . .
series1.Label = "High" ;
series1.LegendIcon = ChartLegendIconType.Triangle;

ColumnSeries series2 = new ColumnSeries();
. . .
series2.Label = "Moderate" ;
series2.LegendIcon = ChartLegendIconType.SeriesType;

ColumnSeries series3 = new ColumnSeries();
. . .
series3.Label = "Low" ;
columnSeries3.LegendIcon = ChartLegendIconType. InvertedTriangle;

chart.Add(series1);
chart.Add(series2);
chart.Add(series3);

this.Content = chart;

The following screenshot displays the different legend icons for each series.

Output image of legend icon type in .NET MAUI Cartesian Chart

Conclusion

I hope you enjoyed learning how to change the legend icons in .NET MAUI Chart (SfCartesianChart).

You can refer to our .NET MAUI Chart feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI Chart documentation to understand how to present and manipulate data.

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

Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, 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)
Access denied
Access denied