TChartSeries.AddArray
 
 
 

All Units  All Classes  Properties, Methods and Events  

TChartSeries.AddArray
TChartSeries

function AddArray(Const Values: array of TChartValue): Integer; overload;

Unit
TeEngine

Description
The Series AddArray method may be used to add an array of data directly to the Series.

Example

Series3.Clear;
Series3.AddArray([ 1234, 2001, 4567.12 ] );

AddArray does not Clear the Series before adding points.

You can express points as constants or variables:

Series3.AddArray([ Table1Sales.AsFloat, 123, MyTotal ] );


Assigning an array directly to a Series valueList

You may assign an array directly to a Series ValueList without using the AddArray method to pass the values. To add an array of data to a Chart Series simply allocate the array to the Series.

This example uses the TChartValues definition in TeeChart's Teengine unit:

TChartValue=Double; { <-- default }
TChartValues=Array of TChartValue;

TChartValue may be modified to use Extended or Single as data type
. See inside TeeDefs.inc file.



Example

\fi-360\li\tx\tx\tx
procedure TDynArrays.Button1Click(Sender: TObject);
Var X,Y : Array of Double; // TChartValues
t : Integer;
Num : Integer;
begin
{ number of points here using an Editbox to set Array size}
Num:=StrToInt(Edit1.Text);

{ allocate our custom arrays }
SetLength(X,Num);
SetLength(Y,Num);

{ fill data in our custom arrays }
X[0]:=0;
Y[0]:=Random(10000);
for t:=1 to Num-1 do
begin
X[t]:=t;
Y[t]:=Y[t-1]+Random(101)-50;
end;

{ set our X array }
With Series1.XValues do
begin
Value:=TChartValues(X); { <-- the array }
Count:=Num; { <-- number of points }
Modified:=True; { <-- recalculate min and max }
end;

{ set our Y array }
With Series1.YValues do
begin
Value:=TChartValues(Y);
Count:=Num;
Modified:=True;
end;

Chart1.UndoZoom; { <-- remove zoom (optional) }

{ Show data }
Series1.Repaint;
end;




Send us Help Feedback. Copyright 1995-2013 © by Steema Software. All Rights Reserved.