Articles in this section
Category / Section

How to customize the axis labels in Xamarin.Forms Chart?

4 mins read

Xamarin.Forms Chart supports customization of its axis labels using the LabelStyle property of ChartAxis. By using the LabelStyle property, you can customize the following aspects of the axis labels:

  • BorderColor—Color of the background border.
  • BorderThickness—Thickness of the background border.
  • BackgroundColor—Background fill color.
  • Font—Represents the size, font-family, and font-weight of the text.
  • LabelPosition—Represents the position of the axis labels. Whether it can be inside or outside of the chart area.
  • LabelFormat—Formatter string of the labels.
  • Margin—Represents the margin between the label and background rectangle.
  • TextColor—Color of the labels.

The following code example illustrates the customization of the axis label’s font, position, format, and its color.

C#

chart.PrimaryAxis.LabelStyle.Font = Font.SystemFontOfSize(30);
chart.PrimaryAxis.LabelStyle.LabelsPosition = AxisElementPosition.Inside;
chart.PrimaryAxis.LabelStyle.LabelFormat = "MMM";
chart.PrimaryAxis.LabelStyle.TextColor = Color.Red;

 

XAML

<chart:SfChart.PrimaryAxis>
      <chart:DateTimeAxis >             
        <chart:DateTimeAxis.LabelStyle>
          <chart:ChartAxisLabelStyle LabelFormat = "MMM" LabelsPosition="Inside" TextColor="Red">            
            <chart:ChartAxisLabelStyle.Font>
              <Font FontSize="30"/>
            </chart:ChartAxisLabelStyle.Font>            
          </chart:ChartAxisLabelStyle>          
        </chart:DateTimeAxis.LabelStyle>        
      </chart:DateTimeAxis>
    </chart:SfChart.PrimaryAxis>

 

Output:

Axis label customization in Xamarin.Forms Chart 

Conclusion

I hope you enjoyed learning about how to customize the axis labels in Xamarin.Forms Chart.

You can refer to our Xamarin.Forms Chart feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create 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 trial 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 forumsDirect-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