mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 23:49:36 +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)
|
||||
private
|
||||
FDefaultTransformations: TChartAxisTransformations;
|
||||
FMarkTexts: TStringDynArray;
|
||||
FMarkValues: TDoubleDynArray;
|
||||
FSize: Integer;
|
||||
@ -191,6 +190,8 @@ type
|
||||
|
||||
function SideByAlignment(
|
||||
var ARect: TRect; AAlignment: TChartAxisAlignment; ADelta: Integer): Integer;
|
||||
function TransformByAxis(
|
||||
AAxisList: TChartAxisList; AIndex: Integer): TChartAxisTransformations;
|
||||
|
||||
implementation
|
||||
|
||||
@ -200,6 +201,9 @@ uses
|
||||
const
|
||||
FONT_SLOPE_VERTICAL = 45 * 10;
|
||||
|
||||
var
|
||||
VIdentityTransform: TChartAxisTransformations;
|
||||
|
||||
function SideByAlignment(
|
||||
var ARect: TRect; AAlignment: TChartAxisAlignment; ADelta: Integer): Integer;
|
||||
var
|
||||
@ -211,6 +215,16 @@ begin
|
||||
a[AAlignment] += ADelta;
|
||||
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 }
|
||||
|
||||
procedure TChartAxisTitle.Assign(Source: TPersistent);
|
||||
@ -295,7 +309,6 @@ end;
|
||||
constructor TChartAxis.Create(ACollection: TCollection);
|
||||
begin
|
||||
inherited Create(ACollection);
|
||||
FDefaultTransformations := TChartAxisTransformations.Create(nil);
|
||||
FGrid := TChartAxisPen.Create;
|
||||
FGrid.OnChange := @StyleChanged;
|
||||
FGrid.Style := psDot;
|
||||
@ -312,7 +325,6 @@ begin
|
||||
FTitle.Free;
|
||||
FMarks.Free;
|
||||
FGrid.Free;
|
||||
FDefaultTransformations.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -488,7 +500,7 @@ function TChartAxis.GetTransform: TChartAxisTransformations;
|
||||
begin
|
||||
Result := Transformations;
|
||||
if Result = nil then
|
||||
Result := FDefaultTransformations;
|
||||
Result := VIdentityTransform;
|
||||
end;
|
||||
|
||||
function TChartAxis.IsVertical: Boolean; inline;
|
||||
@ -692,7 +704,11 @@ begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
VIdentityTransform := TChartAxisTransformations.Create(nil);
|
||||
SkipObsoleteAxisProperties;
|
||||
|
||||
finalization
|
||||
VIdentityTransform.Free;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -147,20 +147,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
Math, TAChartAxis, TATransformations;
|
||||
|
||||
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;
|
||||
Math, TAChartAxis;
|
||||
|
||||
type
|
||||
|
||||
@ -197,12 +184,12 @@ end;
|
||||
|
||||
function TCustomChartSeries.AxisToGraphX(AX: Double): Double;
|
||||
begin
|
||||
Result := TransformationByAxis(FChart, AxisIndexX).AxisToGraph(AX)
|
||||
Result := TransformByAxis(FChart.AxisList, AxisIndexX).AxisToGraph(AX)
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.AxisToGraphY(AY: Double): Double;
|
||||
begin
|
||||
Result := TransformationByAxis(FChart, AxisIndexY).AxisToGraph(AY)
|
||||
Result := TransformByAxis(FChart.AxisList, AxisIndexY).AxisToGraph(AY)
|
||||
end;
|
||||
|
||||
constructor TCustomChartSeries.Create(AOwner: TComponent);
|
||||
@ -241,12 +228,12 @@ end;
|
||||
|
||||
function TCustomChartSeries.GraphToAxisX(AX: Double): Double;
|
||||
begin
|
||||
Result := TransformationByAxis(FChart, AxisIndexX).GraphToAxis(AX)
|
||||
Result := TransformByAxis(FChart.AxisList, AxisIndexX).GraphToAxis(AX)
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.GraphToAxisY(AY: Double): Double;
|
||||
begin
|
||||
Result := TransformationByAxis(FChart, AxisIndexY).GraphToAxis(AY)
|
||||
Result := TransformByAxis(FChart.AxisList, AxisIndexY).GraphToAxis(AY)
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.HasParent: Boolean;
|
||||
@ -582,9 +569,5 @@ begin
|
||||
ListSource.SetYValue(AIndex, AValue);
|
||||
end;
|
||||
|
||||
initialization
|
||||
VIdentityTransform := TChartAxisTransformations.Create(nil);
|
||||
finalization
|
||||
VIdentityTransform.Free;
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user