Change SfChart DataMarkerLabelStyle TextColor using Binding Converter

Hi!
I'm trying to change ChartDataMarker's TextColor according to an int property that is converted to some Color based on its value.
I've been using Binding Converter without problems, but with ChartDataMarker it's not working, all label's colors are the same. 
Could someone help me?

Thank you!

Converter:

public class IntegerToColorConverter : IValueConverter
{
    public object Convert(object valueType targetType, object parameter, CultureInfo culture)
    {
        var index = (int)value;

        if (index < 50)
            return Color.FromHex("#ca1d1f");

        return Color.FromHex("#000000");
    }

    public object ConvertBack(object valueType targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
  


Xaml:

<chart:SfChart>
    <chart:SfChart.PrimaryAxis>
        <chart:CategoryAxis>
            <chart:CategoryAxis.Title>
                <chart:ChartAxisTitle Text="X" />
            chart:CategoryAxis.Title>
        chart:CategoryAxis>
    chart:SfChart.PrimaryAxis>
    
    <chart:SfChart.SecondaryAxis>
        <chart:NumericalAxis>
            <chart:NumericalAxis.Title>
                <chart:ChartAxisTitle Text="Y" />
            chart:NumericalAxis.Title> 
        chart:NumericalAxis>
    chart:SfChart.SecondaryAxis>

    <chart:SfChart.Series>
        <chart:LineSeries ItemsSource="{Binding PersonList}" XBindingPath="Person" YBindingPath="Grade">

            <chart:LineSeries.DataMarker>
                <chart:ChartDataMarker>
                    <chart:ChartDataMarker.LabelStyle>
                        <chart:DataMarkerLabelStyle TextColor="{Binding Grade, Converter={StaticResource integerToColorConverter}}" />
                    chart:ChartDataMarker.LabelStyle>
                chart:ChartDataMarker>
            chart:LineSeries.DataMarker>
            
        chart:LineSeries>
    chart:SfChart.Series>
    
chart:SfChart>
  

2 Replies

CL Caio Liberali October 20, 2017 01:07 AM UTC

Hi!

I missed this post: https://www.syncfusion.com/forums/133198/funnel-chart-label-string-format !

Using DataTemplate it worked!





PS Parthiban Sundaram Syncfusion Team October 20, 2017 09:27 AM UTC

Hi Caio,

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

Regards,
Parthiban S

Loader.
Up arrow icon