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

Individual Colors to Bars

2 Answers 30 Views
Chart
This is a migrated thread and some comments may be shown as answers.
wael
Top achievements
Rank 1
wael asked on 02 Feb 2015, 11:21 PM
How Do I Assign Individual Colors to Bars?


i want to do something like that 

http://www.telerik.com/help/aspnet-ajax/chart-how-to-assign-individual-colors-to-bars.html

from code behind in silverlight

there is my sample code 

 Telerik.Windows.Controls.RadChart chart = new Telerik.Windows.Controls.RadChart();
 chart.PaletteBrushes = new BrushCollection();
                                chart.PaletteBrushes.Add(new SolidColorBrush() { Color = Colors.Orange });
                                chart.PaletteBrushes.Add(new SolidColorBrush() { Color = Colors.Green });
                                chart.PaletteBrushes.Add(new SolidColorBrush() { Color = Colors.Orange });
                                chart.PaletteBrushes.Add(new SolidColorBrush() { Color = Colors.DarkGray });
  DataSeries barSeries=new DataSeries();
                                foreach (Indicator ind in cd.Indicators)
                                {

                                   
                                        barSeries.Add(new DataPoint() { YValue = double.Parse(ind.value), XCategory = ind.Name });
                                        barSeries.LegendLabel = ind.Name;
                                        
                                        
                                    
                                }
 int colorindex = 0;
                              foreach (var bar in barSeries)
                                            {
                                                BarSeriesDefinition bardef = new BarSeriesDefinition();
                                                bardef.Appearance.Fill = chart.PaletteBrushes[colorindex];
                                                bar.DataItem = bardef;
                                                colorindex++;
                                            }
 chart.DefaultView.ChartArea.DataSeries.Add(barSeries);


2 Answers, 1 is accepted

Sort by
0
wael
Top achievements
Rank 1
answered on 02 Feb 2015, 11:25 PM
this sample code return all bars with the first color in PaletteBrushes
0
Peshito
Telerik team
answered on 03 Feb 2015, 10:12 AM
Hello,

You can check out our online help topic on how to have a custom item style. Furthermore this is related with the older chart control of ours. We have a newer one - RadChartView. If you haven't, I suggest you to try it out as our efforts are focused on the newer control.

Regards,
Peshito
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart
Asked by
wael
Top achievements
Rank 1
Answers by
wael
Top achievements
Rank 1
Peshito
Telerik team
Share this question
or