XAxis not displaying correct date

Thread is closed for posting
3 posts, 1 answers
  1. Daniel
    Daniel avatar
    184 posts
    Member since:
    Feb 2009

    Posted 14 May 2009 Link to this post

    Hi. I'm using RadChart (line) to display some KPI's. I'm assuming the chart is plotting correctly because it looks the same as an Excel spreadsheet I have. The XAxis is showing a datetime of 12/01/1899, 12/02/1900 etc. For starters, the datetime seems to force to en-US even if I set <globalization culture="en-AU" uiCulture="en-AU" /> in the web.config, which should be displaying dd/MM/yyyy. This makes the months appears as days and vice versa. Secondly, the years are totally out, reading 1899 and 1900 when they should be displaying 2007 and 2008.

    Daniel

  2. Answer
    Ves
    Admin
    Ves avatar
    2926 posts

    Posted 18 May 2009 Link to this post

    Hi Daniel,

    RadChart does not directly support DateTime values, but it does support the DateTime OLEAutomation equivalent - you can use the ToOADate() method to convert a DateTime value. So setting the X axis to show ChartValueFormat.ShortDate, the chart will convert each axis item's value  - by default these values are 1, 2, 3, etc. and these numbers represent 31/12/1899, 01/01/19000, etc.

    However, you can force the X axis values to match the dates in the underlying datasource. You need to set the DataXColumn property of the ChartSeries -- this effectively means, you will force each ChartSeriesItem's XValue property to be set with the value of this column. Note, that this column should be  numeric -- you can use the converted DateTime values. You can find an example here. You can set the AutoScale property to false and provide the range for the X axis, as shown in the example, or leave the default AutoScale=true and set the IsZeroBased property to false, so that the chart will only show the relevant range. I have attached a small example, showing this. It will work fine with different culture settings. The archive contains the output images for en-US, en-AU and de-DE cultures.

    Regards,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Daniel
    Daniel avatar
    184 posts
    Member since:
    Feb 2009

    Posted 18 May 2009 Link to this post

    Thanks Ves, your attached example did the trick.

    Daniel
Back to Top