Need example - bar chart by month not starting with January

Thread is closed for posting
5 posts, 1 answers
  1. Digital Man
    Digital Man avatar
    126 posts
    Member since:
    Nov 2003

    Posted 12 Apr 2011 Link to this post

    I'm programmatically creating a bar chart with 2 series. The x-axis needs to be the month but different users might have different calendar years so won't always be Jan - Dec. Not sure the best way to go about this. I had it sort of working but when there's no data for most of the months the value labels were missing or floating where they shouldn't. The x-axis was displaying correctly but the values weren't.

    As I was looping through the 12 month year creating a chart item for each of the two series (current year and previous year) I was also adding a plot item like so

    rcTotalsMonth.PlotArea.XAxis.Items.Add(monthItem);


    where monthItem was just a string with the month abbreviation. From some other example I've seen

    rcTotalsMonth.PlotArea.XAxis[0].TextBlock.Text = String.Format("{0:MMM}", tPrevDate);

    but that would mean needing to tie the data to it which is what I'm not sure of.

    So if someone could give me a quick example of say, an x-axis going from "Apr" to "Mar" with currency y values that would be great. Thanks.

  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 15 Apr 2011 Link to this post

    Hi Digital Man,

    Please, find attached a small example, showing such chart.

    Best regards,
    Ves
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Digital Man
    Digital Man avatar
    126 posts
    Member since:
    Nov 2003

    Posted 15 Apr 2011 Link to this post

    Thanks. I got it partially working. However I need to do multiple series (previous year and current year). I don't believe databinding will work in this case. I'm confused with creating the chart items manually with what to set the xValue to. In your example with databinding it seems you ignore the xvalue and it just works. But in creating the chart items manually I need to supply a value for both x and y as double.
  4. Answer
    Ves
    Admin
    Ves avatar
    2926 posts

    Posted 20 Apr 2011 Link to this post

    Hi Digital Man,

    In this case you will have to resort to modifying the X axis items' text, as you have already seen. Please, find attached an updated version of the example -- this time there is no databinding, the ChartSeriesItems are added manually and the corresponding axis item text is updated.

    Regards,
    Ves
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. Digital Man
    Digital Man avatar
    126 posts
    Member since:
    Nov 2003

    Posted 20 Apr 2011 Link to this post

    Perfect. I wasn't sure what to put for the x value when creating the series. I thought it had to be the month. Thanks much!

    Dan
Back to Top