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

DataMaker LabelFormat problem

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?

7 Replies

PS Parthiban Sundaram Syncfusion Team 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.  
 
  
Regards,
Parthiban S
 
  
  



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

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


SP Saravana Pandian Murugan Syncfusion Team 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.

Regards,
Saravana Pandian M.



GC Geoffrey Chen 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




DV Divya Venkatesan Syncfusion Team 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.

Regards,
Divya Venkatesan



GC Geoffrey Chen 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


DV Divya Venkatesan Syncfusion Team 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. 
 
Regards, 
Divya Venkatesan 
 


Loader.
Live Chat Icon For mobile
Up arrow icon