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

Y axis values are not appearing using ChartDataPoint Binding

I am trying to display date or month in X axis as below, it works fine. I can see the columnseries and weight number on y axis but not months on X axis. I tried alternatively using Date instead of month but I cant see dates either

If i bind directly my AllBodyStats list object by defining binding on XBindingPath an YBindingPath, I can see the dates on X axis. Am I missing something? why it doesnt work using ChartDataPoint

xaml;

  <chart:SfChart x:Name="Chart" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

         
            <chart:SfChart.Title>

                <chart:ChartTitle Text="{Binding ChartTitle}"/>

            </chart:SfChart.Title>
            <chart:SfChart.PrimaryAxis>

                <chart:DateTimeAxis IntervalType="Months" Interval="1">

                    <chart:DateTimeAxis.Title>

                        <chart:ChartAxisTitle Text="{resx:Translate Date}"></chart:ChartAxisTitle>

                    </chart:DateTimeAxis.Title>
                  
                </chart:DateTimeAxis>

            </chart:SfChart.PrimaryAxis>

            <chart:SfChart.SecondaryAxis>

                <chart:NumericalAxis  Minimum="0" Maximum="{Binding NumericalAxisMax}" Interval="{Binding NumericalAxisInterval}" >

                    <chart:NumericalAxis.Title>

                        <chart:ChartAxisTitle Text="{Binding NumericalAxisTitle}" ></chart:ChartAxisTitle>

                    </chart:NumericalAxis.Title>

                </chart:NumericalAxis>

            </chart:SfChart.SecondaryAxis>

            <chart:SfChart.Series>

                <chart:ColumnSeries ItemsSource="{Binding NumericMonthStats, Mode=OneWay}"  EnableAnimation = "true" AnimationDuration="0.8" >
                    <chart:ColumnSeries.DataMarker>
                        <chart:ChartDataMarker/>
                    </chart:ColumnSeries.DataMarker>
                </chart:ColumnSeries>

            </chart:SfChart.Series>


        </chart:SfChart>


viewmodel:

        public ObservableCollection<ChartDataPoint> NumericMonthStats{ get; set; }

           foreach (var BodyStat in AllBodyStats.OrderBy(o=>o.DateCreated))
            {
                string month = BodyStat.DateCreated.ToString("MMMM", Helpers.Settings.CurrentCultureInfo);

 
                    NumericMonthStats.Add(new ChartDataPoint(month, (double)BodyStat.Weight)); // using month
                    NumericMonthStats.Add(new ChartDataPoint(BodyStat.DateCreated.Date, (double)BodyStat.Weight)); // using date
          
            }


using my custom list object

 <chart:SfChart.Series>

            <chart:ColumnSeries ItemsSource="{Binding AllBodyStats}" XBindingPath="DateCreated" YBindingPath="Weight">
                <chart:ColumnSeries.DataMarker>
                    <chart:ChartDataMarker/>
                </chart:ColumnSeries.DataMarker>
            </chart:ColumnSeries>

        </chart:SfChart.Series>


1 Reply

SP Saravana Pandian Murugan Syncfusion Team August 1, 2017 01:32 PM UTC

Hi Emil, 
  
Thanks for contacting Syncfusion support. 
  
We are not able to reproduce the reported issue at our end and we have prepared a sample for this. Please update us the modified sample to reproduce the issue which will be helpful for providing further assistance on this. 
  
Note: If you bind the custom object, you should bind the model properties. If you bind Data using ChartDataPoint and update the data dynamically, you should set XBindingPath as “XValue” and YBindingPath as “YValue” as per the below code. But we always recommend you to set XBindingPath as “XValue” and YBindingPath as “YValue” if you bind ChartDataPoint object. 
  
Code Example:  
  
  
<chart:SfChart.Series> 
  
          <chart:ColumnSeries ItemsSource="{Binding NumericMonthStats}" XBindingPath="XValue" YBindingPath="YValue"> 
  
                 <chart:ColumnSeries.DataMarker> 
  
                         <chart:ChartDataMarker/> 
  
                </chart:ColumnSeries.DataMarker> 
  
         </chart:ColumnSeries> 
 
         <chart:LineSeries ItemsSource="{Binding NumericMonthStats1}" XBindingPath="Date" YBindingPath="Weight"/> 
    
</chart:SfChart.Series> 
  
  
  
Please check the attached sample. If you are still facing this issue, please update us the modified sample. 
  
Regards, 
Saravana Pandian M. 


Loader.
Up arrow icon