home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Delphi1_And_Delphi2 / EXAMPLES / STANDARD / UFAST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  2.7 KB  |  107 lines

  1. {****************************************}
  2. {    TeeChart. TChart Component          }
  3. { Copyright (c) 1995,96 by David Berneda }
  4. {    All Rights Reserved                 }
  5. {****************************************}
  6. unit UFast;
  7.  
  8. interface
  9.  
  10. uses
  11.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  12.   Forms, Dialogs, StdCtrls, ExtCtrls, Teengine, Chart,Series, Buttons,
  13.   TeeProcs;
  14.  
  15. type
  16.   TFastLineForm = class(TForm)
  17.     Chart1: TChart;
  18.     Panel1: TPanel;
  19.     Button1: TButton;
  20.     CheckBox1: TCheckBox;
  21.     CheckBox2: TCheckBox;
  22.     FastLineSeries1: TFastLineSeries;
  23.     FastLineSeries2: TFastLineSeries;
  24.     CheckBox3: TCheckBox;
  25.     BitBtn3: TBitBtn;
  26.     Memo1: TMemo;
  27.     procedure FormCreate(Sender: TObject);
  28.     procedure Button1Click(Sender: TObject);
  29.     procedure CheckBox2Click(Sender: TObject);
  30.     procedure CheckBox1Click(Sender: TObject);
  31.     procedure CheckBox3Click(Sender: TObject);
  32.   private
  33.     { Private declarations }
  34.   public
  35.     { Public declarations }
  36.   end;
  37.  
  38. implementation
  39.  
  40. {$R *.DFM}
  41.  
  42. procedure TFastLineForm.FormCreate(Sender: TObject);
  43. var t,tmpRandom:Longint;
  44. begin
  45.   { This can speed up things a little... }
  46.   TeeEraseBack:=False;
  47.  
  48.   { Make the chart flicker by default, only for this demo }
  49.   Chart1.BufferedDisplay:=False;
  50.  
  51.   Chart1.View3d:=False;
  52.   Chart1.Legend.Visible:=False;
  53.   Chart1.Title.Visible:=False;
  54.   Chart1.Foot.Visible:=False;
  55.  
  56.   { some speed improvement if... }
  57.   TeeDefaultCapacity:=2000;
  58.   
  59.   { 2000 random points }
  60.   Randomize;
  61.   for t:=1 to 1000 do
  62.   begin
  63.     tmpRandom:=Random(Abs(500-t))-(Abs(500-t) div 2);
  64.     FastLineSeries1.Add(1000-t+tmpRandom,'',clTeeColor);
  65.     FastLineSeries2.Add(t+tmpRandom,'',clTeeColor);
  66.   end;
  67. end;
  68.  
  69. procedure TFastLineForm.Button1Click(Sender: TObject);
  70. var t1,t2,t:Longint;
  71. begin
  72.   Screen.Cursor:=crHourGlass;
  73.   try
  74.     Chart1.AnimatedZoom:=False;
  75.     t1:=GetTickCount;
  76.     for t:=1 to 30 do Chart1.ZoomPercent(105);  { 5% zoom in }
  77.     for t:=1 to 30 do Chart1.ZoomPercent(95); { 5% zoom out }
  78.     t2:=GetTickCount;
  79.     Chart1.AnimatedZoom:=True;
  80.     Chart1.UndoZoom;
  81.   finally
  82.     Screen.Cursor:=crDefault;
  83.   end;
  84.   Showmessage('Time to plot 2000 points'+#13+
  85.               '61 times: '+#13+
  86.               IntToStr(t2-t1)+' milliseconds.');
  87. end;
  88.  
  89. procedure TFastLineForm.CheckBox2Click(Sender: TObject);
  90. begin
  91.   Chart1.AxisVisible:=CheckBox2.Checked;
  92. end;
  93.  
  94. procedure TFastLineForm.CheckBox1Click(Sender: TObject);
  95. begin
  96.  { Setting this to False speeds up drawing
  97.    with maximized charts on some video drivers }
  98.   Chart1.BufferedDisplay:=CheckBox1.Checked;
  99. end;
  100.  
  101. procedure TFastLineForm.CheckBox3Click(Sender: TObject);
  102. begin
  103.   Chart1.ClipPoints:=CheckBox3.Checked;
  104. end;
  105.  
  106. end.
  107.