Page 1 of 1
flicker when destroying series
Posted: Fri Sep 21, 2012 10:21 am
by 10051902
Hi,
I have a TDBChart which contains various series, some linked to a datasource and others created and populated at runtime.
In the attached screenshot there are TAreaSeries with custom vertical axes created at runtime.
Before I (re)create the series, I destroy the series as in code below.
The problem is that this takes quite some time where I see the hour glass flicker for each series that is destroyed.
Is there a way to avoid this ?
Code: Select all
// delete series
I := 0;
while I < FSeries.Count do begin
if FSeries[I].SeriesType = fts_ZoneLevel then begin
Series := FSeries[I].Series as TAreaSeries;
Axis := Series.CustomVertAxis;
if not FZoneLevelSingleAxis then
Axis.Free;
Series.Free;
FSeries[I].Free;
end else begin
Inc(I);
end;
end;
Re: flicker when destroying series
Posted: Mon Sep 24, 2012 8:36 am
by yeray
Hi
strobbekoen wrote:The problem is that this takes quite some time where I see the hour glass flicker for each series that is destroyed.
Is there a way to avoid this ?
This is probably because the chart is being redrawn each time you remove a series, and also each time you create and populate a new one.
Try disabling AutoRepaint before destroying any series and reenabling it when you've finished removing and readding series. Note you'll probably have to force a chart repaint manually when done, to show the updated chart:
Code: Select all
Chart1.AutoRepaint:=false;
//remove series
//create and populate series
Chart1.AutoRepaint:=true;
Chart1.Draw;
Re: flicker when destroying series
Posted: Mon Sep 24, 2012 9:27 am
by 10051902
Hi,
I tried it but it does not seem to change anything.
However, when I debug on the line Series.Free I get the call stack as in the attached file.
The series I am destroying is not linked to a datasource though, the points are just added manually.
Edit: when i create the series and populate them, it's instantaneous, the delay and flicker only occurs when destroying.
It seems the data for other series linked to a datasource on the same chart is being refreshed for some reason ?
I tried setting all chart series to Active=False, but seems the problem remains.
Code: Select all
procedure TFrameFTChart.BeginUpdate;
begin
if FUpdating = 0 then
DBChartFieldTrack.AutoRepaint := False;
Inc(FUpdating);
end;
procedure TFrameFTChart.EndUpdate;
begin
Dec(FUpdating);
if FUpdating = 0 then begin
DBChartFieldTrack.AutoRepaint := True;
DBChartFieldTrack.Repaint;
end;
end;
Re: flicker when destroying series
Posted: Mon Sep 24, 2012 10:00 am
by 10051902
Apparently, the culprit is the DBChart.AutoRefresh property.
When I change the Begin/End update as below, the chart refreshes instantly when switching to / creating / destroying groups of series.
The question is why the chart refreshes the data when a series is destroyed which is not even linked to the data source ?
Also, it seems when disabling/enabling AutoRefresh as in the code below, I will need to call CheckDataSource for each series as well, not just calling DBChart.RefreshData as it does not seem to work. Some of the series remain blank. Seems like a lot of refreshing to do just to destroy a series though..
Code: Select all
procedure TFrameFTChart.BeginUpdate;
begin
if FUpdating = 0 then begin
DBChartFieldTrack.AutoRefresh := False;
DBChartFieldTrack.AutoRepaint := False;
end;
Inc(FUpdating);
end;
procedure TFrameFTChart.EndUpdate;
begin
Dec(FUpdating);
if FUpdating = 0 then begin
DBChartFieldTrack.AutoRefresh := True;
DBChartFieldTrack.RefreshData;
DBChartFieldTrack.AutoRepaint := True;
DBChartFieldTrack.Repaint;
end;
end;
Re: flicker when destroying series
Posted: Mon Sep 24, 2012 2:44 pm
by yeray
Hi,
Please, try to arrange a simple example example project we can run as-is to reproduce the exact situation here.
The issue will probably depend on how do you exactly populate your series.