This is a migrated thread and some comments may be shown as answers.

Need example - bar chart by month not starting with January

4 Answers 92 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Digital Man
Top achievements
Rank 2
Digital Man asked on 12 Apr 2011, 08:57 PM
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.

4 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 15 Apr 2011, 07:28 AM
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.

0
Digital Man
Top achievements
Rank 2
answered on 15 Apr 2011, 03:39 PM
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.
0
Accepted
Ves
Telerik team
answered on 20 Apr 2011, 08:39 AM
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.

0
Digital Man
Top achievements
Rank 2
answered on 20 Apr 2011, 04:08 PM
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
Tags
Chart (Obsolete)
Asked by
Digital Man
Top achievements
Rank 2
Answers by
Ves
Telerik team
Digital Man
Top achievements
Rank 2
Share this question
or