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

Is it possible to bind XBindingPath="{Binding Key, StringFormat='{0:MMM yyyy}'}" in SfChart Series

Is it possible to bind XBindingPath="{Binding Key, StringFormat='{0:MMM yyyy}'}" in

           <chart:SfChart.Series>
                            <chart:SplineSeries x:Name="splineSalesGraph"
                                                ItemsSource="{Binding MonthWiseSummaryList}" 
                                                XBindingPath="Key"
                                                YBindingPath="Value"
                                                EnableAnimation="True" EnableTooltip="False">
                            </chart:SplineSeries>
           </chart:SfChart.Series>

where Key is a property in :

namespace System.Collections.Generic
{
     public struct KeyValuePair<TKey, TValue>
    {
          public KeyValuePair(TKey key, TValue value);

          public TKey Key { get; }
        
          public TValue Value { get; }
 
          public override string ToString();
    }
}

in ViewModel : 

            MonthWiseSummaryList = new List<KeyValuePair<DateTime, double>>();
            MonthWiseSummaryList.Add(new KeyValuePair<DateTime, double>(new DateTime(2017, 03, 01), 383884.00));



3 Replies

PS Parthiban Sundaram Syncfusion Team September 4, 2017 10:43 AM UTC

Hi Balamuraleekrishna,

Thanks for using Syncfusion products.

You can achieve your requirement by using LabelStyle.LabelFormat propertyof DateTimeAxis. Please find the below code snippet.

Code Snippet:

 
  
        <chart:DateTimeAxis> 
  
          <chart:DateTimeAxis.LabelStyle> 
  
            <chart:ChartAxisLabelStyle LabelFormat="MMM yyyy"/> 
  
          </chart:DateTimeAxis.LabelStyle> 
  
        </chart:DateTimeAxis> 
  
 

Sample: https://www.syncfusion.com/downloads/support/forum/132431/ze/LabelStyle-1150041112

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

Regards,
Parthiban S


BK Balamuraleekrishna K R September 6, 2017 05:38 AM UTC

Thank you sir..... Really helpful.



PS Parthiban Sundaram Syncfusion Team September 7, 2017 06:31 AM UTC

Hi Balamuraleekrishana,

Thanks for the update. We are glad that the given solution has helped to achieve your requirement. Please let us know for your further assistance.

Regards,
Parthiban S


Loader.
Live Chat Icon For mobile
Up arrow icon