mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 07:18:16 +02:00
TAChart: Use VIdentityTransform instead of TChartAxis.FDefaultTransformations
git-svn-id: trunk@24464 -
This commit is contained in:
parent
8306359d07
commit
f5ff000c40
@ -102,7 +102,6 @@ type
|
|||||||
|
|
||||||
TChartAxis = class(TCollectionItem)
|
TChartAxis = class(TCollectionItem)
|
||||||
private
|
private
|
||||||
FDefaultTransformations: TChartAxisTransformations;
|
|
||||||
FMarkTexts: TStringDynArray;
|
FMarkTexts: TStringDynArray;
|
||||||
FMarkValues: TDoubleDynArray;
|
FMarkValues: TDoubleDynArray;
|
||||||
FSize: Integer;
|
FSize: Integer;
|
||||||
@ -191,6 +190,8 @@ type
|
|||||||
|
|
||||||
function SideByAlignment(
|
function SideByAlignment(
|
||||||
var ARect: TRect; AAlignment: TChartAxisAlignment; ADelta: Integer): Integer;
|
var ARect: TRect; AAlignment: TChartAxisAlignment; ADelta: Integer): Integer;
|
||||||
|
function TransformByAxis(
|
||||||
|
AAxisList: TChartAxisList; AIndex: Integer): TChartAxisTransformations;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -200,6 +201,9 @@ uses
|
|||||||
const
|
const
|
||||||
FONT_SLOPE_VERTICAL = 45 * 10;
|
FONT_SLOPE_VERTICAL = 45 * 10;
|
||||||
|
|
||||||
|
var
|
||||||
|
VIdentityTransform: TChartAxisTransformations;
|
||||||
|
|
||||||
function SideByAlignment(
|
function SideByAlignment(
|
||||||
var ARect: TRect; AAlignment: TChartAxisAlignment; ADelta: Integer): Integer;
|
var ARect: TRect; AAlignment: TChartAxisAlignment; ADelta: Integer): Integer;
|
||||||
var
|
var
|
||||||
@ -211,6 +215,16 @@ begin
|
|||||||
a[AAlignment] += ADelta;
|
a[AAlignment] += ADelta;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TransformByAxis(
|
||||||
|
AAxisList: TChartAxisList; AIndex: Integer): TChartAxisTransformations;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
if InRange(AIndex, 0, AAxisList.Count - 1) then
|
||||||
|
Result := AAxisList[AIndex].Transformations;
|
||||||
|
if Result = nil then
|
||||||
|
Result := VIdentityTransform;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TChartAxisTitle }
|
{ TChartAxisTitle }
|
||||||
|
|
||||||
procedure TChartAxisTitle.Assign(Source: TPersistent);
|
procedure TChartAxisTitle.Assign(Source: TPersistent);
|
||||||
@ -295,7 +309,6 @@ end;
|
|||||||
constructor TChartAxis.Create(ACollection: TCollection);
|
constructor TChartAxis.Create(ACollection: TCollection);
|
||||||
begin
|
begin
|
||||||
inherited Create(ACollection);
|
inherited Create(ACollection);
|
||||||
FDefaultTransformations := TChartAxisTransformations.Create(nil);
|
|
||||||
FGrid := TChartAxisPen.Create;
|
FGrid := TChartAxisPen.Create;
|
||||||
FGrid.OnChange := @StyleChanged;
|
FGrid.OnChange := @StyleChanged;
|
||||||
FGrid.Style := psDot;
|
FGrid.Style := psDot;
|
||||||
@ -312,7 +325,6 @@ begin
|
|||||||
FTitle.Free;
|
FTitle.Free;
|
||||||
FMarks.Free;
|
FMarks.Free;
|
||||||
FGrid.Free;
|
FGrid.Free;
|
||||||
FDefaultTransformations.Free;
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -488,7 +500,7 @@ function TChartAxis.GetTransform: TChartAxisTransformations;
|
|||||||
begin
|
begin
|
||||||
Result := Transformations;
|
Result := Transformations;
|
||||||
if Result = nil then
|
if Result = nil then
|
||||||
Result := FDefaultTransformations;
|
Result := VIdentityTransform;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChartAxis.IsVertical: Boolean; inline;
|
function TChartAxis.IsVertical: Boolean; inline;
|
||||||
@ -692,7 +704,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
VIdentityTransform := TChartAxisTransformations.Create(nil);
|
||||||
SkipObsoleteAxisProperties;
|
SkipObsoleteAxisProperties;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
VIdentityTransform.Free;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -147,20 +147,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math, TAChartAxis, TATransformations;
|
Math, TAChartAxis;
|
||||||
|
|
||||||
var
|
|
||||||
VIdentityTransform: TChartAxisTransformations;
|
|
||||||
|
|
||||||
function TransformationByAxis(
|
|
||||||
AChart: TChart; AAxisIndex: Integer): TChartAxisTransformations;
|
|
||||||
begin
|
|
||||||
Result := nil;
|
|
||||||
if InRange(AAxisIndex, 0, AChart.AxisList.Count - 1) then
|
|
||||||
Result := AChart.AxisList[AAxisIndex].Transformations;
|
|
||||||
if Result = nil then
|
|
||||||
Result := VIdentityTransform;
|
|
||||||
end;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -197,12 +184,12 @@ end;
|
|||||||
|
|
||||||
function TCustomChartSeries.AxisToGraphX(AX: Double): Double;
|
function TCustomChartSeries.AxisToGraphX(AX: Double): Double;
|
||||||
begin
|
begin
|
||||||
Result := TransformationByAxis(FChart, AxisIndexX).AxisToGraph(AX)
|
Result := TransformByAxis(FChart.AxisList, AxisIndexX).AxisToGraph(AX)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomChartSeries.AxisToGraphY(AY: Double): Double;
|
function TCustomChartSeries.AxisToGraphY(AY: Double): Double;
|
||||||
begin
|
begin
|
||||||
Result := TransformationByAxis(FChart, AxisIndexY).AxisToGraph(AY)
|
Result := TransformByAxis(FChart.AxisList, AxisIndexY).AxisToGraph(AY)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TCustomChartSeries.Create(AOwner: TComponent);
|
constructor TCustomChartSeries.Create(AOwner: TComponent);
|
||||||
@ -241,12 +228,12 @@ end;
|
|||||||
|
|
||||||
function TCustomChartSeries.GraphToAxisX(AX: Double): Double;
|
function TCustomChartSeries.GraphToAxisX(AX: Double): Double;
|
||||||
begin
|
begin
|
||||||
Result := TransformationByAxis(FChart, AxisIndexX).GraphToAxis(AX)
|
Result := TransformByAxis(FChart.AxisList, AxisIndexX).GraphToAxis(AX)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomChartSeries.GraphToAxisY(AY: Double): Double;
|
function TCustomChartSeries.GraphToAxisY(AY: Double): Double;
|
||||||
begin
|
begin
|
||||||
Result := TransformationByAxis(FChart, AxisIndexY).GraphToAxis(AY)
|
Result := TransformByAxis(FChart.AxisList, AxisIndexY).GraphToAxis(AY)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomChartSeries.HasParent: Boolean;
|
function TCustomChartSeries.HasParent: Boolean;
|
||||||
@ -582,9 +569,5 @@ begin
|
|||||||
ListSource.SetYValue(AIndex, AValue);
|
ListSource.SetYValue(AIndex, AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
|
||||||
VIdentityTransform := TChartAxisTransformations.Create(nil);
|
|
||||||
finalization
|
|
||||||
VIdentityTransform.Free;
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user