55
55
constructor Create(AOwner: TComponent); override;
56
56
destructor Destroy; override;
58
procedure Assign(Source: TPersistent); override;
58
procedure Assign(ASource: TPersistent); override;
59
59
function GetParentComponent: TComponent; override;
60
60
function HasParent: Boolean; override;
71
71
TAxisTransformClass = class of TAxisTransform;
73
TAxisTransformList = class(TFPList)
73
{$IFNDEF fpdoc} // Workaround for issue #18549.
74
TAxisTransformEnumerator = specialize TTypedFPListEnumerator<TAxisTransform>;
77
TAxisTransformList = class(TIndexedComponentList)
79
function GetEnumerator: TAxisTransformEnumerator;
76
82
{ TChartAxisTransformations }
78
TChartAxisTransformations = class (TComponent)
84
TChartAxisTransformations = class(TComponent)
80
86
FBroadcaster: TBroadcaster;
81
87
FList: TAxisTransformList;
89
procedure SetName(const AValue: TComponentName); override;
83
91
constructor Create(AOwner: TComponent); override;
84
92
destructor Destroy; override;
111
119
constructor Create(AOwner: TComponent); override;
113
procedure Assign(Source: TPersistent); override;
121
procedure Assign(ASource: TPersistent); override;
115
123
function AxisToGraph(AX: Double): Double; override;
116
124
function GraphToAxis(AX: Double): Double; override;
122
130
{ TAutoScaleAxisTransform }
124
132
TAutoScaleAxisTransform = class(TAxisTransform)
126
134
FMaxValue: Double;
127
135
FMinValue: Double;
128
function MaxValueIsStored: boolean;
129
function MinValueIsStored: boolean;
130
procedure SetMaxValue(const AValue: Double);
131
procedure SetMinValue(const AValue: Double);
136
function MaxValueIsStored: Boolean;
137
function MinValueIsStored: Boolean;
138
procedure SetMaxValue(AValue: Double);
139
procedure SetMinValue(AValue: Double);
133
141
procedure ClearBounds; override;
134
142
function GetDrawDataClass: TDrawDataItemClass; override;
137
145
constructor Create(AOwner: TComponent); override;
139
procedure Assign(Source: TPersistent); override;
147
procedure Assign(ASource: TPersistent); override;
141
149
function AxisToGraph(AX: Double): Double; override;
142
150
function GraphToAxis(AX: Double): Double; override;
164
172
property Base: Double read FBase write SetBase;
175
TCumulNormDistrAxisTransform = class(TAxisTransform)
177
function AxisToGraph(AX: Double): Double; override;
178
function GraphToAxis(AX: Double): Double; override;
181
TTransformEvent = procedure (AX: Double; out AT: Double) of object;
183
{ TUserDefinedAxisTransform }
185
TUserDefinedAxisTransform = class(TAxisTransform)
187
FOnAxisToGraph: TTransformEvent;
188
FOnGraphToAxis: TTransformEvent;
189
procedure SetOnAxisToGraph(AValue: TTransformEvent);
190
procedure SetOnGraphToAxis(AValue: TTransformEvent);
192
procedure Assign(ASource: TPersistent); override;
194
function AxisToGraph(AX: Double): Double; override;
195
function GraphToAxis(AX: Double): Double; override;
197
property OnAxisToGraph: TTransformEvent read FOnAxisToGraph write SetOnAxisToGraph;
198
property OnGraphToAxis: TTransformEvent read FOnGraphToAxis write SetOnGraphToAxis;
167
201
procedure Register;
175
209
ComponentEditors, Forms, Math, PropEdits,
176
TASubcomponentsEditor;
210
TAMath, TASubcomponentsEditor;
179
213
{ TAxisTransformsComponentEditor }
236
270
AxisTransformsClassRegistry.AddObject(ACaption, TObject(AAxisTransformClass));
273
{ TAxisTransformList }
275
function TAxisTransformList.GetEnumerator: TAxisTransformEnumerator;
277
Result := TAxisTransformEnumerator.Create(Self);
239
280
{ TAxisTransformsComponentEditor }
241
282
function TAxisTransformsComponentEditor.GetVerb(Index: Integer): string;
306
347
{ TAxisTransform }
308
procedure TAxisTransform.Assign(Source: TPersistent);
349
procedure TAxisTransform.Assign(ASource: TPersistent);
310
if Source is TAxisTransform then
311
with TAxisTransform(Source) do
351
if ASource is TAxisTransform then
352
with TAxisTransform(ASource) do
312
353
Self.FEnabled := Enabled
314
inherited Assign(Source);
355
inherited Assign(ASource);
317
358
function TAxisTransform.AxisToGraph(AX: Double): Double;
429
470
function TChartAxisTransformations.AxisToGraph(AX: Double): Double;
434
for i := 0 to List.Count - 1 do
435
with TAxisTransform(List[i]) do
437
Result := AxisToGraph(Result);
475
if IsNan(Result) then exit;
478
Result := t.AxisToGraph(Result);
440
481
procedure TChartAxisTransformations.ClearBounds;
444
for i := List.Count - 1 downto 0 do
445
with TAxisTransform(List[i]) do
450
490
constructor TChartAxisTransformations.Create(AOwner: TComponent);
466
506
procedure TChartAxisTransformations.GetChildren(
467
507
Proc: TGetChildProc; Root: TComponent);
471
for i := 0 to List.Count - 1 do
472
if TAxisTransform(List[i]).Owner = Root then
473
Proc(TAxisTransform(List[i]));
512
if t.Owner = Root then
476
516
function TChartAxisTransformations.GraphToAxis(AX: Double): Double;
487
527
procedure TChartAxisTransformations.SetChart(AChart: TObject);
491
for i := 0 to List.Count - 1 do
492
with TAxisTransform(List[i]) do
494
TAxisTransform(List[i]).SetChart(AChart);
497
536
procedure TChartAxisTransformations.SetChildOrder(
504
543
List.Move(i, Order);
546
procedure TChartAxisTransformations.SetName(const AValue: TComponentName);
550
if Name = AValue then exit;
552
inherited SetName(AValue);
553
if csDesigning in ComponentState then
554
List.ChangeNamePrefix(oldName, AValue);
507
557
procedure TChartAxisTransformations.UpdateBounds(var AMin, AMax: Double);
511
for i := 0 to List.Count - 1 do
512
with TAxisTransform(List[i]) do
514
UpdateBounds(AMin, AMax);
563
t.UpdateBounds(AMin, AMax);
517
566
{ TLinearAxisTransform }
519
procedure TLinearAxisTransform.Assign(Source: TPersistent);
568
procedure TLinearAxisTransform.Assign(ASource: TPersistent);
521
if Source is TLinearAxisTransform then
522
with Source as TLinearAxisTransform do begin
570
if ASource is TLinearAxisTransform then
571
with ASource as TLinearAxisTransform do begin
523
572
Self.FOffset := Offset;
524
573
Self.FScale := Scale;
526
inherited Assign(Source);
575
inherited Assign(ASource);
529
578
function TLinearAxisTransform.AxisToGraph(AX: Double): Double;
607
656
{ TAutoScaleAxisTransform }
609
procedure TAutoScaleAxisTransform.Assign(Source: TPersistent);
658
procedure TAutoScaleAxisTransform.Assign(ASource: TPersistent);
611
if Source is TAutoScaleAxisTransform then
612
with TAutoScaleAxisTransform(Source) do begin
660
if ASource is TAutoScaleAxisTransform then
661
with TAutoScaleAxisTransform(ASource) do begin
613
662
Self.FMinValue := FMinValue;
614
663
Self.FMaxValue := FMaxValue;
616
inherited Assign(Source);
665
inherited Assign(ASource);
619
668
function TAutoScaleAxisTransform.AxisToGraph(AX: Double): Double;
650
699
Result := (AX - FOffset) / FScale;
653
function TAutoScaleAxisTransform.MaxValueIsStored: boolean;
702
function TAutoScaleAxisTransform.MaxValueIsStored: Boolean;
655
704
Result := MaxValue <> 1.0;
658
function TAutoScaleAxisTransform.MinValueIsStored: boolean;
707
function TAutoScaleAxisTransform.MinValueIsStored: Boolean;
660
709
Result := MinValue <> 0.0;
663
procedure TAutoScaleAxisTransform.SetMaxValue(const AValue: Double);
712
procedure TAutoScaleAxisTransform.SetMaxValue(AValue: Double);
665
714
if FMaxValue = AValue then exit;
666
715
FMaxValue := AValue;
670
procedure TAutoScaleAxisTransform.SetMinValue(const AValue: Double);
719
procedure TAutoScaleAxisTransform.SetMinValue(AValue: Double);
672
721
if FMinValue = AValue then exit;
673
722
FMinValue := AValue;
691
740
AMax := MaxValue;
743
{ TCumulNormDistrAxisTransform }
745
function TCumulNormDistrAxisTransform.AxisToGraph(AX: Double): Double;
747
Result := InvCumulNormDistr(AX);
750
function TCumulNormDistrAxisTransform.GraphToAxis(AX: Double): Double;
752
Result := CumulNormDistr(AX);
755
{ TUserDefinedAxisTransform }
757
procedure TUserDefinedAxisTransform.Assign(ASource: TPersistent);
759
if ASource is TUserDefinedAxisTransform then
760
with TUserDefinedAxisTransform(ASource) do begin
761
Self.FOnAxisToGraph := FOnAxisToGraph;
762
Self.FOnGraphToAxis := FOnGraphToAxis;
764
inherited Assign(ASource);
767
function TUserDefinedAxisTransform.AxisToGraph(AX: Double): Double;
769
if Assigned(OnAxisToGraph) then
770
OnAxisToGraph(AX, Result)
775
function TUserDefinedAxisTransform.GraphToAxis(AX: Double): Double;
777
if Assigned(OnGraphToAxis) then
778
OnGraphToAxis(AX, Result)
783
procedure TUserDefinedAxisTransform.SetOnAxisToGraph(AValue: TTransformEvent);
785
if TMethod(FOnAxisToGraph) = TMethod(AValue) then exit;
786
FOnAxisToGraph := AValue;
790
procedure TUserDefinedAxisTransform.SetOnGraphToAxis(AValue: TTransformEvent);
792
if TMethod(FOnGraphToAxis) = TMethod(AValue) then exit;
793
FOnGraphToAxis := AValue;
696
799
AxisTransformsClassRegistry := TStringList.Create;
697
800
RegisterAxisTransformClass(TAutoScaleAxisTransform, 'Auto scale');
801
RegisterAxisTransformClass(
802
TCumulNormDistrAxisTransform, 'Cumulative normal distribution');
698
803
RegisterAxisTransformClass(TLinearAxisTransform, 'Linear');
699
804
RegisterAxisTransformClass(TLogarithmAxisTransform, 'Logarithmic');
805
RegisterAxisTransformClass(TUserDefinedAxisTransform, 'User defined');