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.

DataMaker LabelFormat problem

Thread ID:

Created:

Updated:

Platform:

Replies:

130740 May 30,2017 11:10 AM Feb 20,2018 09:51 AM Xamarin.Forms 7
loading
Tags: SfChart
Rudá Cunha
Asked On May 30, 2017 11:10 AM

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 09:19 AM

  
  
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
 
  
  


Rudá Cunha
Replied On May 31, 2017 10:35 AM

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

Saravana Pandian Murugan [Syncfusion]
Replied On June 1, 2017 11:31 AM

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.


Geoffrey Chen
Replied On February 8, 2018 05:38 PM

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 08:23 AM

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


Geoffrey Chen
Replied On February 19, 2018 03:33 PM

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 09:51 AM

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 
 


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.

;