Page 1 of 1

ValueColor Index problem

Posted: Thu Nov 07, 2013 1:33 am
by 16566869
We are using TeeChart2013RADXE4, and we have a problem when using ValueColor for TPointSeries.
Just look at the code below.

Code: Select all

	
Series2->AddXY(0, 50, "", claRed);
Series2->AddXY(10, 100, "", claBlue);

Series2->ValueColor[10] = claWhite;

Re: ValueColor Index problem

Posted: Thu Nov 07, 2013 1:36 am
by 16566869
the attachment for ValueColor Index problem

Re: ValueColor Index problem

Posted: Thu Nov 07, 2013 1:40 am
by 16566869
When I change

Code: Select all

	Series2->AddXY(0, 50, "", claRed);
	Series2->AddXY(10, 100, "", claBlue);

	Series2->ValueColor[10] = claWhite;
to

Code: Select all

	Series2->AddXY(0, 50, "", claRed);
	Series2->AddXY(10, 100, "", claBlue);

	Series2->ValueColor[9] = claWhite;
It looks working well. Why?

Re: ValueColor Index problem

Posted: Fri Nov 08, 2013 8:29 am
by narcis
Indexes at ValueColor ValueList go from 0 to Series.Count-1. If you have 10 points in the series, to index the last one you must use 9 as its index.

Re: ValueColor Index problem

Posted: Sat Nov 09, 2013 1:27 am
by 16566869

Code: Select all

	// Series1 is a TPointSeries
	// Add two points to Series1
	Series1->AddXY(0, 50, "", claRed);    // Point1 having the index of 0
	Series1->AddXY(10, 100, "", claBlue); // Point2 having the index of 10

	ShowMessage(Series1->Count());  // 2 points

	// Question1: As you say,ValueColor ValueList indexs from 0,
	// so the line below should change the color of Point2,
	// but as the screenshot shown, another point was added at the index of Ponit2,
	Series1->ValueColor[10] = claWhite;

	// Count() = 11 points.
	//  Question2: the 'ValueColor' goes to change the number of Series?
	ShowMessage(Series1->Count());

Re: ValueColor Index problem

Posted: Mon Nov 11, 2013 8:47 am
by narcis
Hello,
ShowMessage(Series1->Count()); // 2 points
Count has a value of 2. So, valid indexes in the series are: 0 and 1.
// Question1: As you say,ValueColor ValueList indexs from 0,
// so the line below should change the color of Point2,
// but as the screenshot shown, another point was added at the index of Ponit2,
Series1->ValueColor[10] = claWhite;
To change the color of the second point you should use.

Code: Select all

   Series1->ValueColor[1] = claWhite;[/quote]
If you use an invalid index it adds sequential values up to this point with Y value being 0.
// Count() = 11 points.
// Question2: the 'ValueColor' goes to change the number of Series?
ShowMessage(Series1->Count());
That changes the number of points in the series. You may want to check that the indices you are using are between the 0 and Series1->Count()-1 range.

Re: ValueColor Index problem

Posted: Mon Nov 11, 2013 10:15 am
by 16566869
Hello Narcís,
Thank you for your replay!

Re: ValueColor Index problem

Posted: Mon Nov 11, 2013 11:44 am
by 16566869
Hello Narcís,
One more question.
If you use an invalid index it adds sequential values up to this point with Y value being 0.
As shown in the attachment, the legend is showing that
there are 11 points (from 0 to 10),
and the 10th point (index=9) is 100(blue point),
but why it is shown at the index of 10 in chart?

Re: ValueColor Index problem

Posted: Mon Nov 11, 2013 12:16 pm
by narcis
Hi elmec,

An image will be more helpful to explain it. Look at the Data tab in the chart editor for your chart:
ElmecData.jpg
ElmecData.jpg (58.29 KiB) Viewed 12767 times
In your code you start adding two points: X=0 and X=10. Then, you modify the 11th point in the series (index 10), this creates missing sequential points starting at 2 since there are 2 existing points in the series. TeeChart counts the number of points that will be necessary, 9 points, and adds them with Y=0. Hence points with indices: 2, 3, 4, 5 ,6, 7, and 10, are added. You change the color of the 11th point (X=10, Y=0 and Color=White) but it is also plot at 10 due to the sequential index generated.

Hope my explanation and the image helps you understand what's going on.

Re: ValueColor Index problem

Posted: Tue Nov 12, 2013 12:38 am
by 16566869
Hello Narcís,
I got your explanation.
But maybe it is easily understood by adding the points according to the X axis.

Anyway ,it's my advice.
Thank you!