flicker when destroying series

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
strobbekoen
Newbie
Newbie
Posts: 23
Joined: Tue Feb 10, 2009 12:00 am

flicker when destroying series

Post by strobbekoen » Fri Sep 21, 2012 10:21 am

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;
Attachments
iqo2_wo.gif
iqo2_wo.gif (36.1 KiB) Viewed 6597 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: flicker when destroying series

Post by Yeray » Mon Sep 24, 2012 8:36 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

strobbekoen
Newbie
Newbie
Posts: 23
Joined: Tue Feb 10, 2009 12:00 am

Re: flicker when destroying series

Post by strobbekoen » Mon Sep 24, 2012 9:27 am

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;
Attachments
iqo2_callstack.gif
iqo2_callstack.gif (7.7 KiB) Viewed 6493 times

strobbekoen
Newbie
Newbie
Posts: 23
Joined: Tue Feb 10, 2009 12:00 am

Re: flicker when destroying series

Post by strobbekoen » Mon Sep 24, 2012 10:00 am

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;


Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: flicker when destroying series

Post by Yeray » Mon Sep 24, 2012 2:44 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply