TAChart: Update dragdrop demo to show Sorted property

git-svn-id: trunk@25913 -
This commit is contained in:
ask 2010-06-05 12:59:52 +00:00
parent cf2296e624
commit d940f2e95a
2 changed files with 40 additions and 19 deletions

View File

@ -1,18 +1,19 @@
object Form1: TForm1 object Form1: TForm1
Left = 739 Left = 404
Height = 300 Height = 481
Top = 341 Top = 180
Width = 400 Width = 483
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 300 ClientHeight = 481
ClientWidth = 400 ClientWidth = 483
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '0.9.29' LCLVersion = '0.9.29'
object Chart1: TChart object Chart1: TChart
Left = 0 Left = 0
Height = 300 Height = 447
Top = 0 Top = 34
Width = 400 Width = 483
AxisList = < AxisList = <
item item
Alignment = calLeft Alignment = calLeft
@ -26,8 +27,7 @@ object Form1: TForm1
Title.Brush.Color = clBtnFace Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue Title.Font.Color = clBlue
Title.Text.Strings = ( Title.Text.Strings = (
'You can drag data points' 'Drag data points while holding Shift key'
'while holding Shift key'
) )
Title.Visible = True Title.Visible = True
Toolset = ChartToolset1 Toolset = ChartToolset1
@ -38,7 +38,6 @@ object Form1: TForm1
Marks.Clipped = False Marks.Clipped = False
Marks.Format = '%0:.9g' Marks.Format = '%0:.9g'
Marks.Style = smsValue Marks.Style = smsValue
OnGetMark = Chart1LineSeries1GetMark
Pointer.Brush.Color = clPurple Pointer.Brush.Color = clPurple
Pointer.HorizSize = 6 Pointer.HorizSize = 6
Pointer.Style = psDiamond Pointer.Style = psDiamond
@ -47,6 +46,25 @@ object Form1: TForm1
ShowPoints = True ShowPoints = True
end end
end end
object Panel1: TPanel
Left = 0
Height = 34
Top = 0
Width = 483
Align = alTop
ClientHeight = 34
ClientWidth = 483
TabOrder = 1
object cbSorted: TCheckBox
Left = 12
Height = 17
Top = 8
Width = 52
Caption = 'Sorted'
OnChange = cbSortedChange
TabOrder = 0
end
end
object ChartToolset1: TChartToolset object ChartToolset1: TChartToolset
left = 99 left = 99
top = 129 top = 129

View File

@ -5,8 +5,8 @@ unit Main;
interface interface
uses uses
Classes, ExtCtrls, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Classes, ExtCtrls, StdCtrls, SysUtils, FileUtil, LResources, Forms, Controls,
Dialogs, TAGraph, TASeries, TATools; Graphics, Dialogs, TAGraph, TASeries, TATools;
type type
@ -17,12 +17,12 @@ type
Chart1LineSeries1: TLineSeries; Chart1LineSeries1: TLineSeries;
ChartToolset1: TChartToolset; ChartToolset1: TChartToolset;
ChartToolset1DataPointDragTool1: TDataPointDragTool; ChartToolset1DataPointDragTool1: TDataPointDragTool;
cbSorted: TCheckBox;
Panel1: TPanel;
procedure cbSortedChange(Sender: TObject);
procedure Chart1LineSeries1GetMark(out AFormattedMark: String; procedure Chart1LineSeries1GetMark(out AFormattedMark: String;
AIndex: Integer); AIndex: Integer);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
private
FDragIndex: Integer;
FNearestIndex: Integer;
end; end;
var var
@ -37,6 +37,11 @@ uses
{ TForm1 } { TForm1 }
procedure TForm1.cbSortedChange(Sender: TObject);
begin
Chart1LineSeries1.ListSource.Sorted := cbSorted.Checked;
end;
procedure TForm1.Chart1LineSeries1GetMark( procedure TForm1.Chart1LineSeries1GetMark(
out AFormattedMark: String; AIndex: Integer); out AFormattedMark: String; AIndex: Integer);
begin begin
@ -54,8 +59,6 @@ begin
RandSeed := 675402; RandSeed := 675402;
for i := 1 to 10 do for i := 1 to 10 do
Chart1LineSeries1.AddXY(i, Random(20) - 10); Chart1LineSeries1.AddXY(i, Random(20) - 10);
FDragIndex := -1;
FNearestIndex := -1;
end; end;
end. end.