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

[Solved] XAxis Date & Time

2 Answers 189 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Brett Robichaud
Top achievements
Rank 1
Brett Robichaud asked on 10 Apr 2009, 03:41 PM
I have a datasource that includes an undetermined time range. Because of this I need to display both Date & Time in the xAxis labels. I have seen the various posts on including date or time but don't see how I would include both. In my own code I currently can toggle between showing date or time by simply toggling the ValueFormat as seen below. How can I show both?

 

_chart.AutoLayout = true;  
_chart.PlotArea.XAxis.IsZeroBased = false;  
_chart.PlotArea.XAxis.Appearance.ValueFormat = ChartValueFormat.ShortTime;  
_chart.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 320

2 Answers, 1 is accepted

Sort by
0
Accepted
Dessy
Telerik team
answered on 13 Apr 2009, 02:33 PM
Hi Brett Robichaud,

In order to display both date and time values, you will need to use two properties - ValueFormat property and CustomFormat property. You need to set the ValueFormat property to a value, indicating that the axis will show DateTime values (e.g. ShortDate, ShortTime, etc.). Then you can set the CustomFormat property with a valid standard or custom DateTime format string, as described here:

http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

Here is an example illustrating this:

RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;  
RadChart1.PlotArea.XAxis.Appearance.CustomFormat = "s"


Hope that helps.

All the best,
Dessy
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Brett Robichaud
Top achievements
Rank 1
answered on 13 Apr 2009, 10:33 PM
Thanks, that did the trick.
Tags
Chart (Obsolete)
Asked by
Brett Robichaud
Top achievements
Rank 1
Answers by
Dessy
Telerik team
Brett Robichaud
Top achievements
Rank 1
Share this question
or