We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize each label of the axis in different format?

Platform: Xamarin.Forms |
Control: SfChart

In SfCharts , you can format the axis labels using the LabelFormat property of the respective axis. This will format all the labels in an axis with the same format.

Suppose, if you want to format each label in an axis with different format, this can be done in LabelCreated event. This event will be fired once for each label of that axis. You can get the current label’s content using the LabelContent property in the event argument and format the label and assign the formatted content to the LabelContent property itself.

In the following code example, the first label of each month in the DateTimeAxis is formatted with month format and other labels in the same month are formatted with day format.


chart.PrimaryAxis = new DateTimeAxis() { IntervalType = DateTimeIntervalType.Days, 
Interval = 11}; 
chart.PrimaryAxis.LabelCreated += PrimaryAxis_LabelCreated;



      <chart:DateTimeAxis IntervalType="Days" LabelCreated = "PrimaryAxis_LabelCreated">



int month = 0;
void PrimaryAxis_LabelCreated(object sender, ChartAxisLabelEventArgs e)
            DateTime date = DateTime.Parse(e.LabelContent);
            if (month != date.Month)
                e.LabelContent = date.ToString("MMM");
                month = date.Month;
                e.LabelContent = date.Day.ToString();


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CustomAxisLabel1047363945.zip  



Format the axis labels in SfCharts

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile