Dynamically generating series color

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Dynamically generating series color

Post by dave » Wed May 09, 2007 6:29 am

Hi,

I've a chart with white background and if dynamically generated series. How could I make sure that the colours assigned to these series are not white? Or to have the series only using a range of colours that would go well with a white background.

Thanks.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Wed May 09, 2007 9:19 am

Hi Dave

You can do an array with your wish colors, and then when you generate a new serie also put the wish color, you can do something similar as below code:

Code: Select all

        Color[] cl;
        int cl_index;
        private void Form1_Load(object sender, EventArgs e)
        {
            cl = new Color[]
           {
               Color.Red,Color.Salmon,Color.Green,Color.Blue
           };
            cl_index = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Line line = new Line(tChart1.Chart);
            line.Color = cl[(cl_index++)%cl.Length];
            line.FillSampleValues();
        }
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Post by dave » Thu May 10, 2007 12:48 am

Thanks Edu... it works :D

Post Reply