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

How do change to the color of a bar series programmatically?

1 Answer 395 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Louay Jabry
Top achievements
Rank 1
Louay Jabry asked on 02 Apr 2012, 05:13 PM

I need to programmatically create my barseries and assign a different color of my choosing for each series. In Line series, it is easy. I set the Stroke color. I couldn't find anything equivalent for the bar series.

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 03 Apr 2012, 03:35 PM
Hello Louay,

You can achieve the desired appearance by setting the BarSeries.DefaultVisualStyle property like this:
BarSeries series = new BarSeries();
series.DataPoints.Add(new CategoricalDataPoint() { Category = "C1", Value = 11 });
series.DataPoints.Add(new CategoricalDataPoint() { Category = "C2", Value = 5 });
series.DataPoints.Add(new CategoricalDataPoint() { Category = "C3", Value = 7 });
series.DataPoints.Add(new CategoricalDataPoint() { Category = "C4", Value = 17 });
 
Style style = new Style(typeof(Border));
style.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(Colors.LightGray)));
series.DefaultVisualStyle = style;
 
RadChart1.Series.Add(series);

Hope this helps.


Regards,
Giuseppe
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ChartView
Asked by
Louay Jabry
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or