Load only current data into TChart
I am using Delphi 10 with TChart, TPointSeries, horizontal scrolling, and currently there is too much data (100 curves, each of them contains many thousands of points) loaded from PostgreSQL database.
You can do this manually looping the data and calling Add() / AddXY() functions.
Then, at OnScroll event you can remove points that are out/far from the axes range and add those in/next to the axis range.
No. You should use OnScroll event and check it yourself.
Update
An example of what could be done is provided below:
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
chart.OnScroll := chartScroll;
chart.OnZoom := chartZoom;
end;
procedure TForm1.displayRange();
var startDate, endDate: TDateTime;
begin
startDate := TDateTime(chart.BottomAxis.Minimum);
endDate := TDateTime(chart.BottomAxis.Maximum);
Log(Format('start=%d, end=%d', [
FindClosestIndex(startDate, chart.Series[0].XValues),
FindClosestIndex(endDate, chart.Series[0].XValues)
]));
end;
procedure TForm1.chartScroll(Sender: TObject);
begin
displayRange();
end;
procedure TForm1.chartZoom(Sender: TObject);
begin
displayRange();
end;
An example of FindClosestIndex could be taken here.
End of update
No, but you can maintain variables doing it.
You can use OnCLickLegend event and loop your series. At this moment the Active property of the series is up to date so you can Clear those that are not Active and you can Add / AddXY points to those that are Active .
下一篇: 只将当前数据加载到TChart
