diff --git a/components/tachart/demo/extent/extentdemo.lpi b/components/tachart/demo/extent/extentdemo.lpi index 7f51b55df6..52b7119957 100644 --- a/components/tachart/demo/extent/extentdemo.lpi +++ b/components/tachart/demo/extent/extentdemo.lpi @@ -53,13 +53,14 @@ + - + diff --git a/components/tachart/demo/extent/main.lfm b/components/tachart/demo/extent/main.lfm index 72394b5c46..bf7521e3da 100644 --- a/components/tachart/demo/extent/main.lfm +++ b/components/tachart/demo/extent/main.lfm @@ -7,7 +7,7 @@ object Form1: TForm1 ClientHeight = 397 ClientWidth = 396 OnCreate = FormCreate - LCLVersion = '0.9.31' + LCLVersion = '1.1' object Chart1: TChart Left = 0 Height = 307 @@ -16,16 +16,18 @@ object Form1: TForm1 AxisList = < item Grid.Visible = False + Minors = <> Title.LabelFont.Orientation = 900 end item - Alignment = calBottom Grid.Visible = False + Alignment = calBottom + Minors = <> end> - Extent.XMin = -1.7 - Extent.YMin = -1.7 Extent.XMax = 1.7 + Extent.XMin = -1.7 Extent.YMax = 1.7 + Extent.YMin = -1.7 Foot.Brush.Color = clBtnFace Foot.Font.Color = clBlue Title.Brush.Color = clBtnFace @@ -34,6 +36,7 @@ object Form1: TForm1 'TAChart' ) Toolset = ChartToolset1 + OnExtentChanged = Chart1ExtentChanged Align = alClient ParentColor = False object Chart1LineSeries: TLineSeries @@ -81,9 +84,9 @@ object Form1: TForm1 TabOrder = 1 object lblBoundValue: TLabel Left = 160 - Height = 14 + Height = 13 Top = 21 - Width = 27 + Width = 26 Caption = 'Value' ParentColor = False end @@ -103,6 +106,8 @@ object Form1: TForm1 ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 + ClientHeight = 70 + ClientWidth = 143 Items.Strings = ( 'Left' 'Right' @@ -127,6 +132,23 @@ object Form1: TForm1 TabOrder = 1 Value = 1.7 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 object RandomChartSource1: TRandomChartSource PointsNumber = 20 @@ -139,8 +161,8 @@ object Form1: TForm1 top = 118 end object ChartToolset1: TChartToolset - left = 328 - top = 332 + left = 336 + top = 320 object ChartToolset1PanDragTool1: TPanDragTool Shift = [ssRight] LimitToExtent = [pdLeft, pdUp, pdRight, pdDown] diff --git a/components/tachart/demo/extent/main.pas b/components/tachart/demo/extent/main.pas index e8f9c00ba4..d7dab25821 100644 --- a/components/tachart/demo/extent/main.pas +++ b/components/tachart/demo/extent/main.pas @@ -5,13 +5,15 @@ unit main; interface uses - ExtCtrls, Spin, StdCtrls, Forms, TAGraph, TASeries, TASources, TATools; + ExtCtrls, Spin, StdCtrls, Forms, TAGraph, TASeries, TASources, TATools, + TATypes; type { TForm1 } TForm1 = class(TForm) + btnPrevExtent: TButton; cgUseBounds: TCheckGroup; Chart1: TChart; ChartToolset1: TChartToolset; @@ -23,12 +25,18 @@ type clBottom: TConstantLine; Chart1LineSeries: TLineSeries; fseBounds: TFloatSpinEdit; + lblHistory: TLabel; lblBoundValue: TLabel; Panel1: TPanel; 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 fseBoundsChange(Sender: TObject); + private + FHistory: TChartExtentHistory; + FIsRemembering: Boolean; end; var @@ -38,10 +46,21 @@ implementation {$R *.lfm} +uses + SysUtils, TAChartUtils; + { TForm1 } -procedure TForm1.cgUseBoundsItemClick(Sender: TObject; Index: integer); +procedure TForm1.btnPrevExtentClick(Sender: TObject); 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 UseXMin := cgUseBounds.Checked[0]; UseXMax := cgUseBounds.Checked[1]; @@ -50,9 +69,23 @@ begin 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); begin fseBoundsChange(nil); + FHistory := TChartExtentHistory.Create; + FHistory.Capacity := 8; + FIsRemembering := true; end; procedure TForm1.fseBoundsChange(Sender: TObject);