ValueColor Index problem

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

ValueColor Index problem

Post by elmec » Thu Nov 07, 2013 1:33 am

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;

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: ValueColor Index problem

Post by elmec » Thu Nov 07, 2013 1:36 am

the attachment for ValueColor Index problem
Attachments
ValueColor.png
ValueColor.png (19.15 KiB) Viewed 12932 times

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: ValueColor Index problem

Post by elmec » Thu Nov 07, 2013 1:40 am

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?
Attachments
ValueColor2.png
ValueColor2.png (21.84 KiB) Viewed 12918 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: ValueColor Index problem

Post by Narcís » Fri Nov 08, 2013 8:29 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: ValueColor Index problem

Post by elmec » Sat Nov 09, 2013 1:27 am

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());

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: ValueColor Index problem

Post by Narcís » Mon Nov 11, 2013 8:47 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: ValueColor Index problem

Post by elmec » Mon Nov 11, 2013 10:15 am

Hello Narcís,
Thank you for your replay!

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: ValueColor Index problem

Post by elmec » Mon Nov 11, 2013 11:44 am

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?
Attachments
ValueColor.png
ValueColor.png (24.58 KiB) Viewed 12877 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: ValueColor Index problem

Post by Narcís » Mon Nov 11, 2013 12:16 pm

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 12869 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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: ValueColor Index problem

Post by elmec » Tue Nov 12, 2013 12:38 am

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!

Post Reply