mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 10:49:09 +02:00
TAChart: Use TChartExtentHistory in the "extent" demo
git-svn-id: trunk@38656 -
This commit is contained in:
parent
ba3925a8de
commit
6af3a1eb5d
@ -53,13 +53,14 @@
|
|||||||
<Filename Value="main.pas"/>
|
<Filename Value="main.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="Form1"/>
|
<ComponentName Value="Form1"/>
|
||||||
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="main"/>
|
<UnitName Value="main"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="10"/>
|
<Version Value="11"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
@ -7,7 +7,7 @@ object Form1: TForm1
|
|||||||
ClientHeight = 397
|
ClientHeight = 397
|
||||||
ClientWidth = 396
|
ClientWidth = 396
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
LCLVersion = '0.9.31'
|
LCLVersion = '1.1'
|
||||||
object Chart1: TChart
|
object Chart1: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 307
|
Height = 307
|
||||||
@ -16,16 +16,18 @@ object Form1: TForm1
|
|||||||
AxisList = <
|
AxisList = <
|
||||||
item
|
item
|
||||||
Grid.Visible = False
|
Grid.Visible = False
|
||||||
|
Minors = <>
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = calBottom
|
|
||||||
Grid.Visible = False
|
Grid.Visible = False
|
||||||
|
Alignment = calBottom
|
||||||
|
Minors = <>
|
||||||
end>
|
end>
|
||||||
Extent.XMin = -1.7
|
|
||||||
Extent.YMin = -1.7
|
|
||||||
Extent.XMax = 1.7
|
Extent.XMax = 1.7
|
||||||
|
Extent.XMin = -1.7
|
||||||
Extent.YMax = 1.7
|
Extent.YMax = 1.7
|
||||||
|
Extent.YMin = -1.7
|
||||||
Foot.Brush.Color = clBtnFace
|
Foot.Brush.Color = clBtnFace
|
||||||
Foot.Font.Color = clBlue
|
Foot.Font.Color = clBlue
|
||||||
Title.Brush.Color = clBtnFace
|
Title.Brush.Color = clBtnFace
|
||||||
@ -34,6 +36,7 @@ object Form1: TForm1
|
|||||||
'TAChart'
|
'TAChart'
|
||||||
)
|
)
|
||||||
Toolset = ChartToolset1
|
Toolset = ChartToolset1
|
||||||
|
OnExtentChanged = Chart1ExtentChanged
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
object Chart1LineSeries: TLineSeries
|
object Chart1LineSeries: TLineSeries
|
||||||
@ -81,9 +84,9 @@ object Form1: TForm1
|
|||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object lblBoundValue: TLabel
|
object lblBoundValue: TLabel
|
||||||
Left = 160
|
Left = 160
|
||||||
Height = 14
|
Height = 13
|
||||||
Top = 21
|
Top = 21
|
||||||
Width = 27
|
Width = 26
|
||||||
Caption = 'Value'
|
Caption = 'Value'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
@ -103,6 +106,8 @@ object Form1: TForm1
|
|||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 1
|
ChildSizing.ControlsPerLine = 1
|
||||||
|
ClientHeight = 70
|
||||||
|
ClientWidth = 143
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'Left'
|
'Left'
|
||||||
'Right'
|
'Right'
|
||||||
@ -127,6 +132,23 @@ object Form1: TForm1
|
|||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
Value = 1.7
|
Value = 1.7
|
||||||
end
|
end
|
||||||
|
object btnPrevExtent: TButton
|
||||||
|
Left = 159
|
||||||
|
Height = 25
|
||||||
|
Top = 49
|
||||||
|
Width = 95
|
||||||
|
Caption = 'Previous extent'
|
||||||
|
OnClick = btnPrevExtentClick
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
object lblHistory: TLabel
|
||||||
|
Left = 264
|
||||||
|
Height = 13
|
||||||
|
Top = 57
|
||||||
|
Width = 44
|
||||||
|
Caption = 'lblHistory'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object RandomChartSource1: TRandomChartSource
|
object RandomChartSource1: TRandomChartSource
|
||||||
PointsNumber = 20
|
PointsNumber = 20
|
||||||
@ -139,8 +161,8 @@ object Form1: TForm1
|
|||||||
top = 118
|
top = 118
|
||||||
end
|
end
|
||||||
object ChartToolset1: TChartToolset
|
object ChartToolset1: TChartToolset
|
||||||
left = 328
|
left = 336
|
||||||
top = 332
|
top = 320
|
||||||
object ChartToolset1PanDragTool1: TPanDragTool
|
object ChartToolset1PanDragTool1: TPanDragTool
|
||||||
Shift = [ssRight]
|
Shift = [ssRight]
|
||||||
LimitToExtent = [pdLeft, pdUp, pdRight, pdDown]
|
LimitToExtent = [pdLeft, pdUp, pdRight, pdDown]
|
||||||
|
@ -5,13 +5,15 @@ unit main;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ExtCtrls, Spin, StdCtrls, Forms, TAGraph, TASeries, TASources, TATools;
|
ExtCtrls, Spin, StdCtrls, Forms, TAGraph, TASeries, TASources, TATools,
|
||||||
|
TATypes;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
|
btnPrevExtent: TButton;
|
||||||
cgUseBounds: TCheckGroup;
|
cgUseBounds: TCheckGroup;
|
||||||
Chart1: TChart;
|
Chart1: TChart;
|
||||||
ChartToolset1: TChartToolset;
|
ChartToolset1: TChartToolset;
|
||||||
@ -23,12 +25,18 @@ type
|
|||||||
clBottom: TConstantLine;
|
clBottom: TConstantLine;
|
||||||
Chart1LineSeries: TLineSeries;
|
Chart1LineSeries: TLineSeries;
|
||||||
fseBounds: TFloatSpinEdit;
|
fseBounds: TFloatSpinEdit;
|
||||||
|
lblHistory: TLabel;
|
||||||
lblBoundValue: TLabel;
|
lblBoundValue: TLabel;
|
||||||
Panel1: TPanel;
|
Panel1: TPanel;
|
||||||
RandomChartSource1: TRandomChartSource;
|
RandomChartSource1: TRandomChartSource;
|
||||||
procedure cgUseBoundsItemClick(Sender: TObject; Index: integer);
|
procedure btnPrevExtentClick(Sender: TObject);
|
||||||
|
procedure cgUseBoundsItemClick(Sender: TObject; AIndex: integer);
|
||||||
|
procedure Chart1ExtentChanged(ASender: TChart);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure fseBoundsChange(Sender: TObject);
|
procedure fseBoundsChange(Sender: TObject);
|
||||||
|
private
|
||||||
|
FHistory: TChartExtentHistory;
|
||||||
|
FIsRemembering: Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -38,10 +46,21 @@ implementation
|
|||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, TAChartUtils;
|
||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
procedure TForm1.cgUseBoundsItemClick(Sender: TObject; Index: integer);
|
procedure TForm1.btnPrevExtentClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
FIsRemembering := FHistory.Count > 0;
|
||||||
|
if FIsRemembering then
|
||||||
|
Chart1.LogicalExtent := FHistory.Pop;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.cgUseBoundsItemClick(Sender: TObject; AIndex: integer);
|
||||||
|
begin
|
||||||
|
Unused(AIndex);
|
||||||
with Chart1.Extent do begin
|
with Chart1.Extent do begin
|
||||||
UseXMin := cgUseBounds.Checked[0];
|
UseXMin := cgUseBounds.Checked[0];
|
||||||
UseXMax := cgUseBounds.Checked[1];
|
UseXMax := cgUseBounds.Checked[1];
|
||||||
@ -50,9 +69,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.Chart1ExtentChanged(ASender: TChart);
|
||||||
|
begin
|
||||||
|
Unused(ASender);
|
||||||
|
if not FIsRemembering then
|
||||||
|
FHistory.Add(Chart1.PrevLogicalExtent);
|
||||||
|
FIsRemembering := false;
|
||||||
|
btnPrevExtent.Enabled := FHistory.Count > 0;
|
||||||
|
lblHistory.Caption := Format(
|
||||||
|
'History: %d of %d', [FHistory.Count, FHistory.Capacity]);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
fseBoundsChange(nil);
|
fseBoundsChange(nil);
|
||||||
|
FHistory := TChartExtentHistory.Create;
|
||||||
|
FHistory.Capacity := 8;
|
||||||
|
FIsRemembering := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.fseBoundsChange(Sender: TObject);
|
procedure TForm1.fseBoundsChange(Sender: TObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user