Colors of high level series are red!

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Albert
Newbie
Newbie
Posts: 16
Joined: Fri Nov 15, 2002 12:00 am
Location: Taipei, Taiwan, Republic of China
Contact:

Colors of high level series are red!

Post by Albert » Mon May 31, 2004 8:37 am

Hello seniors,

Have you drawn many series in a TChart? I added 25 bars (from series 0 to series 24) in a chart and it seems that there is a small problem of the colors. All colors of series 18 to series 24 are red! 8O Had you met this problem? Should I assign the color of every series by myself? Do you have any better idea for discriminating them? :?: Thanks for your suggestion. :)

Albert


If you want to reproduce this problem, you might follow the steps below.

1 Preparation:

1.1 Open the "Microsoft Visual Studio .NET 2003"
1.2 New a Visual C# Project by the template "Windows Application".
1.3 Drag a "TChart" to the "design page"
1.4 Double click the “tChart1” for adding the following code.

Code: Select all

private void Form1_Load(object sender, System.EventArgs e)
{
	System.Int32 SeriesOfChart = 25;
	System.Int32 PointsOfSeries = 3;
	Steema.TeeChart.Styles.Series sTemp;
	// add series
	for (System.Int32 i =0; i<SeriesOfChart; i++)
	{
		sTemp = this.tChart1.Series.Add(new Steema.TeeChart.Styles.Bar());
		// add data
		for (System.Int32 j = 0; j<PointsOfSeries; j++)
		{
			sTemp.Add(new System.Int32[] {i%6 + j});
		}
	}
}
2 Reproduce the situation:

2.1 Press F5 to compile and run this program.
2.2 The colors of series 18 to series 24 are red. :(

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon May 31, 2004 12:20 pm

Hi.

I think this one is a bug. Teechart has a list of pre-defined colors which are used as default colors for series. These colors are declared in Graphics3D.ColorPalette color array. Normally if there are more than 20 series, upper color limit is reached and the coloring should again start from red color (the Graphics3D.GetDefaultColor method implementation).

But obviously the internal algorithm stops at last color and uses it for all series beyond this limit. The problem is in Graphics3D.FreeSeriesColor method where the result is wrong (i.e. the Graphics3D.ColorPalette[0]) if there are more than 20 points. BTW, the same problem also happens with the VCL version (logging it to the bug list).

At the moment the workaround is to use the following code after you've added series to chart:

Code: Select all

      tChart1.Series.Clear();
      for (int i = 0 ; i< 30; i++)
      {
        tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
        tChart1.Series[i].FillSampleValues(10);
        tChart1.Series[i].Color = Steema.TeeChart.Drawing.Graphics3D.GetDefaultColor(i);
      } 
Marjan Slatinek,
http://www.steema.com

Post Reply