Charts with DateTimeCategory..

Hi,

I am trying to create a chart with DateTimeCategoryAxis where all data points are plotted with equal spaces per the description here - https://help.syncfusion.com/xamarin-android/sfchart/axis#date-time-category-axis . So, I modified your sample from here https://help.syncfusion.com/xamarin-android/sfchart/getting-started

Instead of a CategoryAxis - 

CategoryAxis primaryAxis = new CategoryAxis();
primaryAxis.Title.Text = "Name";
chart.PrimaryAxis = primaryAxis;

I initialized a DateTimeCategoryAxis -

DateTimeCategoryAxis primaryAxis = new DateTimeCategoryAxis();
primaryAxis.Title.Text = "Name";
primaryAxis.LabelStyle.LabelFormat = "d/MMM/yy";           
chart.PrimaryAxis = primaryAxis;

I also modified the Model and the ViewModel to -

public DateTime Name { get; set; }
public double Height { get; set; }

 public Person(DateTime name, double height)
{
      Name = name;
      Height = height;
}

public class ViewModel
    {
        public ObservableCollection<Person> Data { get; set; }

        public ViewModel()
        {
            Data = new ObservableCollection<Person>();
           
             //Data.Add(new Person("David", 180));
            //Data.Add(new Person("Michael", 170));
            //Data.Add(new Person("Steve", 160));
            //Data.Add(new Person("Joel", 182));
          
            Data.Add(new Person(new DateTime(1998, 03, 03), 10));
            Data.Add(new Person(new DateTime(1998, 04, 03), 10));
            Data.Add(new Person(new DateTime(1999,05,03), 15));
            Data.Add(new Person(new DateTime(2018, 10, 03), 95));
        }
    }

Now, if the dates are in order (1998,1998,1999,2016), the chart works just great. Please refer to the pic named dates_in_order.

Now if the I add another date - lets say from 2005 -

            Data.Add(new Person(new DateTime(1998, 03, 03), 10));
            Data.Add(new Person(new DateTime(1998, 04, 03), 10));
            Data.Add(new Person(new DateTime(1999, 05,03), 15));
            Data.Add(new Person(new DateTime(2016, 10, 03), 95));
             Data.Add(new Person(new DateTime(2005, 10, 03), 105));

Please refer to the pic named dates_not_in_order.

There are two issues -
1) It does not create a new column between 1999 and 2016, but creates a column at the end after 2016. Any added data after 2005 - it treats the same way. Shouldn't the columns be with the dates in order - 1998, 1998, 1999, 2005, 2016, instead of 1998, 1998, 1999, 2016, 2005
2) The column does not have the appropriate label.

I am planning to pull data from a sqlite database and the dates are not sorted in anyway. I was under the assumption that when I use DateTimeCategoryAxis they will automatically place the dates in order just like one would expect when I use DateTimeAxis(). Please see third pic attached - dates_not_in_order_DateTimeAxis which looks quite ugly but the dates are in order. 

Am I doing something wrong? Can you please modify your sample to include DateTimeCategory? If this is the way it normally behaves do you have any solutions in mind where I can keep equal spacing between different columns?

Thanks & Regards.

Attachment: date_time_category_cb2357b0.zip

2 Replies

MP Michael Prabhu M Syncfusion Team August 14, 2018 10:43 AM UTC

  
Hi Sachin, 
 
Sorry for the delay in getting back at this, we were able to reproduce the reported issue “DateTimeCategory axis is not sorting the data linearly” at our end. And we have logged a defect report regarding the same. A support incident to track the status of this defect has been created under your account.  
Please log on to our support website to check for further updates. 
http://www.syncfusion.com/Account/Logon?ReturnUrl=%2fsupport%2fdirecttrac/  
Thanks, 
Michael 



SA Saachinj August 14, 2018 11:40 AM UTC

Great. Thanks.

Regards,

Sachin.

Loader.
Up arrow icon