Monthly X Axis for Daily Series Data

2 posts, 0 answers
  1. Michael
    Michael avatar
    9 posts
    Member since:
    Jul 2011

    Posted 28 Sep 2011 Link to this post

    Hi, I am using RadControls for WinForms SP2 (Q2 2010) and trying to render a stock price line chart, of which each price is a daily price. The prices are rendering ok however I have an issue with the x axis which I believe is affecting how the data is ultimately rendered.


    Each item in the series is a daily price for the given stock, along with the date on which the price relates to.  On the X axis we want to just show monthly points, so for our example where we are rendering a chart of daily stock prices, each axis label on the x axis would show the month (Jan, Feb, Mar etc). The code we are using ( to set the x axis label is:


    chrtVBA.PlotArea.XAxis.AddRange(xMin, xMax, 30)


    …where xMin and xMax are the minimum and maximum dates in the series (converted using .ToOADate()).


    As you can see, we are specifying 30 as the step value, however I beleive that because there aren’t 30 days in every month the X axis labels becomes out of sync with the plotted points. Is there a specific method to call or property we can set so that the x axis correctly shows the correct month?


    I have attached an example of what the chart currently looks like, we have checked the stock prices and they do appear to be out of sync with the x axis, for example a price which appears to be for late August on the rendered chart should be showing for early September. For information; the xMin and xMax values used to render this chart were 09/12/2010 and 09/12/2011 respectively (not We did call .ToOADate() to convert.

    Thanks for you help.


  2. Peshito
    Peshito avatar
    493 posts

    Posted 03 Oct 2011 Link to this post

    Hello Michael,

    Thank you for contacting Telerik Support and for the details provided.
    Since the months have different number of days it is practically impossible to set an intelligent accurate step of 1 month. You can set a step of 1 day and wire the BeforeLayout event where you can iterate through the XAxis.Items and show only the first day of a month.

    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft R3 2016 release webinar banner
Back to Top