I'm trying to programmatically change the fill colour of the series on my chart and for some reason I'm not getting it to work.
This is the code I'm currently using.
radChart1.SkinsOverrideStyles =
false
;
chartSeries.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Gradient;
chartSeries.Appearance.FillStyle.FillSettings.GradientMode = Telerik.Charting.Styles.GradientFillStyle.Horizontal;
chartSeries.Appearance.FillStyle.MainColor = Color.FromArgb(255, 55, 96, 145);
chartSeries.Appearance.FillStyle.SecondColor = Color.FromArgb(255, 184, 204, 228);
radChart1.UpdateGraphics();
Obviously I'm either missing something or the above code is completely wrong, can someone help please?
Regards,
Guy
7 Answers, 1 is accepted

This is the correct way of setting the series color.
I tried to reproduce your issue using the same code as you did, but it worked fine and the color was changed successfully. In order for us to determine what is causing this issue, could you try to attach a sample runnable project pointing out the problem. This way we will be able to provide you with an appropriate solution to this issue.
Kind regards,
Peshito
the Telerik team
SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Here is a link to download the example (as I can't attach it here).
Chart Test
Many thanks,
Guy
Thank you for providing us with your sample.
Some of the RadChart's Skins are more complex than others and the palette overrides the Gradient Filltype. In such cases you should use the ComplexGradient FillType like this for example:
// Chart styling
radChart1.SkinsOverrideStyles =
false
;
chartSeries.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.ComplexGradient;
chartSeries.Appearance.FillStyle.FillSettings.GradientMode = Telerik.Charting.Styles.GradientFillStyle.Horizontal;
chartSeries.Appearance.FillStyle.FillSettings.ComplexGradient.Add(
new
GradientElement(Color.FromArgb(255, 55, 96, 145), 0));
chartSeries.Appearance.FillStyle.FillSettings.ComplexGradient.Add(
new
GradientElement(Color.FromArgb(255, 184, 204, 228), 1));
This is edited code snippet from your project so following the above approach should change your series' color.
Hope this helps.
Greetings,
Peshito
the Telerik team

Many thanks for your help!
Regards,
Guy

I tried the below code,but it doesn't work.I'm using the latest version o telerik reporting,in that i can't set "radChart1.SkinsOverrideStyles" .can someone please help
// Chart styling
radChart1.SkinsOverrideStyles = false;
chartSeries.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.ComplexGradient;
chartSeries.Appearance.FillStyle.FillSettings.GradientMode = Telerik.Charting.Styles.GradientFillStyle.Horizontal;
chartSeries.Appearance.FillStyle.FillSettings.ComplexGradient.Add(new GradientElement(Color.FromArgb(255, 55, 96, 145), 0));
chartSeries.Appearance.FillStyle.FillSettings.ComplexGradient.Add(new GradientElement(Color.FromArgb(255, 184, 204, 228), 1));
Thank you for writing.
The Chart control is now obsoleted and replaced by the new ChartView. The following snippet shows how you can change the series color:
BarSeries series = new BarSeries();
series.BorderColor = Color.Red;
series.BackColor = Color.Yellow;
Let me know if you have additional questions.
Regards,
Dimitar
Telerik