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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataMaker LabelFormat problem

Thread ID:





130740 May 30,2017 03:10 PM UTC Feb 20,2018 02:51 PM UTC Xamarin.Forms 7
Tags: SfChart
Rudá Cunha
Asked On May 30, 2017 03:10 PM UTC

I have in my chart that already comes from the database. The value in percentage.
In other words, it is already grouped.

In x it is of category type and in Y it is of type Number that goes from 0 to 100.

Category A = 10
Category B = 20
Category C = 30
Category D = 40

Total: 100%

On the Y I put the LabelCreated to be able to put the %

In DataMaker I tried to put the format for Percentage but it appears NaN if it does not come at all 0%.

So I left the default and I'm trying to use the LabelStyle.LabelFormat only that does not work as expected.
If I put "#%" it appears 1000% of time 10%

How do I solve the problem?

Parthiban Sundaram [Syncfusion]
Replied On May 31, 2017 01:19 PM UTC

Thanks for using Syncfusion products. 
You can use the LabelContent property to achieve your requirement. Please find the following code snippet. 
Code Snippet: 
series.DataMarker.LabelContent = LabelContent.Percentage; 
Please let us know, if you need further assistance on this.  
Parthiban S

Rudá Cunha
Replied On May 31, 2017 02:35 PM UTC

It does not work properly.
If all data is 0, Nan appears 0%

Saravana Pandian Murugan [Syncfusion]
Replied On June 1, 2017 03:31 PM UTC

Hi Ruda,

We have achieved your requirement using platform specific codes.

In Android, we have achieved your requirement by using DataMarkerLabelCreated event (MainActivity.cs file).

In iOS, we have achieved your requirement by using GetFormattedDataMarkerLabel override method (AppDelegate.cs file).

In UWP, we have achieved this by using Adornment LabelTemplate (CustomRenderer.cs file).

Please download the sample from the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/130740/ze/DataMarkerLabelSample552792988

Please check the sample and let us know if you need further assistance on this.

Saravana Pandian M.

Geoffrey Chen
Replied On February 8, 2018 10:38 PM UTC

Hi Syncfusion,

I am having the same problem as Ruda when attempting to format percentages in SfChart Categorical Axis.

Our db returns percentages as a number between 0 to 100.

Ideally, it would be nice to be able to escape the "%" character when setting LabelFormat for the axis, as this is how it is typically done with string formatting in C#.

Currently (when inputting 10.00), neither @"#\%" nor "#\\%" LabelFormat properly escape the "%" custom specifier, and instead return 1000\%.

Is your team willing to look at this issue?

Best regards,
Geoffrey Chen

Divya Venkatesan [Syncfusion]
Replied On February 9, 2018 01:23 PM UTC

Hi Geoffrey,

We have prepared a sample to add “%” to the axis label using LabelCreated of ChartAxis. Please download the sample from the following link.

Sample: http://www.syncfusion.com/downloads/support/forum/130740/ze/LabelFormatSample-1793648753

Please let us know, if you need any further assistance.

Divya Venkatesan

Geoffrey Chen
Replied On February 19, 2018 08:33 PM UTC

Hi Syncfusion,

Using LabelCreated does work for ChartAxis, but I am now struggling with the same issue when using LabelFormat for SfChart ToolTip and TrackBall behaviours.
As neither of these have an event like LabelCreated, how else could I properly format for percentages?

Best regards,
Geoffrey Chen

Divya Venkatesan [Syncfusion]
Replied On February 20, 2018 02:51 PM UTC

Hi Geoffrey, 
Please set the TooltipTemplate and TrackballLabelTemplate as shown in below code snippet. 
DataTemplate template = new DataTemplate(() => 
    Label yValue = new Label(); 
    yValue.SetBinding(Label.TextProperty, new Binding("YValue", stringFormat: "{0}%")); 
    return yValue; 
series.TooltipTemplate = template; 
series.TrackballLabelTemplate = template; 
Please let us know, if you need any further assistance on this. 
Divya Venkatesan 


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.

Please sign in to access our forum

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

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