home *** CD-ROM | disk | FTP | other *** search
- {$I TeeDefs.inc}
- unit Welcome;
-
- { Animation of Pie and Bar / Line series... }
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
-
- type
- TWelcomeForm = class(TForm)
- Chart1: TChart;
- Series1: TPieSeries;
- Timer1: TTimer;
- Series2: TLineSeries;
- Series3: TLineSeries;
- Series4: TFastLineSeries;
- procedure FormCreate(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure FormShow(Sender: TObject);
- private
- { Private declarations }
- Delta : Integer;
- DeltaRot : Integer;
- DeltaElev : Integer;
- TheSeries : TChartSeries;
- public
- { Public declarations }
- end;
-
- implementation
-
- {$R *.DFM}
-
- procedure TWelcomeForm.FormCreate(Sender: TObject);
- begin
- { constants to rotate... }
- Delta:=1;
- DeltaElev:=1;
- DeltaRot:=1;
-
- { sample values... }
- Series1.FillSampleValues(8);
- Series2.FillSampleValues(30);
- Series3.FillSampleValues(30);
- Series4.FillSampleValues(50);
-
- { the series to animate... }
- TheSeries:=Series1;
-
- { start with a very small view... }
- Chart1.View3DOptions.Zoom:=1;
- end;
-
- { Do animation... }
- procedure TWelcomeForm.Timer1Timer(Sender: TObject);
-
- { add a new point to the series and remove the first point }
- Procedure AddPoint(ASeries:TChartSeries);
- begin
- with ASeries do
- begin
- AddXY(XValues.Last+1,YValues.Last+Random(20)-10 {$IFNDEF D4},'',clTeeColor{$ENDIF} );
- Delete(0);
- end;
- end;
-
- begin
- Timer1.Enabled:=False;
-
- { Pie series, do rotation... }
- if TheSeries is TPieSeries then
- begin
- With TheSeries as TPieSeries do
- RotationAngle:=RotationAngle+2;
- end
- else
- { scroll points... }
- begin
- AddPoint(Series2);
- AddPoint(Series3);
- AddPoint(Series4);
- { change 3D view (rotation / elevation) ... }
- With Chart1.View3DOptions do
- begin
- Elevation:=Elevation+DeltaElev;
- if (Elevation>320) or (Elevation<280) then
- DeltaElev:=-DeltaElev;
- Rotation:=Rotation+DeltaRot;
- if (Rotation>355) or (Rotation<272) then
- DeltaRot:=-DeltaRot;
- end;
- end;
- { change view Zoom... }
- With Chart1.View3DOptions do
- begin
- Zoom:=Zoom+Delta;
-
- { reverse zoom-in / zoom-out }
- if (Zoom>200) or (Zoom<2) then
- Delta:=-Delta;
-
- { change from Pie to Lines... }
- if Zoom>200 then
- begin
- Series1.Active:=False;
- Series2.Active:=False;
- Series3.Active:=False;
- Series4.Active:=False;
- if TheSeries=Series1 then
- begin
- TheSeries:=Series2;
- Series2.Active:=True;
- Series3.Active:=True;
- Series4.Active:=True;
- Chart1.View3DOptions.Perspective:=75;
- Chart1.View3DOptions.Rotation:=300;
- end
- else
- begin
- TheSeries:=Series1;
- Chart1.View3DOptions.Rotation:=360;
- TheSeries.Active:=True;
- end;
- end;
- end;
- { re-start the timer... }
- Timer1.Enabled:=True;
- end;
-
- procedure TWelcomeForm.FormShow(Sender: TObject);
- begin
- Timer1.Enabled:=True; { start animation... }
- end;
-
- initialization
- RegisterClass(TWelcomeForm)
- end.
-