Chart do not work with date

2 posts, 0 answers
  1. Paulo
    Paulo avatar
    56 posts
    Member since:
    Apr 2012

    Posted 20 Mar 2013 Link to this post

    I have a range of dates. My chart needs to start on a certain date, but is beginning on the first date of the Xaxis. How do I get in a certain specific date?
  2. Petar Kirov
    Petar Kirov avatar
    425 posts

    Posted 25 Mar 2013 Link to this post

    Hi Paulo,

    The ASP.NET RadChart uses the OADate format to visualize DateTime data. This means that in order to set a manual X axis range, you will need to convert DateTime values to OADate first: 
    double startDateInOA = new DateTime(2013, 1, 1).ToOADate();
    double endDateInOA = new DateTime(2013, 5, 1).ToOADate();
    double step = 1; // one day in OADate format
    radChart.PlotArea.XAxis.AutoScale = false;
    radChart.PlotArea.XAxis.AddRange(startDateInOA, endDateInOA, step);

    Additionally to make the RadChart visualize the X axis labels in DateTime format, you can set the Value format of the axis to one of the DateTime options: 
    radChart.PlotArea.YAxis.Appearance.ValueFormat =

    By default the RadChart's axes are zero based. This means when AutoScale is true, the first date displayed will be 0.0 which in OADate format is 30 Dec 1899. To change that, you can set radChart.PlotArea.XAxis.IsZeroBased to false.

    I hope this helps.

    Petar Kirov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top