TAChart: Add "Pointers" page to the line demo

git-svn-id: trunk@29988 -
This commit is contained in:
ask 2011-03-23 06:40:01 +00:00
parent 038d161836
commit dead098042
2 changed files with 103 additions and 5 deletions

View File

@ -6,6 +6,7 @@ object Form1: TForm1
Caption = 'Form1'
ClientHeight = 479
ClientWidth = 645
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '0.9.31'
object PageControl2: TPageControl
@ -150,12 +151,12 @@ object Form1: TForm1
object tsStats: TTabSheet
Caption = 'Statistics'
ClientHeight = 453
ClientWidth = 581
ClientWidth = 637
object chCalc: TChart
Left = 0
Height = 453
Top = 0
Width = 581
Width = 637
AxisList = <
item
Title.LabelFont.Orientation = 900
@ -198,6 +199,62 @@ object Form1: TForm1
end
end
end
object tsPointers: TTabSheet
Caption = 'Pointers'
ClientHeight = 453
ClientWidth = 637
object chPointers: TChart
Left = 0
Height = 453
Top = 0
Width = 467
AxisList = <
item
Title.LabelFont.Orientation = 900
end
item
Alignment = calBottom
end>
AxisVisible = False
ExpandPercentage = 5
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
'TAChart'
)
Align = alClient
ParentColor = False
end
object pnlPointers: TPanel
Left = 467
Height = 453
Top = 0
Width = 170
Align = alRight
ClientHeight = 453
ClientWidth = 170
TabOrder = 1
object sePointerSize: TSpinEdit
Left = 49
Height = 21
Top = 6
Width = 50
OnChange = sePointerSizeChange
TabOrder = 0
Value = 4
end
object lblPointerSize: TLabel
Left = 9
Height = 14
Top = 10
Width = 20
Caption = 'Size'
ParentColor = False
end
end
end
end
object RandomChartSource1: TRandomChartSource
PointsNumber = 25

View File

@ -5,8 +5,8 @@ unit Main;
interface
uses
Classes, ComCtrls, ExtCtrls, StdCtrls, SysUtils, FileUtil, Forms, Controls,
Graphics, Dialogs, TAGraph, TASeries, TASources, TATools;
Classes, ComCtrls, ExtCtrls, Spin, StdCtrls, SysUtils, FileUtil, Forms,
Controls, Graphics, Dialogs, TAGraph, TASeries, TASources, TATools;
type
@ -21,6 +21,7 @@ type
cbSorted: TCheckBox;
ccsAvg: TCalculatedChartSource;
ccsSum: TCalculatedChartSource;
chPointers: TChart;
chCalc: TChart;
chCalcLineSeries1: TLineSeries;
chCalcLineSeriesAvg: TLineSeries;
@ -33,10 +34,14 @@ type
ChartToolset1PanDragTool1: TPanDragTool;
ChartToolset1ZoomDragTool1: TZoomDragTool;
edTime: TEdit;
lblPointerSize: TLabel;
lblPointsCount: TLabel;
PageControl2: TPageControl;
Panel1: TPanel;
pnlPointers: TPanel;
RandomChartSource1: TRandomChartSource;
sePointerSize: TSpinEdit;
tsPointers: TTabSheet;
tsStats: TTabSheet;
tsFast: TTabSheet;
procedure btnAddSeriesClick(Sender: TObject);
@ -45,6 +50,8 @@ type
procedure cbLineTypeChange(Sender: TObject);
procedure cbRotatedChange(Sender: TObject);
procedure cbSortedChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure sePointerSizeChange(Sender: TObject);
end;
var
@ -55,7 +62,7 @@ implementation
{$R *.lfm}
uses
LCLIntf;
LCLIntf, TATypes, TAChartUtils;
{ TForm1 }
@ -129,5 +136,39 @@ begin
ListSource.Sorted := cbSorted.Checked;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
st: TSeriesPointerStyle;
ls: TLineSeries;
s: ShortString;
begin
for st := Low(st) to High(st) do begin
ls := TLineSeries.Create(Self);
ls.LinePen.Color := clGreen;
ls.ShowPoints := true;
ls.Pointer.Pen.Color := clRed;
ls.Pointer.Style := st;
ls.AddXY(1, Ord(st));
Str(st, s);
ls.AddXY(10, Ord(st), s, clGreen);
ls.AddXY(19, Ord(st));
ls.Marks.Visible := true;
ls.Marks.Style := smsLabel;
ls.Marks.Distance := 4;
chPointers.AddSeries(ls);
end;
end;
procedure TForm1.sePointerSizeChange(Sender: TObject);
var
i: Integer;
begin
for i := 0 to chPointers.SeriesCount - 1 do
with (chPointers.Series[i] as TLineSeries).Pointer do begin
HorizSize := sePointerSize.Value;
VertSize := sePointerSize.Value;
end;
end;
end.