home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / TeeChartPro / TeeChart5Delphi5Eval.exe / %MAINDIR% / Examples / Features / Tool_Cursor.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-09-10  |  2.5 KB  |  86 lines

  1. unit Tool_Cursor;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   Base, ExtCtrls, TeeProcs, TeEngine, Chart, StdCtrls, TeeTools, Series,
  8.   TeeEdit;
  9.  
  10. type
  11.   TCursorToolDemo = class(TBaseForm)
  12.     Label1: TLabel;
  13.     Label2: TLabel;
  14.     CheckBox2: TCheckBox;
  15.     CheckBox1: TCheckBox;
  16.     ChartTool1: TCursorTool;
  17.     Series2: TFastLineSeries;
  18.     ChartTool2: TCursorTool;
  19.     ChartTool3: TColorLineTool;
  20.     Series1: TFastLineSeries;
  21.     Button1: TButton;
  22.     ChartEditor1: TChartEditor;
  23.     procedure CheckBox1Click(Sender: TObject);
  24.     procedure FormCreate(Sender: TObject);
  25.     procedure ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  26.       const XValue, YValue: Double; Series: TChartSeries;
  27.       ValueIndex: Integer);
  28.     procedure CheckBox2Click(Sender: TObject);
  29.     procedure ChartTool2Change(Sender: TCursorTool; x, y: Integer;
  30.       const XValue, YValue: Double; Series: TChartSeries;
  31.       ValueIndex: Integer);
  32.     procedure Button1Click(Sender: TObject);
  33.   private
  34.     { Private declarations }
  35.   public
  36.     { Public declarations }
  37.   end;
  38.  
  39. implementation
  40.  
  41. {$R *.DFM}
  42.  
  43. procedure TCursorToolDemo.CheckBox1Click(Sender: TObject);
  44. begin
  45.   ChartTool1.Active:=CheckBox1.Checked   { enable / disable the first cursor }
  46. end;
  47.  
  48. procedure TCursorToolDemo.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  49.   const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
  50. begin
  51.   { show the cursor values... }
  52.   Label1.Caption:=FormatFloat('#.00',XValue)+','+FormatFloat('#.00',YValue);
  53. end;
  54.  
  55. procedure TCursorToolDemo.CheckBox2Click(Sender: TObject);
  56. begin
  57.   { set / unset cursor "Snap" (automatic moving of cursor to points) }
  58.   ChartTool1.Snap:=CheckBox2.Checked;
  59.   { change the cursor style... }
  60.   ChartTool1.Style:=cssVertical;
  61. end;
  62.  
  63. procedure TCursorToolDemo.ChartTool2Change(Sender: TCursorTool; x, y: Integer;
  64.   const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
  65. begin
  66.   { show cursor values }
  67.   Label2.Caption:=FormatFloat('#.00',XValue)+','+FormatFloat('#.00',YValue);
  68. end;
  69.  
  70. procedure TCursorToolDemo.FormCreate(Sender: TObject);
  71. begin
  72.   inherited;
  73.   Series1.FillSampleValues(100);
  74.   Series2.FillSampleValues(100);
  75.   Chart1.LeftAxis.Minimum:=0;
  76. end;
  77.  
  78. procedure TCursorToolDemo.Button1Click(Sender: TObject);
  79. begin
  80.   ChartEditor1.Execute  { show the chart editor dialog }
  81. end;
  82.  
  83. initialization
  84.   RegisterClass(TCursorToolDemo);
  85. end.
  86.