I'm trying to realize an optimization for handling alot of data and adding a custom zoom.
This is the original chart, where only each 9th point is being drawn.
If I zoom in ...
... the following happens:
As you can see, the Chart draws a line from the last X value (14.000'ish) to the zoom point and adds new values to that position, simply overdrawing the previous, instead of "inserting" the values at this position.
I already followed a solution given by Narcís, but it isn't working. http://www.teechart.net/support/viewtopic.php?t=5127
Code: Select all
procedure TFrame_ElementDetails.Chart_ObservationZoom(Sender: TObject);
var
Chart: TChart;
i, IndexFrom, IndexTo: Cardinal;
LineColor: TColorRec;
S: String;
Ls: TLineSeries;
// ...
begin
if not (Sender is TChart) or not Assigned(FObserver) then
Exit;
// ...
Chart := TChart(Sender);
Ls := TLineSeries(Chart.Series[0]);
IndexFrom := Floor(Chart.BottomAxis.CalcPosPoint(Chart.Zoom.X0));
IndexTo := Ceil(Chart.BottomAxis.CalcPosPoint(Chart.Zoom.X1));
Chart.AutoRepaint := FALSE;
try
for i := IndexFrom to IndexTo do
begin
Data := DataList[i];
LineColor := GetChartValueColor(Data.Values[0], Data.Sigma[4]);
S := FormatDateTime('ddddd', Data.Timestamp) + #13#10 +
FormatDateTime('tt', Data.Timestamp);
TLineSeries(Chart_Observation.Series[0]).AddXY(i, Data.Values[0], S,
LineColor);
end;
finally
Chart.AutoRepaint := TRUE;
Chart.Refresh;
end;
end;