Surface Series from multiple line series?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
NREL
Newbie
Newbie
Posts: 10
Joined: Fri May 07, 2004 4:00 am

Surface Series from multiple line series?

Post by NREL » Thu Jan 20, 2005 8:27 am

Is it possible to create a SurfaceSeries from multiple LineSeries?

If I have LineSeries1 and LineSeries2 both with same X values, can I create a SurfaceSeries that has these values with Z=1 and Z=2; that is,

Given
LineSeries1 constructed by:
LineSeries1.AddXY(X1,Y1)

LineSeries2 constructed by:
LineSeries2.AddXY(X1,Y2)

Is thers a function so that SurfaceSeries = LineSeries1 (z=1) x LineSeries2 (z=2)

I would like to be able to switch from a family of curves to a surface plot quickly without having to reformat the data.

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

Post by Marjan » Thu Jan 20, 2005 11:20 am

Hi.
Is it possible to create a SurfaceSeries from multiple LineSeries?
Yes, providing all series have the same number of points and (more importantly), all series have the same x values. If this condition is satisfied, you can use TSurfaceSeries.AddXYZ method to add points from individual series. Example

Code: Select all

surface1.Clear;
for i:= Low(X1) to High(X1) do surface1.AddXYZ(X1[i],Y1[i],1.0);
for i:= Low(X1) to High(X1) do surface1.AddXYZ(X1[i],Y2[i],1.0);
You can also copy the values directly from series XValues and Yvalues list(s).
Marjan Slatinek,
http://www.steema.com

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

Post by Narcís » Thu Jan 20, 2005 11:28 am

Hi NREL,

As an example, you can place a Chart with a Surface Series on a form, a button and do something like:

Code: Select all

  private
    { Private declarations }
    XValues: array[0..19] of double;
    YValues: array[0..19] of double;
    ZValues: array[0..19] of double;
    flag: boolean;

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  count,i: integer;
  X,Y,Z: integer;
begin
    count:=0;
    flag:=false;

    Randomize;

    for X := 0 to 9 do
      for Z := 0 to 1 do
      begin
        Y := Random(100);
        XValues[count] := X;
        ZValues[count] := Z;
        YValues[count] := Y;
        inc(count);
      end;

    for i:=0 to 19 do
      series1.AddXYZ(XValues[i], YValues[i], ZValues[i]);

		Chart1.Axes.Depth.Visible := true;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  count,i,j: integer;
  X,Z: integer;
  Surface: TSurfaceSeries;
begin
  count:=0;
  Chart1.RemoveAllSeries;
  flag := not flag;
  if (flag) then
  begin
    for i:=0 to 1 do
      Chart1.AddSeries(TLineSeries);

    for X:=0 to 9 do
      for Z:=0 to 1 do
      begin
        Chart1[1-Z].AddXY(X, YValues[count]);
        inc(count);
      end;
  end
  else
  begin
    Surface:=TSurfaceSeries.Create(self);
    Chart1.AddSeries(Surface);
    for j:=0 to 19 do
      Surface.AddXYZ(XValues[j], YValues[j], ZValues[j]);
  end;
end;
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

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Fri Jan 21, 2005 2:22 pm

In the LineSeries view, can the depth of each individual line be made only 1 pixel (like if viewed in 2D) instead of being a ribbon whose width equals the spacing between each series on the depth axis ?

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

Post by Marjan » Sun Jan 23, 2005 3:58 pm

Hi, Steve.

Yes, sure. Use the following code:

Code: Select all

  Series1.Depth := 0;
  Series1.LinePen.Color := clRed;
  Series2.Depth := 0;
  Series2.LinePen.Color := clGreen;
Or alternatively, simply switch from line to fastline series.
Marjan Slatinek,
http://www.steema.com

Post Reply