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

Decimal numbers separator

Hi,

Is it posible to set always "," as default decimal separator regardless the OS language (culture)?

Currently I´m using "LabelFormat = "#,###.##"" to establish the label style, however the decimal separator number changes with the OS culture (English = "." Spanish = ",")

Thank you.

9 Replies

PS Parthiban Sundaram Syncfusion Team September 20, 2017 01:05 PM UTC

Hi Jaiver,   
  
 
Thanks for using Syncfusion products.   
   
You can achieve this requirement by specifying the culture info when formatting the string. The labels of the axis can be accessed from LabelCreated event of ChartAxis. Please refer the following code snippet.  
   
Code Snippet:   
   
   
        private void YAxis_LabelCreated(object sender, Syncfusion.SfChart.XForms.ChartAxisLabelEventArgs e)   
        {   
            double value = Convert.ToDouble(e.LabelContent);   
            e.LabelContent = value.ToString("#,###.##"new CultureInfo("en-US"));   
        }   
 
    
We have created a simple demo sample to demonstrate this. Please download it from below location.  
  
   
Please let us know, if you need further assistance on this.  
  
Regards,   
Parthiban S  
 



JA Javier September 21, 2017 01:59 PM UTC

Hi,

It works great.

Thank you!



PS Parthiban Sundaram Syncfusion Team September 22, 2017 06:44 AM UTC

Hi Jaiver, 
 
Thanks for the update. We are glad that the given solution has helped to achieve your requirement. Please let us know, if you need further assistance on this. 
 
Regards, 
Parthiban S 



JA Javier September 22, 2017 08:47 AM UTC

Hi,

One more cuestion please. What about formatting "StackingBarSeries -> DataMarker" and "StackingBarSeries -> ToolTip" specifying the culture info?

Thanks.



PS Parthiban Sundaram Syncfusion Team September 25, 2017 12:52 PM UTC

Hi Jaiver,   
   
Thanks for the update.   
   
You can achieve this requirement by setting a DataTemplate with an IValueConverter for both data marker label and tooltip using ChartDataMarker.LabelTemplate and ChartTooltipBehavior.TooltipTemplate properties respectively. Please refer the following code snippet for more details   
   
Code snippet:   
   
DateTemplate   
   
   
    <ResourceDictionary>   
     <local:DataMarkerConverter x:Key="labelConverter"></local:DataMarkerConverter>   
      <DataTemplate x:Key="LabelTemplate">   
        <StackLayout>   
            <Label Text="{Binding YValue, Converter={StaticResource labelConverter}"/>   
        </StackLayout>   
      </DataTemplate>   
    </ResourceDictionary>   
   
  
   
Converter  
   
   
        public object Convert(object value, Type targetType, object parameter, CultureInfoculture)   
        {   
            double yValue = System.Convert.ToDouble(value);   
            return yValue.ToString("#,###.##"new CultureInfo("en-US"));   
        }   
  
   
   
We have created a simple demo sample to demonstrate this. Please download it from below location.     
   
   
Please let us know, if you need further assistance on this.  
  
Regards, 
Parthiban S  



JA Javier September 26, 2017 09:36 AM UTC

Thank you. Could you please post the equivalent for C# code?



PS Parthiban Sundaram Syncfusion Team September 27, 2017 01:11 PM UTC

Hi Jaiver,

Thanks for the update.

As per your requirement, we have prepared the sample with code behind (C#). Please download the sample from following location.

Sample: http://www.syncfusion.com/downloads/support/forum/132751/ze/ChartSample-1678669771

Please let us know, if you need further assistance on this.

Regards,
Parthiban S



JA Javier September 27, 2017 04:48 PM UTC

Works perfect.

Thank you for the excellent assistance.



PS Parthiban Sundaram Syncfusion Team September 28, 2017 05:47 AM UTC

Hi Jaiver,

Thanks for the update. We are glad that the given solution has helped to achieve your requirement. Please let us know, if you need further assistance on this.

Regards,
Parthiban S

Loader.
Up arrow icon