XAxis Date & Time

Thread is closed for posting
3 posts, 1 answers
  1. Brett Robichaud
    Brett Robichaud avatar
    24 posts
    Member since:
    Feb 2009

    Posted 10 Apr 2009 Link to this post

    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. Answer
    Dessy
    Admin
    Dessy avatar
    73 posts

    Posted 13 Apr 2009 Link to this post

    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.
  3. Brett Robichaud
    Brett Robichaud avatar
    24 posts
    Member since:
    Feb 2009

    Posted 13 Apr 2009 Link to this post

    Thanks, that did the trick.
Back to Top