home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / DELPHI4.EXE / %MAINDIR% / Examples / Extended / Uerrstd.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-11-17  |  2.4 KB  |  97 lines

  1. {**********************************************}
  2. {   TErrorSeries Component Example             }
  3. {   Copyright (c) 1995-1998 by David Berneda   }
  4. {**********************************************}
  5. unit uerrstd;
  6.  
  7. interface
  8.  
  9. uses
  10.   WinProcs,WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  11.   TeEngine, Series, ErrorBar, TeeProcs, Chart, TeeComma, StdCtrls, Buttons,
  12.   ExtCtrls;
  13.  
  14. type
  15.   TErrStdForm = class(TForm)
  16.     Panel1: TPanel;
  17.     Label1: TLabel;
  18.     CheckBox1: TCheckBox;
  19.     BitBtn3: TBitBtn;
  20.     Memo1: TMemo;
  21.     TeeCommander1: TTeeCommander;
  22.     Chart1: TChart;
  23.     Series1: TErrorSeries;
  24.     Series2: TErrorSeries;
  25.     Series3: TErrorSeries;
  26.     Series4: TErrorSeries;
  27.     CheckBox2: TCheckBox;
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure CheckBox2Click(Sender: TObject);
  30.     procedure BitBtn3Click(Sender: TObject);
  31.     procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  32.       Y: Integer);
  33.   private
  34.     { Private declarations }
  35.     Function CheckSeries(ASeries:TChartSeries; x,y:Integer):Boolean;
  36.   public
  37.     { Public declarations }
  38.   end;
  39.  
  40. var
  41.   ErrStdForm: TErrStdForm;
  42.  
  43. implementation
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure TErrStdForm.FormCreate(Sender: TObject);
  48. begin
  49.   Series1.FillSampleValues(15);
  50.   Series2.FillSampleValues(15);
  51.   Randomize;
  52.   Series3.FillSampleValues(15);
  53.   Series4.FillSampleValues(15);
  54. end;
  55.  
  56. procedure TErrStdForm.CheckBox2Click(Sender: TObject);
  57. var tmp:Integer;
  58. begin
  59.   { Change the Error Pen width }
  60.   if CheckBox2.Checked then tmp:=2
  61.                        else tmp:=1;
  62.   Series1.ErrorPen.Width:=tmp;
  63.   Series2.ErrorPen.Width:=tmp;
  64.   Series3.ErrorPen.Width:=tmp;
  65.   Series4.ErrorPen.Width:=tmp;
  66. end;
  67.  
  68. procedure TErrStdForm.BitBtn3Click(Sender: TObject);
  69. begin
  70.   Close;
  71. end;
  72.  
  73. Function TErrStdForm.CheckSeries(ASeries:TChartSeries; x,y:Integer):Boolean;
  74. var tmp:Integer;
  75. begin
  76.   tmp:=ASeries.Clicked(x,y);
  77.   if tmp<>-1 then
  78.   begin
  79.     Label1.Caption:=IntToStr(tmp);
  80.     Label1.Font.Color:=ASeries.ValueColor[tmp];
  81.     result:=True;
  82.   end
  83.   else result:=False;
  84. end;
  85.  
  86. procedure TErrStdForm.Chart1MouseMove(Sender: TObject; Shift: TShiftState;
  87.   X, Y: Integer);
  88. begin
  89.   if (not CheckSeries(Series1,x,y)) and
  90.      (not CheckSeries(Series2,x,y)) and
  91.      (not CheckSeries(Series3,x,y)) and
  92.      (not CheckSeries(Series4,x,y)) then
  93.           Label1.Caption:='';
  94. end;
  95.  
  96. end.
  97.