Page 1 of 1

Changing color between points in a series

Posted: Tue Jun 06, 2006 3:21 am
by 9640166
Hi,

Is it possible to manually change the color between points AFTER adding a series?

I know you can do it when adding a series, however I want to set the color between each point in a line series after the series has been created, ie. loop through each series on the chart, and set the color between each point.

Is this possible?

Thanks in advance.

Posted: Tue Jun 06, 2006 11:26 am
by narcis
Hi Agrilink,

Yes, you have 2 options to achieve that:

1. Using one of Add method overloads which allow a color for each series point.
2. Directly looping through all series points and accessing its ValueColor property:

Code: Select all

      for (int i = 0; i < tChart1.Series.Count; i++)
			{
        for (int j = 0; j < tChart1[j].Count; j++)
        {
          tChart1[i].ValueColor[j]=Color.FromArgb(i,j,0);
        }			 
			}

Posted: Wed Jun 07, 2006 12:27 am
by 9640166
Regarding option 2, according to the help ValueColor is a method requiring a point index and returns the color, not a property?

The code provided throws a compile error.

Thanks.

Posted: Wed Jun 07, 2006 8:16 am
by narcis
Hi Agrilink,

Yes, sorry, you should use:

Code: Select all

          tChart1[i].Colors[j] = Color.FromArgb(r, g, b);

Posted: Wed Jun 07, 2006 11:43 pm
by 9640166
Excellent. Thanks Narcis.