mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 20:58:14 +02:00
TAChart: Add methods StoreAxisRange() and RestoreAxisRange() to LiveView component.
git-svn-id: trunk@65499 -
This commit is contained in:
parent
47f6a84e19
commit
148d36900f
@ -26,7 +26,7 @@ unit TAChartLiveView;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, TAGraph, TAChartUtils;
|
Classes, SysUtils, TAGraph, TAChartUtils, TAChartAxis;
|
||||||
|
|
||||||
type
|
type
|
||||||
TChartLiveViewExtentY = (lveAuto, lveFull, lveLogical);
|
TChartLiveViewExtentY = (lveAuto, lveFull, lveLogical);
|
||||||
@ -57,7 +57,9 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure RestoreAxisRange(Axis: TChartAxis);
|
||||||
procedure RestoreAxisRanges;
|
procedure RestoreAxisRanges;
|
||||||
|
procedure StoreAxisRange(Axis: TChartAxis);
|
||||||
procedure StoreAxisRanges;
|
procedure StoreAxisRanges;
|
||||||
published
|
published
|
||||||
property Active: Boolean read FActive write SetActive default false;
|
property Active: Boolean read FActive write SetActive default false;
|
||||||
@ -72,7 +74,7 @@ procedure Register;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math, TAChartAxis, TAChartAxisUtils, TACustomSeries;
|
Math, TAChartAxisUtils, TACustomSeries;
|
||||||
|
|
||||||
constructor TChartLiveView.Create(AOwner: TComponent);
|
constructor TChartLiveView.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
@ -96,6 +98,17 @@ begin
|
|||||||
UpdateViewport;
|
UpdateViewport;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChartLiveView.RestoreAxisRange(Axis: TChartAxis);
|
||||||
|
begin
|
||||||
|
if Assigned(Axis) then
|
||||||
|
with FAxisRanges[Axis.Index] do begin
|
||||||
|
Axis.Range.Max := Max;
|
||||||
|
Axis.Range.Min := Min;
|
||||||
|
Axis.Range.UseMax := UseMax;
|
||||||
|
Axis.Range.UseMin := UseMin;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ The ChartLiveView may change the Range properties of an axis. The original
|
{ The ChartLiveView may change the Range properties of an axis. The original
|
||||||
values, before applying the live view, are restored here from internal
|
values, before applying the live view, are restored here from internal
|
||||||
variables.
|
variables.
|
||||||
@ -104,19 +117,12 @@ end;
|
|||||||
procedure TChartLiveView.RestoreAxisRanges;
|
procedure TChartLiveView.RestoreAxisRanges;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
ax: TChartAxis;
|
|
||||||
begin
|
begin
|
||||||
if FChart = nil then
|
if FChart = nil then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
for i := 0 to FChart.AxisList.Count-1 do
|
for i := 0 to FChart.AxisList.Count-1 do
|
||||||
begin
|
RestoreAxisRange(FChart.AxisList[i]);
|
||||||
ax := FChart.AxisList[i];
|
|
||||||
ax.Range.Max := FAxisRanges[i].Max;
|
|
||||||
ax.Range.Min := FAxisRanges[i].Min;
|
|
||||||
ax.Range.UseMax := FAxisRanges[i].UseMax;
|
|
||||||
ax.Range.UseMin := FAxisRanges[i].UseMin;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Activates the live view mode. Because the Range of the y axes can be changed
|
{ Activates the live view mode. Because the Range of the y axes can be changed
|
||||||
@ -170,6 +176,17 @@ begin
|
|||||||
FullExtentChanged(nil);
|
FullExtentChanged(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChartLiveView.StoreAxisRange(Axis: TChartAxis);
|
||||||
|
begin
|
||||||
|
if Assigned(Axis) then
|
||||||
|
with FAxisRanges[Axis.Index] do begin
|
||||||
|
Max := Axis.Range.Max;
|
||||||
|
Min := Axis.Range.Min;
|
||||||
|
UseMax := Axis.Range.UseMax;
|
||||||
|
UseMin := Axis.Range.UseMin;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ The ChartLiveView may change the Range properties of an axis. The original
|
{ The ChartLiveView may change the Range properties of an axis. The original
|
||||||
values, before applying the live view, are stored here in internal variables.
|
values, before applying the live view, are stored here in internal variables.
|
||||||
Be careful when calling this procedure in user code, it may disrupt the
|
Be careful when calling this procedure in user code, it may disrupt the
|
||||||
@ -177,17 +194,10 @@ end;
|
|||||||
procedure TChartLiveView.StoreAxisRanges;
|
procedure TChartLiveView.StoreAxisRanges;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
ax: TChartAxis;
|
|
||||||
begin
|
begin
|
||||||
SetLength(FAxisRanges, FChart.AxisList.Count);
|
SetLength(FAxisRanges, FChart.AxisList.Count);
|
||||||
for i := 0 to FChart.AxisList.Count-1 do
|
for i := 0 to FChart.AxisList.Count-1 do
|
||||||
begin
|
StoreAxisRange(FChart.AxisList[i]);
|
||||||
ax := FChart.AxisList[i];
|
|
||||||
FAxisRanges[i].Max := ax.Range.Max;
|
|
||||||
FAxisRanges[i].Min := ax.Range.Min;
|
|
||||||
FAxisRanges[i].UseMax := ax.Range.UseMax;
|
|
||||||
FAxisRanges[i].UseMin := ax.Range.UseMin;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ "Workhorse" method of the component. It calculates the logical extent and
|
{ "Workhorse" method of the component. It calculates the logical extent and
|
||||||
|
Loading…
Reference in New Issue
Block a user