1

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.

j0k
  • 22,600
  • 28
  • 79
  • 90
HpW
  • 51
  • 3

1 Answers1

1

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;
Yeray
  • 5,009
  • 1
  • 13
  • 25