Page 1 of 1

Dynamically generating series color

Posted: Wed May 09, 2007 6:29 am
by 9640436
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.

Posted: Wed May 09, 2007 9:19 am
by 9348258
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();
        }

Posted: Thu May 10, 2007 12:48 am
by 9640436
Thanks Edu... it works :D