mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 09:09:17 +02:00
TAChart: Extract TCustomChartSeries class
git-svn-id: trunk@21824 -
This commit is contained in:
parent
412dddbda7
commit
d1f35dc29f
@ -27,12 +27,29 @@ uses
|
|||||||
TAChartUtils, TAGraph, TASources, TATypes;
|
TAChartUtils, TAGraph, TASources, TATypes;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
{ TCustomChartSeries }
|
||||||
|
|
||||||
|
TCustomChartSeries = class(TBasicChartSeries)
|
||||||
|
protected
|
||||||
|
procedure DrawLegend(ACanvas: TCanvas; const ARect: TRect); override;
|
||||||
|
function GetLegendCount: Integer; override;
|
||||||
|
function GetLegendWidth(ACanvas: TCanvas): Integer; override;
|
||||||
|
procedure SetActive(AValue: Boolean); override;
|
||||||
|
procedure SetDepth(AValue: TChartDistance); override;
|
||||||
|
procedure SetShowInLegend(AValue: Boolean); override;
|
||||||
|
procedure SetZPosition(AValue: TChartDistance); override;
|
||||||
|
procedure StyleChanged(Sender: TObject);
|
||||||
|
procedure UpdateParentChart;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
end;
|
||||||
|
|
||||||
TChartGetMarkEvent = procedure (
|
TChartGetMarkEvent = procedure (
|
||||||
out AFormattedMark: String; AIndex: Integer) of object;
|
out AFormattedMark: String; AIndex: Integer) of object;
|
||||||
|
|
||||||
{ TChartSeries }
|
{ TChartSeries }
|
||||||
|
|
||||||
TChartSeries = class(TBasicChartSeries)
|
TChartSeries = class(TCustomChartSeries)
|
||||||
private
|
private
|
||||||
FBuiltinSource: TCustomChartSource;
|
FBuiltinSource: TCustomChartSource;
|
||||||
FListener: TListener;
|
FListener: TListener;
|
||||||
@ -50,18 +67,11 @@ type
|
|||||||
procedure AfterDraw; override;
|
procedure AfterDraw; override;
|
||||||
procedure BeforeDraw; override;
|
procedure BeforeDraw; override;
|
||||||
function ColorOrDefault(AColor: TColor; ADefault: TColor = clTAColor): TColor;
|
function ColorOrDefault(AColor: TColor; ADefault: TColor = clTAColor): TColor;
|
||||||
procedure DrawLegend(ACanvas: TCanvas; const ARect: TRect); override;
|
|
||||||
procedure GetCoords(AIndex: Integer; out AG: TDoublePoint; out AI: TPoint);
|
procedure GetCoords(AIndex: Integer; out AG: TDoublePoint; out AI: TPoint);
|
||||||
function GetLegendCount: Integer; override;
|
function GetLegendCount: Integer; override;
|
||||||
function GetLegendWidth(ACanvas: TCanvas): Integer; override;
|
function GetLegendWidth(ACanvas: TCanvas): Integer; override;
|
||||||
function GetXMaxVal: Integer;
|
function GetXMaxVal: Integer;
|
||||||
procedure SetActive(AValue: Boolean); override;
|
|
||||||
procedure SetDepth(AValue: TChartDistance); override;
|
|
||||||
procedure SetShowInLegend(AValue: Boolean); override;
|
|
||||||
procedure SetZPosition(AValue: TChartDistance); override;
|
|
||||||
procedure StyleChanged(Sender: TObject);
|
|
||||||
procedure UpdateBounds(var ABounds: TDoubleRect); override;
|
procedure UpdateBounds(var ABounds: TDoubleRect); override;
|
||||||
procedure UpdateParentChart;
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -122,6 +132,68 @@ begin
|
|||||||
FSeries.UpdateParentChart;
|
FSeries.UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCustomChartSeries }
|
||||||
|
|
||||||
|
constructor TCustomChartSeries.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
FActive := true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomChartSeries.DrawLegend(ACanvas: TCanvas; const ARect: TRect);
|
||||||
|
begin
|
||||||
|
ACanvas.TextOut(ARect.Right + 3, ARect.Top, Title);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomChartSeries.GetLegendCount: Integer;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomChartSeries.GetLegendWidth(ACanvas: TCanvas): Integer;
|
||||||
|
begin
|
||||||
|
Unused(ACanvas);
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomChartSeries.SetActive(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FActive = AValue then exit;
|
||||||
|
FActive := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomChartSeries.SetDepth(AValue: TChartDistance);
|
||||||
|
begin
|
||||||
|
if FDepth = AValue then exit;
|
||||||
|
FDepth := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomChartSeries.SetShowInLegend(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FShowInLegend = AValue then exit;
|
||||||
|
FShowInLegend := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomChartSeries.SetZPosition(AValue: TChartDistance);
|
||||||
|
begin
|
||||||
|
if FZPosition = AValue then exit;
|
||||||
|
FZPosition := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomChartSeries.StyleChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomChartSeries.UpdateParentChart;
|
||||||
|
begin
|
||||||
|
if ParentChart <> nil then ParentChart.Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TChartSeries }
|
{ TChartSeries }
|
||||||
|
|
||||||
function TChartSeries.Add(AValue: Double; XLabel: String; Color: TColor): Integer;
|
function TChartSeries.Add(AValue: Double; XLabel: String; Color: TColor): Integer;
|
||||||
@ -177,7 +249,6 @@ constructor TChartSeries.Create(AOwner: TComponent);
|
|||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
|
||||||
FActive := true;
|
|
||||||
FListener := TChartSeriesListener.Create(Self);
|
FListener := TChartSeriesListener.Create(Self);
|
||||||
FBuiltinSource := TListChartSource.Create(Self);
|
FBuiltinSource := TListChartSource.Create(Self);
|
||||||
FBuiltinSource.Name := 'Builtin';
|
FBuiltinSource.Name := 'Builtin';
|
||||||
@ -215,11 +286,6 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.DrawLegend(ACanvas: TCanvas; const ARect: TRect);
|
|
||||||
begin
|
|
||||||
ACanvas.TextOut(ARect.Right + 3, ARect.Top, Title);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TChartSeries.Extent: TDoubleRect;
|
function TChartSeries.Extent: TDoubleRect;
|
||||||
begin
|
begin
|
||||||
Result := Source.Extent;
|
Result := Source.Extent;
|
||||||
@ -283,19 +349,6 @@ begin
|
|||||||
Result := Source as TListChartSource;
|
Result := Source as TListChartSource;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.SetActive(AValue: Boolean);
|
|
||||||
begin
|
|
||||||
FActive := AValue;
|
|
||||||
UpdateParentChart;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChartSeries.SetDepth(AValue: TChartDistance);
|
|
||||||
begin
|
|
||||||
if FDepth = AValue then exit;
|
|
||||||
FDepth := AValue;
|
|
||||||
UpdateParentChart;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChartSeries.SetMarks(const AValue: TChartMarks);
|
procedure TChartSeries.SetMarks(const AValue: TChartMarks);
|
||||||
begin
|
begin
|
||||||
if FMarks = AValue then exit;
|
if FMarks = AValue then exit;
|
||||||
@ -309,13 +362,6 @@ begin
|
|||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.SetShowInLegend(AValue: Boolean);
|
|
||||||
begin
|
|
||||||
if FShowInLegend = AValue then exit;
|
|
||||||
FShowInLegend := AValue;
|
|
||||||
UpdateParentChart;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChartSeries.SetSource(AValue: TCustomChartSource);
|
procedure TChartSeries.SetSource(AValue: TCustomChartSource);
|
||||||
begin
|
begin
|
||||||
if FSource = AValue then exit;
|
if FSource = AValue then exit;
|
||||||
@ -326,18 +372,6 @@ begin
|
|||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.SetZPosition(AValue: TChartDistance);
|
|
||||||
begin
|
|
||||||
if FZPosition = AValue then exit;
|
|
||||||
FZPosition := AValue;
|
|
||||||
UpdateParentChart;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChartSeries.StyleChanged(Sender: TObject);
|
|
||||||
begin
|
|
||||||
UpdateParentChart;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChartSeries.UpdateBounds(var ABounds: TDoubleRect);
|
procedure TChartSeries.UpdateBounds(var ABounds: TDoubleRect);
|
||||||
begin
|
begin
|
||||||
if not Active or (Count = 0) then exit;
|
if not Active or (Count = 0) then exit;
|
||||||
@ -349,10 +383,5 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.UpdateParentChart;
|
|
||||||
begin
|
|
||||||
if ParentChart <> nil then ParentChart.Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user