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

Setting each Data Point Colors not the Whole DataSeries

4 Answers 175 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Gino
Top achievements
Rank 1
Gino asked on 13 May 2009, 01:39 PM

Hi,

Is there a way in RadChart specifically for BarSeries to set the color of a specific DataPoint and not the whole DataSeries? Please note that I want to retain the default style and look of the Bars.

Please help. Thank you!!!

-gino

4 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 15 May 2009, 01:28 PM
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.
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.
Tags
Chart
Asked by
Gino
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Taylor
Top achievements
Rank 2
Dennis
Top achievements
Rank 1
Share this question
or