Months on X-Axis for line series

3 posts, 0 answers
  1. David
    David avatar
    4 posts
    Member since:
    Sep 2010

    Posted 16 Nov 2010 Link to this post

    I'm trying to customize the X-Axis to look as attached. That means I have several area charts (which represent borders) and one dataserie with only one point (which is the current measure).

    The measure is done all along the year and I would like to know if it is possible to have on axis X one major tick per month ? As I have seen on this forum, this is not possible...

    For the moment, I use the following code, but there is always two ticks per month...
    ChartArea.AxisX.AddRange(new DateTime(year, 1, 1).ToOADate(), new  DateTime</span>(year, 12, 31).ToOADate(), 16);
    Thanks for your reply! David
  2. Ves
    Ves avatar
    2927 posts

    Posted 18 Nov 2010 Link to this post

    Hello David,

    Indeed, the X axis is linear and it accepts double values. When working with DateTime values they are again converted to doubles. However, each month contains different number of days, which makes it hard to define a step, which could ensure that every 1-st day of the month is shown.

    Please, find attached a small example. It shows how this scenario can be implemented by manually controlling the axis labels appearance. The X axis is configured with step 1, so there is a label for every day. Then, looping through the axis items, only the ones for 15-th day of each month stays visible, while others are hidden. This makes the labels appear in the middle of the month and not in its beginning, so a data point for 28-th Jan would still appear closer to Jan rather than Feb. Hope this is applicable.

    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. David
    David avatar
    4 posts
    Member since:
    Sep 2010

    Posted 19 Nov 2010 Link to this post

    Thank you very much. This is exactly what I need. I don't think anyone will see the difference with February..

    Have a nice day
Back to Top