From d589d25f968ac31987a82b921f89c5f157d9a4c7 Mon Sep 17 00:00:00 2001 From: ask Date: Mon, 4 Oct 2010 09:22:47 +0000 Subject: [PATCH] TAChart: Fix chart invalidation after changing subcomponents' properties git-svn-id: trunk@27563 - --- components/tachart/tacustomseries.pas | 7 +++++++ components/tachart/tagraph.pas | 10 ++++------ components/tachart/taseries.pas | 1 + components/tachart/tatypes.pas | 9 ++++++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/components/tachart/tacustomseries.pas b/components/tachart/tacustomseries.pas index aef3026913..3037f943f2 100644 --- a/components/tachart/tacustomseries.pas +++ b/components/tachart/tacustomseries.pas @@ -43,6 +43,7 @@ type procedure SetShowInLegend(AValue: Boolean); protected + procedure AfterAdd; override; procedure GetGraphBounds(var ABounds: TDoubleRect); override; procedure GetLegendItems(AItems: TChartLegendItems); virtual; abstract; procedure GetLegendItemsBasic(AItems: TChartLegendItems); override; @@ -206,6 +207,11 @@ uses { TCustomChartSeries } +procedure TCustomChartSeries.AfterAdd; +begin + Legend.SetOwner(FChart); +end; + function TCustomChartSeries.AxisToGraph( const APoint: TDoublePoint): TDoublePoint; begin @@ -408,6 +414,7 @@ end; procedure TChartSeries.AfterAdd; begin + inherited; FMarks.SetOwner(FChart); end; diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index 1f3cbf7f86..bb82c1f940 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -51,7 +51,7 @@ type FTitle: String; FZPosition: TChartDistance; - procedure AfterAdd; virtual; + procedure AfterAdd; virtual; abstract; procedure AfterDraw; virtual; procedure BeforeDraw; virtual; // Set series bounds in axis coordinates. @@ -711,6 +711,9 @@ end; procedure TChart.AddSeries(ASeries: TBasicChartSeries); begin + if ASeries.FChart = Self then exit; + if ASeries.FChart <> nil then + ASeries.FChart.DeleteSeries(ASeries); DrawReticule(Canvas); Series.FList.Add(ASeries); ASeries.FChart := Self; @@ -1094,11 +1097,6 @@ end; { TBasicChartSeries } -procedure TBasicChartSeries.AfterAdd; -begin - // nothing -end; - procedure TBasicChartSeries.AfterDraw; begin // empty diff --git a/components/tachart/taseries.pas b/components/tachart/taseries.pas index 9f7ca499f0..7b7a703a92 100644 --- a/components/tachart/taseries.pas +++ b/components/tachart/taseries.pas @@ -858,6 +858,7 @@ end; procedure TPieSeries.AfterAdd; begin + inherited; // disable axis when we have TPie series ParentChart.LeftAxis.Visible := false; ParentChart.BottomAxis.Visible := false; diff --git a/components/tachart/tatypes.pas b/components/tachart/tatypes.pas index 4d70fa0e64..b0ec45b3ee 100644 --- a/components/tachart/tatypes.pas +++ b/components/tachart/tatypes.pas @@ -318,9 +318,12 @@ end; procedure TChartElement.Assign(Source: TPersistent); begin - //inherited Assign(Source); if Source is TChartElement then - Self.FVisible := TChartElement(Source).FVisible; + with TChartElement(Source) do begin + Self.FVisible := FVisible; + Self.FOwner := FOwner; + end; + inherited Assign(Source); end; constructor TChartElement.Create(AOwner: TCustomChart); @@ -427,7 +430,6 @@ end; procedure TGenericChartMarks.Assign(Source: TPersistent); begin - inherited Assign(Source); if Source is Self.ClassType then with TGenericChartMarks(Source) do begin Self.FClipped := FClipped; @@ -440,6 +442,7 @@ begin Self.FOverlapPolicy := FOverlapPolicy; Self.FStyle := FStyle; end; + inherited Assign(Source); end; function TGenericChartMarks.CenterOffset(