Articles in this section
Category / Section

How to Rotate Data Labels in .NET MAUI CartesianChart?

2 mins read

This article guides you on how to rotate data labels in a .NET MAUI SfCartesianChart. 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

DataLabel_rotation.png

Conclusion

I hope you enjoyed learning how to rotate data labels in .NET MAUI CartesianChart.

You can refer to our .NET MAUI CartesianChart feature tour page to know about its other groundbreaking feature representations. You can also explore our .NET MAUI Chart documentation to understand how to present 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 trail 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, 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)
Please  to leave a comment
Access denied
Access denied