TAChart: Replace deprecated Reticule in demo/basic by a DataPointCrosshairTool.

git-svn-id: branches/fixes_2_0@60192 -
This commit is contained in:
mattias 2019-01-24 09:47:59 +00:00
parent 9790b72f61
commit a07eef42b0
2 changed files with 64 additions and 47 deletions

View File

@ -47,6 +47,7 @@ object Form1: TForm1
'Centered Chart Title'
)
Title.Visible = True
Toolset = ChartToolset1
Align = alClient
object Chart1LineHor: TConstantLine
Legend.Visible = False
@ -118,19 +119,6 @@ object Form1: TForm1
Caption = 'Add with marks:'
ParentColor = False
end
object lblReticule: TLabel
AnchorSideTop.Control = cbReticule
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbReticule
Left = 371
Height = 15
Top = 92
Width = 45
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Reticule:'
ParentColor = False
end
object btnAddPie: TButton
AnchorSideLeft.Control = btnClearPie
AnchorSideTop.Control = Panel1
@ -366,7 +354,6 @@ object Form1: TForm1
object cbMarkStyle: TComboBox
AnchorSideLeft.Control = lblMarkStyle
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbReticule
Left = 141
Height = 23
Top = 88
@ -392,30 +379,6 @@ object Form1: TForm1
TabOrder = 17
Text = 'smsLabelPercent'
end
object cbReticule: TComboBox
AnchorSideLeft.Control = cbLegend
AnchorSideTop.Control = cbShowGridCheckBox
AnchorSideTop.Side = asrBottom
Left = 424
Height = 23
Top = 88
Width = 156
BorderSpacing.Top = 4
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'rmNone'
'rmVertical'
'rmHorizontal'
'rmCross'
)
OnChange = cbReticuleChange
Style = csDropDownList
TabOrder = 18
Text = 'rmNone'
end
object btnClearAll: TButton
AnchorSideLeft.Control = btnClearLine
AnchorSideLeft.Side = asrBottom
@ -428,7 +391,45 @@ object Form1: TForm1
BorderSpacing.Left = 8
Caption = 'All'
OnClick = btnClearAllClick
TabOrder = 18
end
object lblCrossHairTool: TLabel
AnchorSideTop.Control = lblMarkStyle
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbCrosshairTool
Left = 340
Height = 15
Top = 92
Width = 76
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Crosshair tool:'
ParentColor = False
end
object cbCrosshairTool: TComboBox
AnchorSideLeft.Control = cbShowGridCheckBox
Left = 424
Height = 23
Top = 88
Width = 155
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'none'
'Vertical'
'Horizontal'
'Both'
)
OnChange = cbCrosshairToolChange
Style = csDropDownList
TabOrder = 19
Text = 'none'
end
end
object ChartToolset1: TChartToolset
left = 240
top = 115
object DataPointCrosshairTool: TDataPointCrosshairTool
end
end
end

View File

@ -6,7 +6,7 @@ interface
uses
SysUtils, Forms, Graphics, ExtCtrls,
TAGraph, TASeries, Buttons, StdCtrls, Spin;
TAGraph, TASeries, TATools, Buttons, StdCtrls, Spin, Classes;
type
{ TForm1 }
@ -21,7 +21,6 @@ type
btnAddPie: TButton;
btnAddLine: TButton;
btnAddArea: TButton;
cbReticule: TComboBox;
cbShowAxisTitles: TCheckBox;
Chart1: TChart;
cbBottomAxis: TCheckBox;
@ -34,11 +33,14 @@ type
Chart1LineHor: TConstantLine;
Chart1LineVert: TConstantLine;
cbMarkStyle: TComboBox;
ChartToolset1: TChartToolset;
DataPointCrosshairTool: TDataPointCrosshairTool;
cbCrosshairTool: TComboBox;
lblCrossHairTool: TLabel;
lblAddCount: TLabel;
lblAdd: TLabel;
lblMarkStyle: TLabel;
lblClear: TLabel;
lblReticule: TLabel;
Panel1: TPanel;
edAddCount: TSpinEdit;
procedure btnClearAllClick(Sender: TObject);
@ -46,6 +48,7 @@ type
procedure btnClearBarClick(Sender: TObject);
procedure btnClearLineClick(Sender: TObject);
procedure btnClearPieClick(Sender: TObject);
procedure cbCrosshairToolChange(Sender: TObject);
procedure cbInvertedChange(Sender: TObject);
procedure btnAddAreaClick(Sender: TObject);
procedure btnAddBarClick(Sender: TObject);
@ -53,7 +56,6 @@ type
procedure btnAddPieClick(Sender: TObject);
procedure cbBottomAxisChange(Sender: TObject);
procedure cbLeftAxisChange(Sender: TObject);
procedure cbReticuleChange(Sender: TObject);
procedure cbShowAxisTitlesChange(Sender: TObject);
procedure cbTitleChange(Sender: TObject);
procedure cbFooterChange(Sender: TObject);
@ -184,6 +186,25 @@ begin
FreeAndNil(FPie);
end;
procedure TForm1.cbCrosshairToolChange(Sender: TObject);
begin
DataPointCrosshairTool.Enabled := CbCrosshairTool.ItemIndex > 0;
case cbCrosshairTool.ItemIndex of
1: begin
DatapointCrosshairTool.Shape := ccsVertical;
DatapointCrosshairTool.DistanceMode := cdmOnlyX;
end;
2: begin
DatapointCrosshairTool.Shape := ccsHorizontal;
DatapointCrosshairTool.DistanceMode := cdmOnlyY;
end;
3: begin
DatapointCrosshairTool.Shape := ccsCross;
DatapointCrosshairTool.DistanceMode := cdmXY;
end;
end;
end;
procedure TForm1.cbBottomAxisChange(Sender: TObject);
begin
Chart1.BottomAxis.Visible := cbBottomAxis.Checked;
@ -205,11 +226,6 @@ begin
Chart1.Legend.Visible := cbLegend.Checked;
end;
procedure TForm1.cbReticuleChange(Sender: TObject);
begin
Chart1.ReticuleMode := TReticuleMode(cbReticule.ItemIndex);
end;
procedure TForm1.cbShowAxisTitlesChange(Sender: TObject);
begin
with Chart1.BottomAxis.Title do