Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Chart > How to change series colour

Answered How to change series colour

Feed from this thread
  • Guy avatar

    Posted on Jan 31, 2012 (permalink)

    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

    Reply

  • Siva avatar

    Posted on Feb 1, 2012 (permalink)

    -

    Reply

  • Peshito Peshito admin's avatar

    Posted on Feb 3, 2012 (permalink)

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

    Reply

  • Guy avatar

    Posted on Feb 3, 2012 (permalink)

    Hello Peshito,

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

    Chart Test

    Many thanks,

    Guy

    Reply

  • Answer Peshito Peshito admin's avatar

    Posted on Feb 8, 2012 (permalink)

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

    Reply

  • Guy avatar

    Posted on Feb 8, 2012 (permalink)

    Morning Peshito,

    Many thanks for your help!

    Regards,

    Guy

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Chart > How to change series colour
Related resources for "How to change series colour"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]