mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-11 04:07:29 +01:00
TAChart: Move Active property to TBasicChartSeries class
git-svn-id: trunk@19090 -
This commit is contained in:
parent
bd8923b25a
commit
ce8f80bc53
@ -51,6 +51,7 @@ type
|
|||||||
protected
|
protected
|
||||||
FTitle: String;
|
FTitle: String;
|
||||||
FChart: TChart;
|
FChart: TChart;
|
||||||
|
FActive: Boolean;
|
||||||
|
|
||||||
procedure DrawLegend(ACanvas: TCanvas; const ARect: TRect); virtual; abstract;
|
procedure DrawLegend(ACanvas: TCanvas; const ARect: TRect); virtual; abstract;
|
||||||
function GetLegendCount: Integer; virtual; abstract;
|
function GetLegendCount: Integer; virtual; abstract;
|
||||||
@ -58,8 +59,7 @@ type
|
|||||||
function IsInLegend: Boolean; virtual; abstract;
|
function IsInLegend: Boolean; virtual; abstract;
|
||||||
procedure UpdateMargins(ACanvas: TCanvas; var AMargins: TRect); virtual;
|
procedure UpdateMargins(ACanvas: TCanvas; var AMargins: TRect); virtual;
|
||||||
procedure UpdateBounds(
|
procedure UpdateBounds(
|
||||||
var ANumPoints: Integer; var AXMin, AYMin, AXMax, AYMax: Double);
|
var AXMin, AYMin, AXMax, AYMax: Double); virtual; abstract;
|
||||||
virtual; abstract;
|
|
||||||
procedure AfterAdd; virtual; abstract;
|
procedure AfterAdd; virtual; abstract;
|
||||||
function GetNearestPoint(
|
function GetNearestPoint(
|
||||||
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
||||||
@ -67,6 +67,7 @@ type
|
|||||||
virtual;
|
virtual;
|
||||||
function GetSeriesColor: TColor; virtual; abstract;
|
function GetSeriesColor: TColor; virtual; abstract;
|
||||||
procedure SetSeriesColor(const AValue: TColor); virtual; abstract;
|
procedure SetSeriesColor(const AValue: TColor); virtual; abstract;
|
||||||
|
procedure SetActive(AValue: Boolean); virtual; abstract;
|
||||||
|
|
||||||
procedure ReadState(Reader: TReader); override;
|
procedure ReadState(Reader: TReader); override;
|
||||||
procedure SetParentComponent(AParent: TComponent); override;
|
procedure SetParentComponent(AParent: TComponent); override;
|
||||||
@ -77,8 +78,9 @@ type
|
|||||||
function HasParent: Boolean; override;
|
function HasParent: Boolean; override;
|
||||||
|
|
||||||
function Count: Integer; virtual; abstract;
|
function Count: Integer; virtual; abstract;
|
||||||
procedure DrawIfActive(ACanvas: TCanvas); virtual; abstract;
|
procedure Draw(ACanvas: TCanvas); virtual; abstract;
|
||||||
|
|
||||||
|
property Active: Boolean read FActive write SetActive;
|
||||||
property ParentChart: TChart read FChart;
|
property ParentChart: TChart read FChart;
|
||||||
property SeriesColor: TColor
|
property SeriesColor: TColor
|
||||||
read GetSeriesColor write SetSeriesColor default clTAColor;
|
read GetSeriesColor write SetSeriesColor default clTAColor;
|
||||||
@ -894,7 +896,8 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := Rect(0, 0, 0, 0);
|
Result := Rect(0, 0, 0, 0);
|
||||||
for i := 0 to SeriesCount - 1 do
|
for i := 0 to SeriesCount - 1 do
|
||||||
Series[i].UpdateMargins(ACanvas, Result);
|
if Series[i].Active then
|
||||||
|
Series[i].UpdateMargins(ACanvas, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChart.SetGraphBrush(Value: TBrush);
|
procedure TChart.SetGraphBrush(Value: TBrush);
|
||||||
@ -947,8 +950,7 @@ end;
|
|||||||
procedure TChart.Refresh(ACanvas: TCanvas; ARect: TRect);
|
procedure TChart.Refresh(ACanvas: TCanvas; ARect: TRect);
|
||||||
var
|
var
|
||||||
Tolerance, Valeur: Double;
|
Tolerance, Valeur: Double;
|
||||||
i: Integer;
|
i, pointsTotal: Integer;
|
||||||
NBPointsMax: Integer;
|
|
||||||
XMinSeries, XMaxSeries, YMinSeries, YMaxSeries: Double;
|
XMinSeries, XMaxSeries, YMinSeries, YMaxSeries: Double;
|
||||||
begin
|
begin
|
||||||
DrawReticule(ACanvas);
|
DrawReticule(ACanvas);
|
||||||
@ -964,10 +966,13 @@ begin
|
|||||||
XMaxSeries := MinDouble;
|
XMaxSeries := MinDouble;
|
||||||
YMinSeries := MaxDouble;
|
YMinSeries := MaxDouble;
|
||||||
YMaxSeries := MinDouble;
|
YMaxSeries := MinDouble;
|
||||||
NBPointsMax := 0;
|
pointsTotal := 0;
|
||||||
for i := 0 to SeriesCount - 1 do
|
for i := 0 to SeriesCount - 1 do
|
||||||
Series[i].UpdateBounds(
|
with Series[i] do
|
||||||
NBPointsMax, XMinSeries, YMinSeries, XMaxSeries, YMaxSeries);
|
if Active then begin
|
||||||
|
pointsTotal += Count;
|
||||||
|
UpdateBounds(XMinSeries, YMinSeries, XMaxSeries, YMaxSeries);
|
||||||
|
end;
|
||||||
if XMinSeries > MaxDouble / 10 then XMinSeries := 0;
|
if XMinSeries > MaxDouble / 10 then XMinSeries := 0;
|
||||||
if YMinSeries > MaxDouble / 10 then YMinSeries := 0;
|
if YMinSeries > MaxDouble / 10 then YMinSeries := 0;
|
||||||
if XMaxSeries < MinDouble / 10 then XMaxSeries := 0;
|
if XMaxSeries < MinDouble / 10 then XMaxSeries := 0;
|
||||||
@ -989,7 +994,7 @@ begin
|
|||||||
Tolerance := 0.001; //this should be cleaned eventually
|
Tolerance := 0.001; //this should be cleaned eventually
|
||||||
// Tolerance := 0.1;
|
// Tolerance := 0.1;
|
||||||
|
|
||||||
if NBPointsMax > 0 then begin
|
if pointsTotal > 0 then begin
|
||||||
// If several points : automatic +/-10% of interval
|
// If several points : automatic +/-10% of interval
|
||||||
Valeur := Tolerance * (XMaxSeries - XMinSeries);
|
Valeur := Tolerance * (XMaxSeries - XMinSeries);
|
||||||
if Valeur <> 0 then begin
|
if Valeur <> 0 then begin
|
||||||
@ -1182,7 +1187,8 @@ begin
|
|||||||
|
|
||||||
// Update all series
|
// Update all series
|
||||||
for i := 0 to SeriesCount - 1 do
|
for i := 0 to SeriesCount - 1 do
|
||||||
Series[i].DrawIfActive(ACanvas);
|
if Series[i].Active then
|
||||||
|
Series[i].Draw(ACanvas);
|
||||||
|
|
||||||
//now disable clipping
|
//now disable clipping
|
||||||
SelectClipRgn(ACanvas.Handle, 0);
|
SelectClipRgn(ACanvas.Handle, 0);
|
||||||
|
|||||||
@ -43,14 +43,12 @@ type
|
|||||||
FXGraphMin, FYGraphMin: Double; // Max Graph value of points
|
FXGraphMin, FYGraphMin: Double; // Max Graph value of points
|
||||||
FXGraphMax, FYGraphMax: Double;
|
FXGraphMax, FYGraphMax: Double;
|
||||||
FCoordList: TList;
|
FCoordList: TList;
|
||||||
FActive: Boolean;
|
|
||||||
FMarks: TChartMarks;
|
FMarks: TChartMarks;
|
||||||
FShowInLegend: Boolean;
|
FShowInLegend: Boolean;
|
||||||
FValuesTotal: Double;
|
FValuesTotal: Double;
|
||||||
FValuesTotalValid: Boolean;
|
FValuesTotalValid: Boolean;
|
||||||
|
|
||||||
function GetXMinVal: Integer;
|
function GetXMinVal: Integer;
|
||||||
procedure SetActive(Value: Boolean);
|
|
||||||
procedure SetMarks(const AValue: TChartMarks);
|
procedure SetMarks(const AValue: TChartMarks);
|
||||||
procedure SetShowInLegend(Value: Boolean);
|
procedure SetShowInLegend(Value: Boolean);
|
||||||
procedure InitBounds(out XMin, YMin, XMax, YMax: Integer);
|
procedure InitBounds(out XMin, YMin, XMax, YMax: Integer);
|
||||||
@ -62,12 +60,12 @@ type
|
|||||||
function GetLegendWidth(ACanvas: TCanvas): Integer; override;
|
function GetLegendWidth(ACanvas: TCanvas): Integer; override;
|
||||||
function GetLegendCount: Integer; override;
|
function GetLegendCount: Integer; override;
|
||||||
function IsInLegend: Boolean; override;
|
function IsInLegend: Boolean; override;
|
||||||
procedure UpdateBounds(
|
procedure UpdateBounds(var AXMin, AYMin, AXMax, AYMax: Double); override;
|
||||||
var ANumPoints: Integer; var AXMin, AYMin, AXMax, AYMax: Double); override;
|
|
||||||
procedure UpdateParentChart;
|
procedure UpdateParentChart;
|
||||||
function GetValuesTotal: Double;
|
function GetValuesTotal: Double;
|
||||||
procedure GetCoords(AIndex: Integer; out AG: TDoublePoint; out AI: TPoint);
|
procedure GetCoords(AIndex: Integer; out AG: TDoublePoint; out AI: TPoint);
|
||||||
function ColorOrDefault(AColor: TColor; ADefault: TColor = clTAColor): TColor;
|
function ColorOrDefault(AColor: TColor; ADefault: TColor = clTAColor): TColor;
|
||||||
|
procedure SetActive(AValue: Boolean); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -78,8 +76,6 @@ type
|
|||||||
property YGraphMax: Double read FYGraphMax write FYGraphMax;
|
property YGraphMax: Double read FYGraphMax write FYGraphMax;
|
||||||
|
|
||||||
function Count: Integer; override;
|
function Count: Integer; override;
|
||||||
procedure Draw(ACanvas: TCanvas); virtual; abstract;
|
|
||||||
procedure DrawIfActive(ACanvas: TCanvas); override;
|
|
||||||
function AddXY(X, Y: Double; XLabel: String; Color: TColor): Longint; virtual;
|
function AddXY(X, Y: Double; XLabel: String; Color: TColor): Longint; virtual;
|
||||||
function Add(AValue: Double; XLabel: String; Color: TColor): Longint; virtual;
|
function Add(AValue: Double; XLabel: String; Color: TColor): Longint; virtual;
|
||||||
procedure Delete(AIndex: Integer); virtual;
|
procedure Delete(AIndex: Integer); virtual;
|
||||||
@ -87,7 +83,7 @@ type
|
|||||||
function FormattedMark(AIndex: integer): String;
|
function FormattedMark(AIndex: integer): String;
|
||||||
|
|
||||||
published
|
published
|
||||||
property Active: Boolean read FActive write SetActive default true;
|
property Active default true;
|
||||||
property Marks: TChartMarks read FMarks write SetMarks;
|
property Marks: TChartMarks read FMarks write SetMarks;
|
||||||
property ShowInLegend: Boolean
|
property ShowInLegend: Boolean
|
||||||
read FShowInLegend write SetShowInLegend default true;
|
read FShowInLegend write SetShowInLegend default true;
|
||||||
@ -327,12 +323,6 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.DrawIfActive(ACanvas: TCanvas);
|
|
||||||
begin
|
|
||||||
if Active then
|
|
||||||
Draw(ACanvas);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChartSeries.DrawLegend(ACanvas: TCanvas; const ARect: TRect);
|
procedure TChartSeries.DrawLegend(ACanvas: TCanvas; const ARect: TRect);
|
||||||
begin
|
begin
|
||||||
ACanvas.TextOut(ARect.Right + 3, ARect.Top, Title);
|
ACanvas.TextOut(ARect.Right + 3, ARect.Top, Title);
|
||||||
@ -485,9 +475,9 @@ begin
|
|||||||
Result := FCoordList.Count;
|
Result := FCoordList.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.SetActive(Value: Boolean);
|
procedure TChartSeries.SetActive(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
FActive := Value;
|
FActive := AValue;
|
||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -508,11 +498,9 @@ begin
|
|||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.UpdateBounds(
|
procedure TChartSeries.UpdateBounds(var AXMin, AYMin, AXMax, AYMax: Double);
|
||||||
var ANumPoints: Integer; var AXMin, AYMin, AXMax, AYMax: Double);
|
|
||||||
begin
|
begin
|
||||||
if not Active or (Count = 0) then exit;
|
if not Active or (Count = 0) then exit;
|
||||||
ANumPoints += Count;
|
|
||||||
if XGraphMin < AXMin then AXMin := XGraphMin;
|
if XGraphMin < AXMin then AXMin := XGraphMin;
|
||||||
if YGraphMin < AYMin then AYMin := YGraphMin;
|
if YGraphMin < AYMin then AYMin := YGraphMin;
|
||||||
if XGraphMax > AXMax then AXMax := XGraphMax;
|
if XGraphMax > AXMax then AXMax := XGraphMax;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user