HpW
HpW

Reputation: 61

TeeChart fast plotting

I am reading the "Real-time charting in TeeChart VCL: Another way of adding a large number of points is to use direct dynamic arrays" and would like to ask how to skip the X-Axis buffer (save wasted memory space), while it simple contains a simple cardinal 1....n = Num points sequence. While Num will be in the > 1 mio region.

Upvotes: 1

Views: 870

Answers (1)

Yeray
Yeray

Reputation: 5039

I think the easiest way to avoid the need of having the XValues array would be using the TCustomTeeFunction as in the following example:

var Series1: TFastLineSeries;
    CustFunci: TCustomTeeFunction;
    MyValues: array of double;

procedure TForm1.FormCreate(Sender: TObject);
var i, nValues: Integer;
begin
  //data
  nValues:=10000;
  SetLength(MyValues, nValues);
  MyValues[0]:=Random(10000);
  for i:=Low(MyValues)+1 to High(MyValues) do
    MyValues[i]:=MyValues[i-1]+Random(10)-4.5;

  //chart
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  Series1:=Chart1.AddSeries(TFastLineSeries) as TFastLineSeries;

  CustFunci:=TCustomTeeFunction.Create(Self);
  Series1.FunctionType:=CustFunci;
  CustFunci.NumPoints:=nValues;
  CustFunci.OnCalculate:=CustFunciCalculate;
  CustFunci.ReCalculate;
end;

procedure TForm1.CustFunciCalculate(Sender:TCustomTeeFunction; const x:Double; var y:Double);
begin
  y:=MyValues[Round(x)];
end;

Upvotes: 1

Related Questions