Formatting chart values using Syncfusion for Xamarin Forms

4

I'm using Syncfusion to create graphics in Xamarin Forms .

By studying the documentation , I could not find a way to format the values in my chart, example:

IwantthesevaluesformattedforBraziliancurrency:October-R$14,421.52

DoesanyoneknowhowIcandothis?

MypageinXAML:

<chart:SfChart.Series><chart:BarSeriesItemsSource="{Binding PieSeriesData}" Color="Red" XBindingPath="Name" YBindingPath="Value" LegendIcon="Rectangle" Label="Valor (R$)" EnableAnimation="True">
                                <chart:BarSeries.DataMarker>
                                    <chart:ChartDataMarker LabelContent="YValue" ShowLabel="True">
                                        <chart:DataMarkerLabelStyle LabelFormat="R$##,##" LabelPosition="Center"/>
                                    </chart:ChartDataMarker>
                                </chart:BarSeries.DataMarker>
                            </chart:BarSeries>
                        </chart:SfChart.Series>
    
asked by anonymous 04.10.2017 / 15:47

1 answer

1

Contact Syncfusion support.

Support Response - SyncFusion You can achieve this by setting a DataTemplate with an IValueConverter to the data-marker marker and using the ChartDataMarker.LabelTemplate property. See the following code snippet for more details.

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 class DataMarkerConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        double yValue = System.Convert.ToDouble(value);
        return yValue.ToString("#,###.##", new CultureInfo("pt-BR"));
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return value;
    }
}

Questions and Suggestions feel free to comment ...

    
16.10.2017 / 14:23