随笔 - 32  文章 - 0 评论 - 3 trackbacks - 0

 

 界面代码:

object Form1: TForm1
  Left = 252
  Top = 190
  Width = 1149
  Height = 549
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = GB2312_CHARSET
  Font.Color = clWindowText
  Font.Height = -13
  Font.Name = '宋体'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Chart1: TChart
    Left = 0
    Top = 0
    Width = 472
    Height = 426
    BottomWall.Gradient.EndColor = 14285190
    BottomWall.Gradient.MidColor = clSilver
    BottomWall.Gradient.StartColor = 1415426
    BottomWall.Gradient.Visible = True
    Gradient.EndColor = 14285190
    Gradient.MidColor = clSilver
    Gradient.StartColor = 1415426
    Gradient.Visible = True
    LeftWall.Gradient.EndColor = 14285190
    LeftWall.Gradient.MidColor = clSilver
    LeftWall.Gradient.StartColor = 1415426
    LeftWall.Gradient.Visible = True
    Legend.CheckBoxes = True
    Legend.Visible = False
    Title.Text.Strings = (
      '光标同步演示')
    Chart3DPercent = 45
    Align = alLeft
    BevelInner = bvLowered
    BevelWidth = 2
    TabOrder = 0
    OnMouseMove = Chart1MouseMove
    object Series1: TLineSeries
      Cursor = crHandPoint
      Marks.Callout.Brush.Color = clBlack
      Marks.Callout.Length = 20
      Marks.Visible = False
      PercentFormat = '##0,## %'
      LinePen.Color = clRed
      LinePen.Width = 2
      Pointer.InflateMargins = True
      Pointer.Style = psRectangle
      Pointer.Visible = False
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Y'
      YValues.Order = loNone
    end
    object Series2: TLineSeries
      Active = False
      Marks.Callout.Brush.Color = clBlack
      Marks.Visible = False
      LinePen.Color = clGreen
      LinePen.Width = 2
      Pointer.InflateMargins = True
      Pointer.Style = psRectangle
      Pointer.Visible = False
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Y'
      YValues.Order = loNone
    end
    object ChartTool1: TCursorTool
      FollowMouse = True
      Pen.Width = 2
      Series = Series1
      OnChange = ChartTool1Change
    end
    object ChartTool2: TDragPointTool
      Series = Series1
      OnDragPoint = ChartTool2DragPoint
    end
    object ChartTool5: TDragMarksTool
    end
    object ChartTool8: TMarksTipTool
      MouseDelay = 250
    end
    object ChartTool9: TExtraLegendTool
      Legend.CustomPosition = True
      Legend.Left = 0
      Legend.LegendStyle = lsValues
      Legend.Top = 0
      Series = Series1
    end
    object ChartTool12: TNearestTool
      Brush.Color = clWhite
      Brush.Style = bsClear
      Pen.Color = clWhite
      Pen.Style = psDot
      Series = Series1
    end
  end
  object Panel1: TPanel
    Left = 0
    Top = 426
    Width = 1141
    Height = 86
    Align = alBottom
    BevelInner = bvLowered
    TabOrder = 1
    object Button5: TButton
      Left = 749
      Top = 14
      Width = 81
      Height = 55
      Caption = '&E.退出'
      TabOrder = 0
      OnClick = Button5Click
    end
    object GroupBox1: TGroupBox
      Left = 16
      Top = 8
      Width = 721
      Height = 65
      TabOrder = 1
      object CheckBox11: TCheckBox
        Left = 16
        Top = 16
        Width = 73
        Height = 17
        Caption = '光标工具'
        TabOrder = 0
        OnClick = CheckBox11Click
      end
      object CheckBox12: TCheckBox
        Left = 16
        Top = 40
        Width = 73
        Height = 17
        Caption = '拖点工具'
        TabOrder = 1
        OnClick = CheckBox12Click
      end
      object CheckBox2: TCheckBox
        Left = 416
        Top = 24
        Width = 41
        Height = 17
        Caption = '3D'
        Checked = True
        State = cbChecked
        TabOrder = 2
        OnClick = CheckBox2Click
      end
      object CheckBox13: TCheckBox
        Left = 128
        Top = 16
        Width = 105
        Height = 17
        Caption = '拖标签工具'
        TabOrder = 3
        OnClick = CheckBox13Click
      end
      object CheckBox14: TCheckBox
        Left = 128
        Top = 40
        Width = 105
        Height = 17
        Caption = '提示签工具'
        TabOrder = 4
        OnClick = CheckBox14Click
      end
      object CheckBox15: TCheckBox
        Left = 256
        Top = 16
        Width = 97
        Height = 17
        Caption = '附加图例工具'
        TabOrder = 5
        OnClick = CheckBox15Click
      end
      object CheckBox16: TCheckBox
        Left = 256
        Top = 39
        Width = 97
        Height = 17
        Caption = '最近点工具'
        TabOrder = 6
        OnClick = CheckBox16Click
      end
    end
  end
  object PageControl1: TPageControl
    Left = 944
    Top = 0
    Width = 197
    Height = 426
    ActivePage = TabSheet6
    Align = alClient
    MultiLine = True
    TabOrder = 2
    object TabSheet1: TTabSheet
      Caption = '光标工具'
      object GroupBox2: TGroupBox
        Left = 8
        Top = 0
        Width = 169
        Height = 225
        TabOrder = 0
        object Label1: TLabel
          Left = 2
          Top = 200
          Width = 165
          Height = 23
          Align = alBottom
          Alignment = taCenter
          AutoSize = False
          Color = clInfoBk
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clMaroon
          Font.Height = -16
          Font.Name = 'MS Sans Serif'
          Font.Style = [fsItalic]
          ParentColor = False
          ParentFont = False
        end
        object Button1: TButton
          Left = 33
          Top = 50
          Width = 49
          Height = 25
          Caption = '左←'
          TabOrder = 0
          OnClick = Button1Click
        end
        object Button2: TButton
          Left = 89
          Top = 50
          Width = 49
          Height = 25
          Caption = '右→'
          TabOrder = 1
          OnClick = Button2Click
        end
        object Button3: TButton
          Left = 60
          Top = 18
          Width = 49
          Height = 25
          Caption = '上↑'
          TabOrder = 2
          OnClick = Button3Click
        end
        object Button4: TButton
          Left = 60
          Top = 80
          Width = 49
          Height = 25
          Caption = '下↓'
          TabOrder = 3
          OnClick = Button4Click
        end
        object CheckBox1: TCheckBox
          Left = 61
          Top = 120
          Width = 57
          Height = 17
          Caption = '同步'
          Checked = True
          State = cbChecked
          TabOrder = 4
          OnClick = CheckBox1Click
        end
        object CheckBox5: TCheckBox
          Left = 61
          Top = 144
          Width = 81
          Height = 22
          Caption = '鼠标跟随'
          Checked = True
          State = cbChecked
          TabOrder = 5
          OnClick = CheckBox5Click
        end
      end
    end
    object TabSheet2: TTabSheet
      Caption = '拖点工具'
      ImageIndex = 1
      object GroupBox3: TGroupBox
        Left = 16
        Top = 8
        Width = 161
        Height = 241
        TabOrder = 0
        object Label2: TLabel
          Left = 13
          Top = 12
          Width = 39
          Height = 13
          Caption = '风格:'
        end
        object ComboBox1: TComboBox
          Left = 13
          Top = 31
          Width = 129
          Height = 21
          ItemHeight = 13
          ItemIndex = 1
          TabOrder = 0
          Text = 'Y only'
          OnChange = ComboBox1Change
          Items.Strings = (
            'X only'
            'Y only'
            'X and Y')
        end
        object ChartGrid1: TChartGrid
          Left = 12
          Top = 64
          Width = 136
          Height = 161
          Options = [goVertLine, goHorzLine, goRangeSelect, goDrawFocusSelected, goRowSizing, goColSizing, goEditing, goTabs, goThumbTracking]
          TabOrder = 1
          Chart = Chart1
        end
      end
    end
    object TabSheet3: TTabSheet
      Caption = '拖标签工具'
      ImageIndex = 2
      object GroupBox4: TGroupBox
        Left = 16
        Top = 8
        Width = 160
        Height = 225
        TabOrder = 0
        object CheckBox3: TCheckBox
          Left = 48
          Top = 48
          Width = 65
          Height = 17
          Caption = '标签'
          Checked = True
          State = cbChecked
          TabOrder = 0
          OnClick = CheckBox3Click
        end
      end
    end
    object TabSheet4: TTabSheet
      Caption = '提示签工具'
      ImageIndex = 3
      object GroupBox5: TGroupBox
        Left = 16
        Top = 8
        Width = 153
        Height = 209
        TabOrder = 0
        object Label3: TLabel
          Left = 16
          Top = 92
          Width = 79
          Height = 13
          Caption = '延迟(ms):'
        end
        object Label4: TLabel
          Left = 16
          Top = 148
          Width = 65
          Height = 13
          Caption = '提示风格:'
        end
        object RadioGroup1: TRadioGroup
          Left = 16
          Top = 16
          Width = 113
          Height = 65
          Caption = '在下列情形提示'
          ItemIndex = 0
          Items.Strings = (
            '移动时'
            '点击时')
          TabOrder = 0
          OnClick = RadioGroup1Click
        end
        object SpinEdit1: TSpinEdit
          Left = 16
          Top = 112
          Width = 113
          Height = 22
          MaxValue = 0
          MinValue = 0
          TabOrder = 1
          Value = 10
          OnChange = SpinEdit1Change
        end
        object ComboBox2: TComboBox
          Left = 16
          Top = 176
          Width = 113
          Height = 21
          ItemHeight = 13
          ItemIndex = 0
          TabOrder = 2
          Text = 'Value          { 1234 }'
          OnChange = ComboBox2Change
          Items.Strings = (
            'Value          { 1234 }'
            'Percent,       { 12 % }'
            'Label,         { Cars }'
            'LabelPercent,  { Cars 12 % }'
            'LabelValue,    { Cars 1234 }'
            'Legend,        { (Legend.Style) }'
            'PercentTotal,  { 12 % of 1234 }'
            'XValue,        { 1..2..3.. or 21/6/1996 }'
            'XY             { 123 456 }')
        end
      end
    end
    object TabSheet5: TTabSheet
      Caption = '附加图例工具'
      ImageIndex = 4
      object GroupBox6: TGroupBox
        Left = 16
        Top = 8
        Width = 161
        Height = 201
        TabOrder = 0
        object CheckBox4: TCheckBox
          Left = 48
          Top = 104
          Width = 57
          Height = 17
          Caption = '图例'
          TabOrder = 0
          OnClick = CheckBox4Click
        end
      end
    end
    object TabSheet6: TTabSheet
      Caption = '最近点工具'
      ImageIndex = 5
      object GroupBox7: TGroupBox
        Left = 17
        Top = 16
        Width = 152
        Height = 201
        TabOrder = 0
        object Label5: TLabel
          Left = 16
          Top = 16
          Width = 39
          Height = 13
          Caption = '风格:'
        end
        object ComboBox3: TComboBox
          Left = 16
          Top = 32
          Width = 121
          Height = 21
          ItemHeight = 13
          TabOrder = 0
          Text = 'Circle'
          OnChange = ComboBox3Change
          Items.Strings = (
            'None'
            'Circle'
            'Rectangle'
            'Diamond')
        end
        object CheckBox6: TCheckBox
          Left = 16
          Top = 80
          Width = 97
          Height = 17
          Caption = '连线'
          Checked = True
          State = cbChecked
          TabOrder = 1
          OnClick = CheckBox6Click
        end
        object Button6: TButton
          Left = 16
          Top = 152
          Width = 75
          Height = 25
          Caption = '笔颜色...'
          TabOrder = 2
          OnClick = Button6Click
        end
      end
    end
  end
  object Chart2: TChart
    Left = 472
    Top = 0
    Width = 472
    Height = 426
    BottomWall.Gradient.EndColor = 14285190
    BottomWall.Gradient.MidColor = clSilver
    BottomWall.Gradient.StartColor = 1415426
    BottomWall.Gradient.Visible = True
    Gradient.EndColor = 14285190
    Gradient.MidColor = clSilver
    Gradient.StartColor = 1415426
    Gradient.Visible = True
    LeftWall.Gradient.EndColor = 14285190
    LeftWall.Gradient.MidColor = clSilver
    LeftWall.Gradient.StartColor = 1415426
    LeftWall.Gradient.Visible = True
    Legend.CheckBoxes = True
    Legend.Visible = False
    Title.Text.Strings = (
      '光标同步演示')
    Chart3DPercent = 35
    Align = alLeft
    BevelInner = bvLowered
    BevelWidth = 2
    TabOrder = 3
    OnMouseMove = Chart2MouseMove
    object Series3: TLineSeries
      Cursor = crHandPoint
      Marks.Callout.Brush.Color = clBlack
      Marks.Visible = False
      LinePen.Color = clRed
      LinePen.Width = 2
      Pointer.InflateMargins = True
      Pointer.Style = psRectangle
      Pointer.Visible = False
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Y'
      YValues.Order = loNone
    end
    object Series4: TLineSeries
      Active = False
      Marks.Callout.Brush.Color = clBlack
      Marks.Visible = False
      LinePen.Color = clGreen
      LinePen.Width = 2
      Pointer.InflateMargins = True
      Pointer.Style = psRectangle
      Pointer.Visible = False
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Y'
      YValues.Order = loNone
    end
    object ChartTool3: TCursorTool
      Pen.Width = 2
      Series = Series3
      OnChange = ChartTool3Change
    end
    object ChartTool4: TDragPointTool
      Series = Series3
      OnDragPoint = ChartTool4DragPoint
    end
    object ChartTool6: TDragMarksTool
    end
    object ChartTool7: TMarksTipTool
      MouseDelay = 250
    end
    object ChartTool10: TExtraLegendTool
      Legend.CustomPosition = True
      Legend.Left = 0
      Legend.LegendStyle = lsValues
      Legend.ResizeChart = False
      Legend.Top = 0
      Series = Series4
    end
    object ChartTool11: TNearestTool
      Brush.Color = clWhite
      Brush.Style = bsClear
      Pen.Color = clWhite
      Pen.Style = psDot
      Series = Series3
    end
  end
  object ColorDialog1: TColorDialog
    Left = 532
    Top = 228
  end
end
View Code

功能代码:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TLineSeries;
    Series2: TLineSeries;
    ChartTool2: TDragPointTool;
    ChartTool5: TDragMarksTool;
    ChartTool8: TMarksTipTool;
    ChartTool9: TExtraLegendTool;
    ChartTool12: TNearestTool;
    Panel1: TPanel;
    Button5: TButton;
    GroupBox1: TGroupBox;
    CheckBox11: TCheckBox;
    CheckBox12: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox13: TCheckBox;
    CheckBox14: TCheckBox;
    CheckBox15: TCheckBox;
    CheckBox16: TCheckBox;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    CheckBox1: TCheckBox;
    CheckBox5: TCheckBox;
    TabSheet2: TTabSheet;
    GroupBox3: TGroupBox;
    Label2: TLabel;
    ComboBox1: TComboBox;
    ChartGrid1: TChartGrid;
    TabSheet3: TTabSheet;
    GroupBox4: TGroupBox;
    CheckBox3: TCheckBox;
    TabSheet4: TTabSheet;
    GroupBox5: TGroupBox;
    Label3: TLabel;
    Label4: TLabel;
    RadioGroup1: TRadioGroup;
    SpinEdit1: TSpinEdit;
    ComboBox2: TComboBox;
    TabSheet5: TTabSheet;
    GroupBox6: TGroupBox;
    CheckBox4: TCheckBox;
    TabSheet6: TTabSheet;
    GroupBox7: TGroupBox;
    Label5: TLabel;
    ComboBox3: TComboBox;
    CheckBox6: TCheckBox;
    Button6: TButton;
    Chart2: TChart;
    Series3: TLineSeries;
    Series4: TLineSeries;
    ChartTool3: TCursorTool;
    ChartTool4: TDragPointTool;
    ChartTool6: TDragMarksTool;
    ChartTool7: TMarksTipTool;
    ChartTool10: TExtraLegendTool;
    ChartTool11: TNearestTool;
    ColorDialog1: TColorDialog;
    ChartTool1: TCursorTool;
    procedure FormCreate(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure CheckBox11Click(Sender: TObject);
    procedure CheckBox12Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox5Click(Sender: TObject);
    procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure CheckBox13Click(Sender: TObject);
    procedure CheckBox3Click(Sender: TObject);
    procedure CheckBox14Click(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);
    procedure ComboBox2Change(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CheckBox15Click(Sender: TObject);
    procedure CheckBox4Click(Sender: TObject);
    procedure CheckBox16Click(Sender: TObject);
    procedure ComboBox3Change(Sender: TObject);
    procedure CheckBox6Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure ChartTool2DragPoint(Sender: TDragPointTool; Index: Integer);
    procedure ChartTool4DragPoint(Sender: TDragPointTool; Index: Integer);
    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 Chart2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  Position := poScreenCenter;
  BorderStyle := bsDialog;
  Caption := '序列类工具(Series Tools)功能演示';

  ChartTool1.Active := False;
  ChartTool3.Active := False;
  ChartTool2.Active := False;
  ChartTool4.Active := False;
  ChartTool5.Active := False;
  ChartTool6.Active := False;
  ChartTool8.Active := False;
  ChartTool7.Active := False;
  ChartTool9.Active := False;
  ChartTool10.Active := False;
  ChartTool12.Active := False;
  ChartTool11.Active := False;

  Series1.FillSampleValues(40);
  Series2.FillSampleValues(40);
  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.Button1Click(Sender: TObject);
begin
  ChartTool1.XValue := ChartTool1.XValue - 1;
  ChartTool3.XValue := ChartTool3.XValue - 1;
end;

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

procedure TForm1.CheckBox12Click(Sender: TObject);
begin
  Chart1.Title.Text.Text := '拖点工具演示';
  Chart2.Title.Text.Text := '拖点工具演示';
  ChartTool2.Active := CheckBox12.Checked;
  ChartTool4.Active := CheckBox12.Checked;
  ChartTool2.Series := Series1;
  ChartTool4.Series := Series3;
  ChartTool2.DragStyle := dsY;
  ChartTool4.DragStyle := dsY;
  PageControl1.ActivePageIndex := 1;
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.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 + 10;
  ChartTool3.YValue := ChartTool3.YValue + 10;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  ChartTool1.YValue := ChartTool1.YValue - 10;
  ChartTool3.YValue := ChartTool3.YValue - 10;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  ChartTool1.FollowMouse := CheckBox1.Checked;
  ChartTool3.FollowMouse := CheckBox1.Checked;

  Button1.Enabled := not CheckBox1.Checked;
  Button2.Enabled := not CheckBox1.Checked;
  Button3.Enabled := not CheckBox1.Checked;
  Button4.Enabled := not CheckBox1.Checked;
end;

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

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

procedure TForm1.CheckBox13Click(Sender: TObject);
begin
  Chart1.Title.Text.Text := '拖标签工具演示';
  Chart2.Title.Text.Text := '拖标签工具演示';

  ChartTool5.Active := CheckBox13.Checked;
  ChartTool6.Active := CheckBox13.Checked;
  Series1.Marks.Visible := CheckBox13.Checked;
  Series3.Marks.Visible := CheckBox13.Checked;
  CheckBox3.Checked := CheckBox13.Checked;

  PageControl1.ActivePageIndex := 2;
end;

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

procedure TForm1.CheckBox14Click(Sender: TObject);
begin
  Chart1.Title.Text.Text := '提示签工具演示';
  Chart2.Title.Text.Text := '提示签工具演示';

  ChartTool8.Active := CheckBox4.Checked;
  ChartTool7.Active := CheckBox4.Checked;
  PageControl1.ActivePageIndex := 3;
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  case RadioGroup1.ItemIndex of
    0:
    begin
      ChartTool8.MouseAction := mtmMove;
      ChartTool7.MouseAction := mtmMove;
    end;
    1:
    begin
      ChartTool8.MouseAction := mtmClick;
      ChartTool7.MouseAction := mtmClick;
    end;
  end;
end;

procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
  ChartTool8.MouseDelay := SpinEdit1.Value;
  ChartTool7.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.CheckBox2Click(Sender: TObject);
begin
  //
  Chart1.View3D := CheckBox2.Checked;
  Chart2.View3D := CheckBox2.Checked;
end;

procedure TForm1.CheckBox15Click(Sender: TObject);
begin
  Chart1.Title.Text.Text := '附加图例演示';
  Chart2.Title.Text.Text := '附加图例演示';
  ChartTool9.Active := CheckBox15.Checked;
  charttool10.Active := CheckBox15.Checked;
  PageControl1.ActivePageIndex := 4;
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;
  ChartTool11.Active := CheckBox16.Checked;
  PageControl1.ActivePageIndex := 5;
end;

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

procedure TForm1.CheckBox6Click(Sender: TObject);
begin
  ChartTool11.DrawLine :=CheckBox6.Checked;
  ChartTool12.DrawLine :=CheckBox6.Checked;
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;

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

procedure TForm1.ChartTool4DragPoint(Sender: TDragPointTool;
  Index: Integer);
begin
  ChartTool2.Series.YValue[Index] := ChartTool4.Series.YValue[Index];
  ChartTool2.Series.XValue[Index] := ChartTool4.Series.XValue[Index];
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.YValue := YValue;
    ChartTool1.XValue := XValue;
  end;
end;

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

end.
View Code

 

posted on 2020-03-08 17:25  风与夕阳  阅读(122)  评论(0编辑  收藏