Page 1 of 1
Surface Series from multiple line series?
Posted: Thu Jan 20, 2005 8:27 am
by 9337351
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.
Posted: Thu Jan 20, 2005 11:20 am
by Marjan
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).
Posted: Thu Jan 20, 2005 11:28 am
by narcis
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;
Posted: Fri Jan 21, 2005 2:22 pm
by 9333098
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 ?
Posted: Sun Jan 23, 2005 3:58 pm
by Marjan
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.