How to rotate data labels in .NET MAUI Cartesian Chart?
This article guides you on how to rotate data labels in a .NET MAUI Cartesian Chart. Data labels can be rotated by setting the angle (in degrees) using the Angle property of ChartDataLabelStyle.
Step 1:
Begin by initializing the SfCartesianChart following the guidelines in documentation.
Step 2:
The ShowDataLabels property of the series is used to enable the data labels. Utilize the Angle property of type double, available in the ChartDataLabelStyle, to rotate the data labels in the chart. Refer to the following code sample for reference:
[XAML]
<chart:SfCartesianChart>
..
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="Year"
YBindingPath="SalesRate"
ShowDataLabels="True">
<chart:ColumnSeries.DataLabelSettings>
<chart:CartesianDataLabelSettings>
<chart:CartesianDataLabelSettings.LabelStyle>
<chart:ChartDataLabelStyle Angle="90"/>
</chart:CartesianDataLabelSettings.LabelStyle>
</chart:CartesianDataLabelSettings>
</chart:ColumnSeries.DataLabelSettings>
</chart:ColumnSeries>
</chart:SfCartesianChart>
[C#]
SfCartesianChart chart = new SfCartesianChart();
...
var series = new ColumnSeries
{
ItemsSource = new ViewModel().Data,
XBindingPath = "Year",
YBindingPath = "SalesRate",
ShowDataLabels = true,
};
series.DataLabelSettings = new CartesianDataLabelSettings();
series.DataLabelSettings.LabelStyle = new ChartDataLabelStyle()
{
Angle = 90,
};
chart.Series.Add(series);
this.Content = chart;
Output
Conclusion
I hope you enjoyed learning how to rotate data labels in .NET MAUI Cartesian Chart.
You can refer to our .NET MAUI Cartesian 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 components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our other controls.
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!