TAChart: Update TColorMapSeries after ColorSource change

git-svn-id: trunk@29325 -
This commit is contained in:
ask 2011-02-02 08:22:07 +00:00
parent e0eacbebbd
commit 45aa6e748e

View File

@ -99,6 +99,7 @@ type
private private
FBrush: TBrush; FBrush: TBrush;
FColorSource: TCustomChartSource; FColorSource: TCustomChartSource;
FColorSourceListener: TListener;
FInterpolate: Boolean; FInterpolate: Boolean;
FOnCalculate: TFuncCalculate3DEvent; FOnCalculate: TFuncCalculate3DEvent;
FStepX: TFuncSeriesStep; FStepX: TFuncSeriesStep;
@ -406,6 +407,7 @@ end;
constructor TColorMapSeries.Create(AOwner: TComponent); constructor TColorMapSeries.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FColorSourceListener := TListener.Create(@FColorSource, @StyleChanged);
FBrush := TBrush.Create; FBrush := TBrush.Create;
FBrush.OnChange := @StyleChanged; FBrush.OnChange := @StyleChanged;
FStepX := DEF_COLORMAP_STEP; FStepX := DEF_COLORMAP_STEP;
@ -414,6 +416,7 @@ end;
destructor TColorMapSeries.Destroy; destructor TColorMapSeries.Destroy;
begin begin
FreeAndNil(FColorSourceListener);
FreeAndNil(FBrush); FreeAndNil(FBrush);
inherited Destroy; inherited Destroy;
end; end;
@ -524,7 +527,10 @@ end;
procedure TColorMapSeries.SetColorSource(AValue: TCustomChartSource); procedure TColorMapSeries.SetColorSource(AValue: TCustomChartSource);
begin begin
if FColorSource = AValue then exit; if FColorSource = AValue then exit;
if FColorSourceListener.IsListening then
ColorSource.Broadcaster.Unsubscribe(FColorSourceListener);
FColorSource := AValue; FColorSource := AValue;
ColorSource.Broadcaster.Subscribe(FColorSourceListener);
UpdateParentChart; UpdateParentChart;
end; end;