TAChart: Fix broken TDBChartSource, issue #39313 (running DBGrid scrollbar).

This commit is contained in:
wp_xyz 2021-08-07 22:39:50 +02:00
parent 862cedaca9
commit 41db5da688
2 changed files with 18 additions and 3 deletions

View File

@ -147,6 +147,7 @@ begin
inherited AfterDraw;
try
if not FDataLink.Active or (FBookmark = nil) then exit;
FDataLink.Dataset.EnableControls;
FDataLink.DataSet.GotoBookmark(FBookmark);
FDataLink.DataSet.FreeBookmark(FBookmark);
finally
@ -159,6 +160,7 @@ procedure TDbChartSource.BeforeDraw;
begin
inherited BeforeDraw;
VLockedDatasets.Add(FDataLink.DataSet);
FDataLink.Dataset.DisableControls;
if FDataLink.Active and (FBookmark = nil) then
FBookmark := FDataLink.DataSet.GetBookmark;
end;

View File

@ -241,6 +241,7 @@ type
FOnExtentChanging: TChartEvent;
FOnExtentValidate: TChartExtentValidateEvent;
FOnFullExtentChanged: TChartEvent;
FBufferedFullExtent: TDoubleRect;
FPrevFullExtent: TDoubleRect;
FPrevLogicalExtent: TDoubleRect;
FScale: TDoublePoint; // Coordinates transformation
@ -254,6 +255,7 @@ type
const AMinDataSpace: Integer);
procedure FindComponentClass(
AReader: TReader; const AClassName: String; var AClass: TComponentClass);
function FullExtentBroadcastActive: Boolean;
function GetChartHeight: Integer;
function GetChartWidth: Integer;
function GetHorAxis: TChartAxis;
@ -969,6 +971,12 @@ begin
FCurrentExtent := FLogicalExtent;
end;
// Avoid calculation of the full extent when not needed
// This extent calculation must be inside the series.BeforeDraw (--> Prepare)
// and series.AfterDraw block (DBChartSource issue #39313)
if FullExtentBroadcastActive then
FBufferedFullExtent := GetFullExtent;
if Legend.Visible and not Legend.UseSidebar then
Legend.Prepare(ldd, FClipRect);
@ -1006,12 +1014,12 @@ begin
OnAfterDraw(Self, ADrawer);
ADrawer.DrawingEnd;
tmpExtent := GetFullExtent;
if FPrevFullExtent <> tmpExtent then begin
if FullExtentBroadcastActive and (FPrevFullExtent <> FBufferedFullExtent) then
begin
FFullExtentBroadcaster.Broadcast(Self);
if Assigned(OnFullExtentChanged) then
OnFullExtentChanged(Self);
FPrevFullExtent := tmpExtent;
FPrevFullExtent := FBufferedFullExtent;
end;
if FPrevLogicalExtent <> FLogicalExtent then begin
@ -1142,6 +1150,11 @@ begin
AClass := nil;
end;
function TChart.FullExtentBroadcastActive: Boolean;
begin
Result := (FFullExtentBroadcaster.Count > 0) or Assigned(FOnFullExtentChanged);
end;
procedure TChart.GetAllSeriesAxisLimits(AAxis: TChartAxis; out AMin, AMax: Double);
var
interval: TDoubleInterval;