How to Change the Legend Position in .NET MAUI Sunburst Chart?
In this article, we’ll learn how to configure and customize the position of the legend in the .NET MAUI Sunburst Chart. The article provides step-by-step instructions, relevant code examples, and additional settings to achieve the desired legend position.
Step 1: Initialize the SfSunburstChart with its ItemsSource bound to the data from the ViewModel, and define the hierarchical levels.
<chart:SfSunburstChart ItemsSource="{Binding DataSource}"
ValueMemberPath="EmployeesCount">
<chart:SfSunburstChart.BindingContext>
<local:ViewModel/>
</chart:SfSunburstChart.BindingContext>
<chart:SfSunburstChart.Levels>
<chart:SunburstHierarchicalLevel GroupMemberPath="Country"/>
<chart:SunburstHierarchicalLevel GroupMemberPath="JobDescription"/>
<chart:SunburstHierarchicalLevel GroupMemberPath="JobGroup"/>
<chart:SunburstHierarchicalLevel GroupMemberPath="JobRole"/>
</chart:SfSunburstChart.Levels>
</chart:SfSunburstChart>
Step 2: Use the Legend property to enable and display the Sunburst chart legend.
<chart:SfSunburstChart>
. . .
<chart:SfSunburstChart.Legend>
<chart:SunburstLegend/>
</chart:SfSunburstChart.Legend>
. . .
</chart:SfSunburstChart>
Step 3: Use the Placement property of the SunburstLegend to define the legend’s position. You can set it to Top, Bottom, Left, or Right.
<chart:SfSunburstChart.Legend>
<chart:SunburstLegend Placement="Bottom"/>
</chart:SfSunburstChart.Legend>
Ouput:
Conclusion:
I hope you enjoyed learning how to add and change the position of the chart legend in the .NET MAUI Sunburst Chart.
You can refer to our .NET MAUI Sunburst Chart feature tour page to know about its other groundbreaking feature representations. Explore our .NET MAUI Sunburst Chart documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI components 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!