【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,basic.pas,希望对大家有所帮助!
{*********************************************}
{ TeeChart
Delphi Component Library }
{ Basic Series Types Demo }
{ Copyright (c) 1995-2001 by David Berneda }
{ All rights reserved }
{*********************************************}
unit basic;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Chart, Series, ExtCtrls, StdCtrls, Bubble,
BubbleCh, Teengine, Buttons, teeprocs;
type
TBasicForm = class(TForm)
Chart1: TChart;
Panel1: TPanel;
CheckBox1: TCheckBox;
Timer1: TTimer;
BarSeries1: TBarSeries;
South: TAreaSeries;
Speaking: TPointSeries;
Panel2: TPanel;
Chart2: TChart;
Label1: TLabel;
Chart3: TChart;
Chart4: TChart;
North: TAreaSeries;
Writing: TPointSeries;
Reading: TPointSeries;
BitBtn1: TBitBtn;
RadioGroup1: TRadioGroup;
BitBtn3: TBitBtn;
CheckBox2: TCheckBox;
SaveDialog1: TSaveDialog;
BitBtn2: TBitBtn;
Winter: TLineSeries;
Summer: TLineSeries;
procedure FormCreate(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
Uses Printers;
procedure TBasicForm.FormCreate(Sender: TObject);
var t:Longint;
begin
Summer.FillSampleValues(20); { <-- Some random points }
Winter.FillSampleValues(20); { <-- Some random points }
{ Will need a Bar Series with special random values,
so we dont call the standard FillSampleValues method }
With BarSeries1 do
for t:=1 to 12 do Add(Random(1000),ShortMonthNames[t],GetDefaultColor(t));
South.FillSampleValues(20); { <-- Some random points }
North.FillSampleValues(20); { <-- Some random points }
Speaking.FillSampleValues(20); { <-- Some random points }
Reading.FillSampleValues(20); { <-- Some random points }
Writing.FillSampleValues(20); { <-- Some random points }
{ Force to resize the four charts }
FormResize(Self);
end;
procedure TBasicForm.CheckBox1Click(Sender: TObject);
begin
Timer1.Enabled:=CheckBox1.Checked;
end;
procedure TBasicForm.Timer1Timer(Sender: TObject);
Procedure Animate(Series:TChartSeries);
Begin
With Series do
Begin
Delete(0); { <-- remove the first point }
{ Add a new random point }
AddXY( XValues.Last+1,
YValues.Last+(Random(ChartSamplesMax)-(ChartSamplesMax/2)),
'',clTeeColor);
end;
end;
Var tmpLabel:String;
tmpColor:TColor;
begin
Animate(Summer);
Animate(Winter);
{ BarSeries1 has special treatment to animate }
With BarSeries1 do
Begin
tmpLabel:=XLabel[0];
tmpColor:=ValueColor[0];
Delete(0);
AddXY(XValues.Last+1,Random(1000),tmpLabel,tmpColor);
{ Change Bar Style randomly... }
if Random(10)<1 then
BarStyle:=TBarStyle(Random(1+Ord(High(TBarStyle))));
end;
Animate(South);
Animate(North);
Animate(Speaking);
Animate(Reading);
Animate(Writing);
{ Change Pointer Style randomly... }
if Random(10)<1 then
With Speaking do
Pointer.Style:=TSeriesPointerStyle(Random(1+Ord(High(TSeriesPointerStyle))));
end;
{ Realign the four charts }
procedure TBasicForm.FormResize(Sender: TObject);
Var w,h:Longint;
begin
{ Top and bottom Panel positioning }
w:=ClientWidth-4-Panel1.Width;
Panel2.Width:=w-4;
Panel1.Height:=ClientHeight-Panel2.Height-4;
h:=Panel1.Height;
{ Top Left Chart }
Chart1.SetBounds(Panel1.Width,Panel2.Height,w div 2,h div 2);
{ Bottom Left Chart }
Chart2.SetBounds(Panel1.Width,Panel2.Height+Chart1.Height,w div 2,h div 2);
{ Top Right Chart }
Chart3.SetBounds(Panel1.Width+Chart1.Width+1,Chart1.Top,w div 2,h div 2);
{ Bottom Right Chart }
Chart4.SetBounds(Chart3.Left,Chart2.Top,w div 2,h div 2);
end;
procedure TBasicForm.FormShow(Sender: TObject);
begin
FormResize(Self); { <-- to align charts }
end;
procedure TBasicForm.BitBtn1Click(Sender: TObject);
Var tmpH,tmpW,tmpWMargin,tmpHMargin:Longint; { margins }
OldOrientation:TPrinterOrientation;
begin
Screen.Cursor := crHourGlass;
OldOrientation:=Printer.Orientation; { <-- save paper orientation }
Printer.Orientation:=poLandscape; { <-- Force Horizontal paper }
try
Printer.BeginDoc; { <-- start printer job }
try
Printer.Title:='TeeChart Printing Demo';
Case RadioGroup1.ItemIndex of
0: Begin { screen proportion