This is a migrated thread and some comments may be shown as answers.

XAxis not displaying correct date

2 Answers 81 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Iron
Daniel asked on 14 May 2009, 05:01 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 18 May 2009, 06:31 AM
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.
0
Daniel
Top achievements
Rank 1
Iron
answered on 18 May 2009, 11:47 PM
Thanks Ves, your attached example did the trick.

Daniel
Tags
Chart (Obsolete)
Asked by
Daniel
Top achievements
Rank 1
Iron
Answers by
Ves
Telerik team
Daniel
Top achievements
Rank 1
Iron
Share this question
or