4 Answers, 1 is accepted
0
Hi Gino,
We would suggest you to review this online example here that demonstrates the desired functionality. You can find more information on the MVVM approach used in the sample here.
Hope this helps.
All the best,
Manuel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
We would suggest you to review this online example here that demonstrates the desired functionality. You can find more information on the MVVM approach used in the sample here.
Hope this helps.
All the best,
Manuel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Taylor
Top achievements
Rank 2
answered on 26 May 2009, 03:23 PM
To make the original question a bit more difficult, say you wanted to do this with a stacked bar chart, so that you could individually change the color of each piece of the stack. I'm running into problems with the following code:
List<BarDataPoint> pointList = new List<BarDataPoint>(); |
pointList.Add(new BarDataPoint("MTD", 1, list[2][1].value, Color.FromArgb(255, 255, 0, 0))); |
pointList.Add(new BarDataPoint("FYTD", 2, list[2][0].value, Color.FromArgb(255, 255, 0, 255))); |
rc.DefaultSeriesDefinition = new BarSeriesDefinition() { ItemStyle = this.CustomStyle }; |
SeriesMapping mapping = new SeriesMapping(); |
mapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); |
rc.SeriesMappings.Add(mapping); |
rc.ItemsSource = pointList; |
tickPoints = rcTQISummary.DefaultView.ChartArea.AxisX.TickPoints; |
for (int i = 0; i < tickPoints.Count; i++) |
{ |
TickPoint tickPoint = tickPoints[i]; |
tickPoint.Label = pointList[i].XLabel; |
} |
This block works fine, but when trying to edit it to work with a stacked bar definition, I'm hitting a block. I don't see how to use the ItemSource definition of the chart with multiple series definitions (as you need for stacked bar charts), but if I get rid of the Item source property, I'm not sure how to bind my colors to the bar.
As a bit of background, I created the BarDataPoint to hold the YValue, XLabel, and a Brush so that the data bind would be able to find the color for the bar by binding to the BarColor property of my BarDataPoint class.
Do you guys have any examples of doing this with a stacked bar graph? I'm at a loss.
Thanks,
Taylor Smith
0
Taylor
Top achievements
Rank 2
answered on 28 May 2009, 12:50 PM
I got this working with the stacked bar chart. Basically, I created a wrapper class that held multiple BarDataPoint objects. Each of these objects represented one stacked bar and I was therefore able to change the color of each section of the bar individually from the others while still data binding to the ItemSource.
0
Dennis
Top achievements
Rank 1
answered on 16 Mar 2010, 07:11 PM
It would be nice to see your finished code. Would help me in my current situation.