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.
Unfortunately, activation email could not send to your email. Please try again.

Y axis values are not appearing using ChartDataPoint Binding

Thread ID:

Created:

Updated:

Platform:

Replies:

131851 Jul 31,2017 06:29 AM Aug 1,2017 09:32 AM Xamarin.Forms 1
loading
Tags: SfChart
Emil
Asked On July 31, 2017 06:29 AM

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>


Saravana Pandian Murugan [Syncfusion]
Replied On August 1, 2017 09:32 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;