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

Using Dates for X Values

1 Answer 43 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 2
Aaron asked on 03 Aug 2010, 06:18 PM
It doesn't seem like you can use dates for X values when adding data to series programmatically.  Is that true?


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 05 Aug 2010, 11:59 AM
Hello Aaron,

We would suggest you to review this online example here that demonstrates how you can display DateTime data on the numerical axes of RadChart -- the key is to use the DateTime.ToOADate() method in order to convert the DateTime data to double values as the numerical axes work only with numeric types.

Here is a sample code snippet as well:
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 340;
RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate;
RadChart1.PlotArea.XAxis.AutoScale = false;
RadChart1.PlotArea.XAxis.AddRange(DateTime.Today.ToOADate(), DateTime.Today.AddDays(4).ToOADate(), 1);
ChartSeries series = new ChartSeries();
series.AddItem(new ChartSeriesItem(DateTime.Today.ToOADate(), 200));
series.AddItem(new ChartSeriesItem(DateTime.Today.AddDays(1).ToOADate(), 350));
series.AddItem(new ChartSeriesItem(DateTime.Today.AddDays(2).ToOADate(), 100));
series.AddItem(new ChartSeriesItem(DateTime.Today.AddDays(3).ToOADate(), 500));
series.AddItem(new ChartSeriesItem(DateTime.Today.AddDays(4).ToOADate(), 600));

Hope this helps.

the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Chart (Obsolete)
Asked by
Top achievements
Rank 2
Answers by
Telerik team
Share this question