Date on x-axis with 1 month step

2 posts, 0 answers
  1. rajesh
    rajesh avatar
    5 posts
    Member since:
    Jun 2011

    Posted 04 Jan 2012 Link to this post

    I am trying to plot a chart where datapoint ( x, y ) are as-
    (datetime, number)

    datetime is always in the format of "01-Month-Year"  i.e.  date part is always first of month
    While adding X-axis range I am trying to use-

    RadChart.PlotArea.XAxis.AddRange(dtBegin.ToOADate(), dtEnd.ToOADate(), 31);

     

    RadChart.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Inside;
    RadChart.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate;
    RadChart.PlotArea.XAxis.Appearance.CustomFormat = "dd MMM yyyy";
    RadChart.PlotArea.XAxis.AddRange(dtBegin.ToOADate(), dtEnd.ToOADate(), 31);


    The problem with above code  is that steps of 31 means that  since not all month has 31 days we will end up with x-axis data point which will not  be in 01-Month-Year format.

    what I want on x-axis is like this

    01-Nov-2010
    01-Dec-2010
    01-Jan-2011
    01-Feb-2011
    01-Mar-2011
    01-Apr-2011
    01-May-2011
    01-Jun-2011
    01-Jul-2011
    01-Aug-2011
    01-Sep-2011
    01-Oct-2011
    01-Nov-2011
    01-Dec-2011
    01-Jan-2012
    01-Feb-2012
    01-Mar-2012
    01-Apr-2012
    01-May-2012
    01-Jun-2012
    01-Jul-2012
    01-Aug-2012
    01-Sep-2012
    01-Oct-2012

     what I get is something as shown in attached image.

    How can I add date alone x-axis with steps of 1 month.


  2. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 05 Jan 2012 Link to this post

    Rajesh:

    I do not believe it's possible to accomplish x-axis data points to display in the format you require. There's a suggested workaround in the Adding 1 Month Intervals to Chart X-Axis Range forum thread, if you've not already seen it.

    Hope this helps.

  3. DevCraft Release
Back to Top