How to change series colour

8 posts, 1 answers
  1. Guy
    Guy avatar
    60 posts
    Member since:
    Sep 2010

    Posted 31 Jan 2012 Link to this post

    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
  2. Siva
    Siva avatar
    3 posts
    Member since:
    Feb 2012

    Posted 01 Feb 2012 Link to this post

    -
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peshito
    Admin
    Peshito avatar
    496 posts

    Posted 03 Feb 2012 Link to this post

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

  5. Guy
    Guy avatar
    60 posts
    Member since:
    Sep 2010

    Posted 03 Feb 2012 Link to this post

    Hello Peshito,

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

    Chart Test

    Many thanks,

    Guy
  6. Answer
    Peshito
    Admin
    Peshito avatar
    496 posts

    Posted 08 Feb 2012 Link to this post

    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 >>
  7. Guy
    Guy avatar
    60 posts
    Member since:
    Sep 2010

    Posted 08 Feb 2012 Link to this post

    Morning Peshito,

    Many thanks for your help!

    Regards,

    Guy
  8. deepak
    deepak avatar
    3 posts
    Member since:
    Nov 2015

    Posted 10 Mar in reply to Peshito Link to this post

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

  9. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 10 Mar Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready