unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, TeeTools, TeEngine, Series, TeeGanttTool,
  TeeDragPoint, ExtCtrls, TeeProcs, Chart, TeeSurfaceTool,
  TeeSeriesBandTool, TeePieTool, TeeExtraLegendTool, ComCtrls, Grids,
  TeeChartGrid, Spin, TeeLegendScrollBar;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Panel1: TPanel;
    Button5: TButton;
    PageControl1: TPageControl;
    GroupBox1: TGroupBox;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    GroupBox2: TGroupBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Label1: TLabel;
    GroupBox3: TGroupBox;
    GroupBox4: TGroupBox;
    Chart2: TChart;
    CheckBox1: TCheckBox;
    CheckBox5: TCheckBox;
    Series1: TLineSeries;
    Series2: TLineSeries;
    Series3: TLineSeries;
    Series4: TLineSeries;
    CheckBox11: TCheckBox;
    CheckBox12: TCheckBox;
    ComboBox1: TComboBox;
    Label2: TLabel;
    ChartGrid1: TChartGrid;
    CheckBox2: TCheckBox;
    CheckBox13: TCheckBox;
    CheckBox3: TCheckBox;
    ChartTool1: TCursorTool;
    ChartTool3: TCursorTool;
    ChartTool2: TDragPointTool;
    ChartTool4: TDragPointTool;
    ChartTool5: TDragMarksTool;
    ChartTool6: TDragMarksTool;
    ChartTool7: TMarksTipTool;
    ChartTool8: TMarksTipTool;
    ChartTool9: TExtraLegendTool;
    ChartTool10: TExtraLegendTool;
    ChartTool11: TNearestTool;
    ChartTool12: TNearestTool;
    TabSheet4: TTabSheet;
    CheckBox14: TCheckBox;
    GroupBox5: TGroupBox;
    RadioGroup1: TRadioGroup;
    Label3: TLabel;
    SpinEdit1: TSpinEdit;
    Label4: TLabel;
    ComboBox2: TComboBox;
    TabSheet5: TTabSheet;
    GroupBox6: TGroupBox;
    CheckBox15: TCheckBox;
    CheckBox4: TCheckBox;
    TabSheet6: TTabSheet;
    GroupBox7: TGroupBox;
    CheckBox16: TCheckBox;
    Label5: TLabel;
    ComboBox3: TComboBox;
    CheckBox6: TCheckBox;
    Button6: TButton;
    ColorDialog1: TColorDialog;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure ChartTool1Change(Sender: TCursorTool; x, y: Integer;
      const XValue, YValue: Double; Series: TChartSeries;
      ValueIndex: Integer);
    procedure ChartTool3Change(Sender: TCursorTool; x, y: Integer;
      const XValue, YValue: Double; Series: TChartSeries;
      ValueIndex: Integer);
    procedure CheckBox5Click(Sender: TObject);
    procedure CheckBox11Click(Sender: TObject);
    procedure CheckBox12Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);

    procedure Chart2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure ChartTool4DragPoint(Sender: TDragPointTool; Index: Integer);
    procedure ChartTool2DragPoint(Sender: TDragPointTool; Index: Integer);
    procedure CheckBox3Click(Sender: TObject);
    procedure CheckBox13Click(Sender: TObject);
    procedure CheckBox14Click(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);
    procedure ComboBox2Change(Sender: TObject);
    procedure CheckBox15Click(Sender: TObject);
    procedure CheckBox4Click(Sender: TObject);
    procedure CheckBox16Click(Sender: TObject);
    procedure CheckBox6Click(Sender: TObject);
    procedure ComboBox3Change(Sender: TObject);
    procedure Button6Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin //程序左移
ChartTool1.XValue :=  ChartTool1.XValue-1;
ChartTool3.XValue :=  ChartTool3.XValue-1;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin   //程序右移
ChartTool1.XValue :=  ChartTool1.XValue+1;
ChartTool3.XValue :=  ChartTool3.XValue+1;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin     //程序上移
ChartTool1.YValue :=  ChartTool1.YValue+5;
ChartTool3.YValue :=  ChartTool3.YValue+5;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin       //程序下移
ChartTool1.YValue :=  ChartTool1.YValue-5;
ChartTool3.YValue :=  ChartTool3.YValue-5;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
begin
ChartTool1.Active := false; //光标Chart1
ChartTool3.Active := false; //光标Chart2
ChartTool2.Active := false; //拖点Chart1
ChartTool4.Active := false; //拖点Chart2
ChartTool5.Active := false; //拖标签Chart2
ChartTool6.Active := false; //拖标签Chart2
ChartTool7.Active := false; //提示Chart2
ChartTool8.Active := false; //提示Chart2
ChartTool9.Active := false; //附加图例Chart2
ChartTool10.Active := false; //附加图例Chart2
ChartTool12.Active := false; //最近点Chart1
ChartTool11.Active := false; //附加图例Chart2



Series1.FillSampleValues(20);
Series2.FillSampleValues(20);
Chart1.Refresh;
for i:= 0 to Series1.Count-1 do
  begin
  Series3.AddY(Series1.YValue[i]);
  Series4.AddY(Series2.YValue[i]);
  end;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
Label1.Caption := Inttostr(X)+','+Inttostr(Y);
end;



procedure TForm1.CheckBox1Click(Sender: TObject);
begin  //鼠标跟随控制是否程序控制光标移动
ChartTool1.FollowMouse := CheckBox1.Checked;
ChartTool3.FollowMouse := CheckBox1.Checked;
if CheckBox1.Checked then
  begin
  Button1.Enabled := false;
  Button2.Enabled := false;
  Button3.Enabled := false;
  Button4.Enabled := false;
  end
  else
  begin
  Button1.Enabled := true;
  Button2.Enabled := true;
  Button3.Enabled := true;
  Button4.Enabled := true;
  end;
end;

procedure TForm1.CheckBox2Click(Sender: TObject);
begin  //三维
Chart1.View3D := CheckBox2.Checked;
Chart2.View3D := CheckBox2.Checked;
end;



procedure TForm1.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
if CheckBox1.Checked then
  begin
  ChartTool3.XValue :=  XValue;
  ChartTool3.YValue :=  YValue;
  end;
end;

procedure TForm1.ChartTool3Change(Sender: TCursorTool; x, y: Integer;
  const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
if CheckBox1.Checked then
  begin
  ChartTool1.XValue := XValue;
  ChartTool1.YValue := YValue;
  end;
end;

procedure TForm1.CheckBox5Click(Sender: TObject);
begin
ChartTool1.FollowMouse := CheckBox5.Checked;
ChartTool3.FollowMouse := CheckBox5.Checked;
end;

procedure TForm1.CheckBox11Click(Sender: TObject);
begin //激活光标
Chart1.Title.Text.Text := '光标同步工具演示';
Chart2.Title.Text.Text := '光标同步工具演示';
ChartTool1.Active := CheckBox11.Checked; //光标Chart1
ChartTool3.Active := CheckBox11.Checked; //光标Chart2
PageControl1.ActivePage := TabSheet1;
end;

procedure TForm1.CheckBox12Click(Sender: TObject);
begin
Chart1.Title.Text.Text := '拖点工具演示';
Chart2.Title.Text.Text := '拖点工具演示';
ChartTool2.Active := CheckBox12.Checked; //拖点Chart1
ChartTool4.Active := CheckBox12.Checked; //拖点Chart2
Series1.Pointer.Visible := CheckBox12.Checked;
Series3.Pointer.Visible := CheckBox12.Checked;
ChartTool2.Series := Series1;
ChartTool4.Series := Series3;
ChartTool2.DragStyle := dsY;
ChartTool4.DragStyle := dsY;
PageControl1.ActivePage := TabSheet2;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
case ComboBox1.ItemIndex of
0:
  begin
  ChartTool2.DragStyle := dsX;
  ChartTool4.DragStyle := dsX;
  end;
1:
  begin
  ChartTool2.DragStyle := dsY;
  ChartTool4.DragStyle := dsY;
  end;
2:
  begin
  ChartTool2.DragStyle := dsBoth;
  ChartTool4.DragStyle := dsBoth;
  end;
end;
end;





procedure TForm1.Chart2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
Label1.Caption := Inttostr(X)+','+Inttostr(Y);
end;

procedure TForm1.ChartTool4DragPoint(Sender: TDragPointTool;
  Index: Integer);
begin  //拖点时两个Chart同步
Series1.YValue[Index] := ChartTool4.Series.YValue[Index];
Series1.XValue[Index] := ChartTool4.Series.XValue[Index];
end;

procedure TForm1.ChartTool2DragPoint(Sender: TDragPointTool;
  Index: Integer);
begin   //拖点时两个Chart同步
Series3.YValue[Index] := ChartTool2.Series.YValue[Index];
Series3.XValue[Index] := ChartTool2.Series.XValue[Index];
end;



procedure TForm1.CheckBox3Click(Sender: TObject);
begin
Series1.Marks.Visible :=  CheckBox3.Checked;
Series3.Marks.Visible :=  CheckBox3.Checked;
end;



procedure TForm1.CheckBox13Click(Sender: TObject);
begin  //拖标签
Chart1.Title.Text.Text := '拖标签工具演示';
Chart2.Title.Text.Text := '拖标签工具演示';
ChartTool5.Active := CheckBox13.Checked; //拖标签Chart1
ChartTool6.Active := CheckBox13.Checked; //拖标签Chart2
Series1.Marks.Visible :=  CheckBox13.Checked;
Series3.Marks.Visible :=  CheckBox13.Checked;
CheckBox3.Checked := CheckBox13.Checked;
PageControl1.ActivePage := TabSheet3;
end;

procedure TForm1.CheckBox14Click(Sender: TObject);
begin  //提示签工具
Chart1.Title.Text.Text := '提示签工具演示';
Chart2.Title.Text.Text := '提示签工具演示';
ChartTool7.Active := CheckBox14.Checked; //提示签Chart1
ChartTool8.Active := CheckBox14.Checked; //提示签Chart2
PageControl1.ActivePage := TabSheet4;
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin  //鼠标移动、单击时提示
case  RadioGroup1.ItemIndex of
0:
  begin
  ChartTool7.MouseAction := mtmMove;
  ChartTool8.MouseAction := mtmMove;
  end;
1:
  begin
  ChartTool7.MouseAction := mtmClick;
  ChartTool8.MouseAction := mtmClick;
  end;
end;
end;

procedure TForm1.SpinEdit1Change(Sender: TObject);
begin    //提示签延迟
ChartTool7.MouseDelay := SpinEdit1.Value;
ChartTool8.MouseDelay := SpinEdit1.Value;
end;

procedure TForm1.ComboBox2Change(Sender: TObject);
begin
case  ComboBox2.ItemIndex of
0:ChartTool7.Style :=smsValue;             { 1234 }
1:ChartTool7.Style :=smsPercent;           { 12 % }
2:ChartTool7.Style :=smsLabel;             { Cars }
3:ChartTool7.Style :=smsLabelPercent;      { Cars 12 % }
4:ChartTool7.Style := smsLabelValue;        { Cars 1234 }
5:ChartTool7.Style := smsLegend;            { (Legend.Style) }
6:ChartTool7.Style := smsPercentTotal;      { 12 % of 1234 }
7:ChartTool7.Style := smsLabelPercentTotal; { Cars 12 % of 1234 }
8:ChartTool7.Style := smsXValue;            { 1..2..3.. or 21/6/1996 }
9:ChartTool7.Style := smsXY;                 { 123 456 }
end;
case  ComboBox2.ItemIndex of
0:ChartTool8.Style :=smsValue;             { 1234 }
1:ChartTool8.Style :=smsPercent;           { 12 % }
2:ChartTool8.Style :=smsLabel;             { Cars }
3:ChartTool8.Style :=smsLabelPercent;      { Cars 12 % }
4:ChartTool8.Style := smsLabelValue;        { Cars 1234 }
5:ChartTool8.Style := smsLegend;            { (Legend.Style) }
6:ChartTool8.Style := smsPercentTotal;      { 12 % of 1234 }
7:ChartTool8.Style := smsLabelPercentTotal; { Cars 12 % of 1234 }
8:ChartTool8.Style := smsXValue;            { 1..2..3.. or 21/6/1996 }
9:ChartTool8.Style := smsXY;                 { 123 456 }
end;


end;

procedure TForm1.CheckBox15Click(Sender: TObject);
begin  //附加图例工具
Chart1.Title.Text.Text := '附加图例演示';
Chart2.Title.Text.Text := '附加图例演示';
ChartTool9.Active := CheckBox15.Checked; //提示签Chart1
ChartTool10.Active := CheckBox15.Checked; //提示签Chart2
PageControl1.ActivePage := TabSheet5;
end;

procedure TForm1.CheckBox4Click(Sender: TObject);
begin
Chart1.Legend.Visible := CheckBox4.Checked;
Chart2.Legend.Visible := CheckBox4.Checked;
end;

procedure TForm1.CheckBox16Click(Sender: TObject);
begin   //最近点工具
Chart1.Title.Text.Text := '最近点工具演示';
Chart2.Title.Text.Text := '最近点工具演示';
ChartTool12.Active := CheckBox16.Checked; //最近点Chart1
ChartTool11.Active := CheckBox16.Checked; //最近点Chart2
PageControl1.ActivePage := TabSheet6;
end;

procedure TForm1.CheckBox6Click(Sender: TObject);
begin //最近点带连线
ChartTool11.DrawLine :=CheckBox6.Checked;
ChartTool12.DrawLine :=CheckBox6.Checked;
end;

procedure TForm1.ComboBox3Change(Sender: TObject);
begin
  ChartTool11.Style := TNearestToolStyle(ComboBox3.ItemIndex);
  ChartTool12.Style := TNearestToolStyle(ComboBox3.ItemIndex);
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
if ColorDialog1.Execute then
  begin
   ChartTool11.LinePen.Color :=  ColorDialog1.Color;
   ChartTool12.LinePen.Color :=  ColorDialog1.Color;
   ChartTool11.Pen.Color :=  ColorDialog1.Color;
   ChartTool12.Pen.Color :=  ColorDialog1.Color;
  end;
end;

end.
