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

How to change series colour

7 Answers 113 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Guy
Top achievements
Rank 1
Guy asked on 31 Jan 2012, 03:58 PM
Hi,

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

Sort by
0
Siva
Top achievements
Rank 1
answered on 01 Feb 2012, 10:13 AM
-
0
Peshito
Telerik team
answered on 03 Feb 2012, 10:43 AM
Hello,

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).

0
Guy
Top achievements
Rank 1
answered on 03 Feb 2012, 02:08 PM
Hello Peshito,

Here is a link to download the example (as I can't attach it here).

Chart Test

Many thanks,

Guy
0
Accepted
Peshito
Telerik team
answered on 08 Feb 2012, 09:42 AM
Hello,

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
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Guy
Top achievements
Rank 1
answered on 08 Feb 2012, 10:05 AM
Morning Peshito,

Many thanks for your help!

Regards,

Guy
0
deepak
Top achievements
Rank 1
answered on 10 Mar 2016, 11:46 AM

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));

0
Dimitar
Telerik team
answered on 10 Mar 2016, 12:14 PM
Hi Deepak,

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
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Chart (obsolete as of Q1 2013)
Asked by
Guy
Top achievements
Rank 1
Answers by
Siva
Top achievements
Rank 1
Peshito
Telerik team
Guy
Top achievements
Rank 1
deepak
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or