我正在阅读"TeeChart VCL 中的实时图表:添加大量点的另一种方法是使用直接动态数组",并想问如何跳过 X 轴缓冲区(节省浪费的内存空间),而它只是包含一个简单的基数 1....n = Num 点序列。而 Num 将在> 1 mio 区域。
我认为避免需要 XValues 数组的最简单方法是使用 TCustomTeeFunction,如以下示例所示:
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;