mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-03 10:18:17 +02:00
TAChart: Initial support for rotated series.
Works correctly for point/line series only. git-svn-id: trunk@24080 -
This commit is contained in:
parent
be9244c5b7
commit
08bb26f6b0
@ -40,6 +40,7 @@ type
|
||||
procedure SetAxisIndexY(AValue: Integer);
|
||||
|
||||
protected
|
||||
procedure GetGraphBounds(out ABounds: TDoubleRect); override;
|
||||
procedure SetActive(AValue: Boolean); override;
|
||||
procedure SetDepth(AValue: TChartDistance); override;
|
||||
procedure SetShowInLegend(AValue: Boolean); override;
|
||||
@ -53,6 +54,8 @@ type
|
||||
function GraphToAxisX(AX: Double): Double; override;
|
||||
function GraphToAxisY(AY: Double): Double; override;
|
||||
|
||||
function IsRotated: Boolean;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
property AxisIndexX: Integer read FAxisIndexX write SetAxisIndexX default DEF_AXIS_INDEX;
|
||||
@ -199,6 +202,21 @@ begin
|
||||
FAxisIndexY := DEF_AXIS_INDEX;
|
||||
end;
|
||||
|
||||
procedure TCustomChartSeries.GetGraphBounds(out ABounds: TDoubleRect);
|
||||
begin
|
||||
GetBounds(ABounds);
|
||||
with ABounds do begin
|
||||
a.X := AxisToGraphX(a.X);
|
||||
a.Y := AxisToGraphY(a.Y);
|
||||
b.X := AxisToGraphX(b.X);
|
||||
b.Y := AxisToGraphY(b.Y);
|
||||
if IsRotated then begin
|
||||
Exchange(a.X, a.Y);
|
||||
Exchange(b.X, b.Y);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.GraphToAxisX(AX: Double): Double;
|
||||
begin
|
||||
Result := TransformationByAxis(FChart, AxisIndexX).GraphToAxis(AX)
|
||||
@ -209,6 +227,15 @@ begin
|
||||
Result := TransformationByAxis(FChart, AxisIndexY).GraphToAxis(AY)
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.IsRotated: Boolean;
|
||||
const
|
||||
VERTICAL = [calLeft, calRight];
|
||||
begin
|
||||
Result :=
|
||||
(AxisIndexX >= 0) and (FChart.AxisList[AxisIndexX].Alignment in VERTICAL) and
|
||||
(AxisIndexY >= 0) and not (FChart.AxisList[AxisIndexY].Alignment in VERTICAL);
|
||||
end;
|
||||
|
||||
procedure TCustomChartSeries.SetActive(AValue: Boolean);
|
||||
begin
|
||||
if FActive = AValue then exit;
|
||||
@ -387,6 +414,8 @@ begin
|
||||
Result.X := AxisToGraphX(X);
|
||||
Result.Y := AxisToGraphY(Y);
|
||||
end;
|
||||
if IsRotated then
|
||||
Exchange(Result.X, Result.Y);
|
||||
end;
|
||||
|
||||
function TChartSeries.GetGraphPointX(AIndex: Integer): Double;
|
||||
|
@ -56,6 +56,7 @@ type
|
||||
procedure AfterDraw; virtual;
|
||||
procedure BeforeDraw; virtual;
|
||||
procedure GetBounds(out ABounds: TDoubleRect); virtual; abstract;
|
||||
procedure GetGraphBounds(out ABounds: TDoubleRect); virtual; abstract;
|
||||
procedure GetLegendItems(AItems: TChartLegendItems); virtual; abstract;
|
||||
function GetNearestPoint(
|
||||
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
||||
@ -1074,13 +1075,7 @@ begin
|
||||
s := Series[i];
|
||||
if not s.Active then continue;
|
||||
seriesBounds := EmptyExtent;
|
||||
s.GetBounds(seriesBounds);
|
||||
with seriesBounds do begin
|
||||
a.X := s.AxisToGraphX(a.X);
|
||||
a.Y := s.AxisToGraphY(a.Y);
|
||||
b.X := s.AxisToGraphX(b.X);
|
||||
b.Y := s.AxisToGraphY(b.Y);
|
||||
end;
|
||||
s.GetGraphBounds(seriesBounds);
|
||||
with FCurrentExtent do begin
|
||||
a.X := Min(a.X, seriesBounds.a.X);
|
||||
b.X := Max(b.X, seriesBounds.b.X);
|
||||
|
Loading…
Reference in New Issue
Block a user