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

How to do a X Axis Range for Dates

2 Answers 64 Views
Chart
This is a migrated thread and some comments may be shown as answers.
chris
Top achievements
Rank 1
chris asked on 09 Sep 2011, 08:28 PM
Hello everyone,

I am trying to have a Range of 14 days as my X Axis for my Chart Control. The AddRange() only takes doubles, so is there a different method that I can use to get a Range from 13 days ago all the way up to and including Today? If anyone can help that would be great.

Thank you,
Chris

2 Answers, 1 is accepted

Sort by
0
Accepted
Missing User
answered on 14 Sep 2011, 01:20 PM
Hi Chris,

DataPoint.XValue is of type double. Therefore, the DateTime values have to be converted to OLE Automation dates first, by the DateTime.ToOADate() method. For example:
double min = DateTime.Today.AddDays(-13).ToOADate();
double max = DateTime.Today.ToOADate();
double step = DateTime.Today.ToOADate() - DateTime.Today.AddDays(-1).ToOADate();
 
radChart.DefaultView.ChartArea.AxisX.AddRange(min, max, step);

Also, the AxisX.IsDateTime property should be set to True. For additional information on "DateTime Support", please refer to the following help topic:
http://www.telerik.com/help/wpf/radchart-features-datetime-support.html

I hope this information helps.

Greetings,
Polina
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
chris
Top achievements
Rank 1
answered on 14 Sep 2011, 04:42 PM
Thank you very much, This solved my problem.

Telerik has the best support on the web.
Tags
Chart
Asked by
chris
Top achievements
Rank 1
Answers by
Missing User
chris
Top achievements
Rank 1
Share this question
or