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.
Unfortunately, activation email could not send to your email. Please try again.

Formatting labels on axes

Thread ID:

Created:

Updated:

Platform:

Replies:

118215 Feb 12,2015 04:25 AM Aug 18,2016 03:08 AM Xamarin.Forms 7
loading
Tags: SfChart
Steen Steiniche
Asked On February 12, 2015 04:25 AM

How does one format labels on chart axes?
 
For example, if I have a series with dates on the primary axis (x axis) and want to format these labels to, say, "dd MMM", how do I do that?
 
I do not want to change the actual date values in the data used for the series. I want to change labels before rendering chart.

Magesh Kumar Krishnan [Syncfusion]
Replied On February 12, 2015 05:55 AM

Hi Steen,

Thanks for using Syncfusion Products.

We can achieve your requirement by using LabelFormat property of ChartAxis as shown in the below code snippet.

CodeSnippet:

[XAML] :

<chart:DateTimeAxis.LabelStyle>

            <chart:ChartAxisLabelStyle LabelFormat = "dd MMM"></chart:ChartAxisLabelStyle>

</chart:DateTimeAxis.LabelStyle

[C#] :

DateTimeAxis dateTimeAxis = new DateTimeAxis();

dateTimeAxis.LabelStyle.LabelFormat = "dd MMM ";


Please let us know if you require further assistance on this.

Thanks,

Magesh Kumar K


Steen Steiniche
Replied On February 12, 2015 06:22 AM

Hello Magesh Kumar K
 
Thanks for your reply. That works if I want to set an overall format rule.
 
I need more control than that, however. For instance, I might want to format only the first date of the month with "dd MMM" and all other dates in that month with just "dd". How is that achieved?
 
Thanks in advance
 
Steen

Magesh Kumar Krishnan [Syncfusion]
Replied On February 13, 2015 02:05 AM

Hi Steen,

We are glad to let you know that we have achieved your requirement by using a workaround. In this sample, we have written custom renderer for each platform for formatting individual labels in axis. We will provide this support in control level in any of our upcoming volume release.

Please find the workaround sample from the following attachment.

Sample: http://www.syncfusion.com/downloads/support/directtrac/118215/CustomAxisLabelFormat-1084686580.zip
 

Note:
While customizing individual axis labels in custom renderer for iOS, we faced an error while deploying it to an iPhone device. We have also fixed that error. Please replace the below attached Syncfusion.SfChart.iOS.dll in your “../lib/1.3/ios-unified” and “../lib/1.3/ios“paths in order to run the application on iPhone device.

Dll: http://www.syncfusion.com/downloads/support/directtrac/118215/Xamarian.iOS_Assemblies-83160372.zip

Please let us know if you require further assistance on this.

Thanks,
Magesh Kumar K


Tomasz Wisniewski
Replied On February 24, 2015 02:56 PM

Hello,
Date and time take some space horizontally, so on Windows Phone I displayed label in two rows: time on top (with "t" formatter, eg. 9:15 PM) and and date on bottom (MonthDayPattern, eg. Jan 1). I used LabelTemplate and and StackPanel inside of it. Is it possible to do something similar in Xamarin.Forms? I tried to achieve this with the custom renderer that you provided, however if I give string with two lines it renders in one line anyway. If I give for example TextView as LabelContent, it displays only class name. Do you have any ideas?

Thanks,
Tomasz

Magesh Kumar Krishnan [Syncfusion]
Replied On February 25, 2015 08:18 AM

Hi Thomasz,

We have created incident #135846 on behalf of you for this reported requirement. Our support engineer will assist you through incident under your Direct Trac account. So we request you to follow with the incident for further details.
Our Direct Trac support system can be accessed from the following link:
                               
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let us know if you require further assistance on this.

Thanks,
Magesh Kumar K

David Myers
Replied On August 17, 2016 12:39 AM

Hi,

Was a solution found to allow line breaks in axis labels? We'd also like to utilize this feature.

Yuvaraj Palanisamy [Syncfusion]
Replied On August 18, 2016 03:08 AM

Hi David, 

We have logged this as a feature request in our database. We will implement this feature in upcoming volume 2 service pack 2 release and it is estimated to be rolled in the end of August, 2016.  
 
Thanks, 
Yuvaraj 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;