TAChart: Inherit TFuncSeries from TCustomChartSeries to reduce code duplication

git-svn-id: trunk@21825 -
This commit is contained in:
ask 2009-09-22 16:36:02 +00:00
parent d1f35dc29f
commit c826d70f2d

View File

@ -240,7 +240,7 @@ type
{ TFuncSeries }
TFuncSeries = class(TBasicChartSeries)
TFuncSeries = class(TCustomChartSeries)
private
FExtent: TChartExtent;
FOnCalculate: TFuncCalculateEvent;
@ -256,14 +256,8 @@ type
function GetLegendCount: Integer; override;
function GetLegendWidth(ACanvas: TCanvas): Integer; override;
function GetSeriesColor: TColor; override;
procedure SetActive(AValue: Boolean); override;
procedure SetDepth(AValue: TChartDistance); override;
procedure SetSeriesColor(const AValue: TColor); override;
procedure SetShowInLegend(AValue: Boolean); override;
procedure SetZPosition(AValue: TChartDistance); override;
procedure StyleChanged(Sender: TObject);
procedure UpdateBounds(var ABounds: TDoubleRect); override;
procedure UpdateParentChart;
public
constructor Create(AOwner: TComponent); override;
@ -1053,7 +1047,6 @@ end;
constructor TFuncSeries.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FActive := true;
FExtent := TChartExtent.Create(FChart);
FShowInLegend := true;
FPen := TChartPen.Create;
@ -1107,7 +1100,7 @@ procedure TFuncSeries.DrawLegend(ACanvas: TCanvas; const ARect: TRect);
var
y: Integer;
begin
ACanvas.TextOut(ARect.Right + 3, ARect.Top, Title);
inherited DrawLegend(ACanvas, ARect);
ACanvas.Pen.Assign(Pen);
y := (ARect.Top + ARect.Bottom) div 2;
ACanvas.Line(ARect.Left, y, ARect.Right, y);
@ -1133,20 +1126,6 @@ begin
Result := not Assigned(OnCalculate);
end;
procedure TFuncSeries.SetActive(AValue: Boolean);
begin
if FActive = AValue then exit;
FActive := AValue;
UpdateParentChart;
end;
procedure TFuncSeries.SetDepth(AValue: TChartDistance);
begin
if FDepth = AValue then exit;
FDepth := AValue;
UpdateParentChart;
end;
procedure TFuncSeries.SetExtent(const AValue: TChartExtent);
begin
if FExtent = AValue then exit;
@ -1175,13 +1154,6 @@ begin
UpdateParentChart;
end;
procedure TFuncSeries.SetShowInLegend(AValue: Boolean);
begin
if FShowInLegend = AValue then exit;
FShowInLegend := AValue;
UpdateParentChart;
end;
procedure TFuncSeries.SetStep(AValue: TFuncSeriesStep);
begin
if FStep = AValue then exit;
@ -1189,18 +1161,6 @@ begin
UpdateParentChart;
end;
procedure TFuncSeries.SetZPosition(AValue: TChartDistance);
begin
if FZPosition = AValue then exit;
FZPosition := AValue;
UpdateParentChart;
end;
procedure TFuncSeries.StyleChanged(Sender: TObject);
begin
UpdateParentChart;
end;
procedure TFuncSeries.UpdateBounds(var ABounds: TDoubleRect);
begin
with Extent do begin
@ -1211,12 +1171,6 @@ begin
end;
end;
procedure TFuncSeries.UpdateParentChart;
begin
if ParentChart <> nil then
ParentChart.Invalidate;
end;
initialization
RegisterSeriesClass(TLineSeries, 'Line series');
RegisterSeriesClass(TAreaSeries, 'Area series');