How to draw the contour?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
steven zheng
Newbie
Newbie
Posts: 12
Joined: Sun Oct 31, 2004 4:00 am
Location: china

How to draw the contour?

Post by steven zheng » Sun Jul 29, 2007 7:25 am

HI
I have three arrays---Long, Lati, and Temperatuer.
I want to contouer on the Temperatuer.

I have done these code:

ContourSeries: TContourSeries;
.
.
.

With ContourSeries do
begin
Clear;
for i:=0 to 50 do
AddXYZ( Long,Temp ,Lati, '', clTeeColor);
end;


It doesn't work, anything wrong?
Please help me.

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Post by xxxxxx » Sun Jul 29, 2007 7:36 am

If you create ContourSeries in your code manually you need something like this

Code: Select all

ContourSeries.ParentChart:=YourChart;

Do you use Chart Editor at all or maybe you do not have TChart component on your form?
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009

steven zheng
Newbie
Newbie
Posts: 12
Joined: Sun Oct 31, 2004 4:00 am
Location: china

Post by steven zheng » Sun Jul 29, 2007 2:58 pm

I don't create the ContourSeries manually.
I find Teechart Demo use the two loop to add these data.
Why?[/quote]

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

Post by Marjan » Sun Jul 29, 2007 3:03 pm

For contour series you need 2d regular or irregular grid data. This is why you need two y=y(x,z) variables i.e. two for loops to populate the series. In case your data is not arranged as grid data, you'll first have to create grid data and then pass it to series using:

Code: Select all

for i := 0 to NumCellsGridX -1 do
  for j := 0 to NumCellsGridZ-1 do
   ContourSeries1.AddXYZ(i,y[i,j],j);
where i,j are data x,z grid indexes (in your case long, latt) and y[i,j] is data you're trying to plot (in your case temperature).
Marjan Slatinek,
http://www.steema.com

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Post by xxxxxx » Sun Jul 29, 2007 4:13 pm

Hi, zheng!
In your case it seems you try to plot isotherms in geographical coordinates, therefore your Lat and Long array have to produce some grid. Isn't so?
I advice you to use Chart Editor in run-time with EditChart procedure and explore your series in run-time.
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009

steven zheng
Newbie
Newbie
Posts: 12
Joined: Sun Oct 31, 2004 4:00 am
Location: china

Post by steven zheng » Mon Jul 30, 2007 4:05 am

Marjan wrote:For contour series you need 2d regular or irregular grid data. This is why you need two y=y(x,z) variables i.e. two for loops to populate the series. In case your data is not arranged as grid data, you'll first have to create grid data and then pass it to series using:

Code: Select all

for i := 0 to NumCellsGridX -1 do
  for j := 0 to NumCellsGridZ-1 do
   ContourSeries1.AddXYZ(i,y[i,j],j);
where i,j are data x,z grid indexes (in your case long, latt) and y[i,j] is data you're trying to plot (in your case temperature).
Thanks for your reply,In my case I only have one temperature data at one long and one lati.But In your program, I should get all temperature data at same long and different lati.I am not sure I make it clear.I wll give one table, that will be more clear.

Now I have three datas,Table 1
Long 100 102 103 104 105 106
Lati 94 96 98 91 90 84
Temp 23 25 26 20 29 21

You require datas, Table 2
Long 100 100 100 100 100 100 102 102 102 102 102 102 103 103 103 103 103 103...
Lati 94 96 98 91 90 84 94 96 98 91 90 84 94 96 98 91 90 84...
Temp 23 X X X X X 25 X X X X X 26 X X X X X...
these X datas I miss, How to get them?

steven zheng
Newbie
Newbie
Posts: 12
Joined: Sun Oct 31, 2004 4:00 am
Location: china

Post by steven zheng » Mon Jul 30, 2007 4:14 am

Hi,Alexander
Thanks for your reply.
I really will plot isotherms in geographical coordinates.
9047589 wrote:your Lat and Long array have to produce some grid. Isn't so?
How to produce the grid by Lat and Long?

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Post by xxxxxx » Mon Jul 30, 2007 10:25 am

Well, you have produce 3D array. Better to have regular grid, i.e. without missing data, but it's not mandatory. It seems you have data only for one latitude - it's not enough for grid.
One example for you:
X Y Z
90 24.919 100
92 24.9392 100
94 24.9594 100
96 24.9796 100
98 24.9998 100
90 24.9372 102
92 24.9578 102
94 24.9784 102
96 24.999 102
98 25.0196 102
90 24.9554 104
92 24.9764 104
94 24.9974 104
96 25.0184 104
98 25.0394 104
90 24.9736 106
92 24.995 106
94 25.0164 106
96 25.0378 106
98 25.0592 106
90 24.9918 108
92 25.0136 108
94 25.0354 108
96 25.0572 108
98 25.079 108

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

Post by Marjan » Mon Jul 30, 2007 2:32 pm

9339728 wrote: Thanks for your reply,In my case I only have one temperature data at one long and one lati.But In your program, I should get all temperature data at same long and different lati.I am not sure I make it clear.I wll give one table, that will be more clear.

Now I have three datas,Table 1
Long 100 102 103 104 105 106
Lati 94 96 98 91 90 84
Temp 23 25 26 20 29 21

You require datas, Table 2
Long 100 100 100 100 100 100 102 102 102 102 102 102 103 103 103 103 103 103...
Lati 94 96 98 91 90 84 94 96 98 91 90 84 94 96 98 91 90 84...
Temp 23 X X X X X 25 X X X X X 26 X X X X X...
these X datas I miss, How to get them?
For contour series having a grid data is mandatory. For missing grid points you can generate data points by using simple (linear should do the trick) interpolation. I think TeeChart demo has an example of this: check the Surface Gridding node. It moreless does exactly what you need - creates 2d grid array from arbitrary y=y(x,z) data points.
Marjan Slatinek,
http://www.steema.com

Post Reply