unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, TeEngine, Series, TeeProcs, Chart;
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TFastLineSeries;
Button1: TButton;
Button2: TButton;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure Chart1AfterDraw(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
series1.AddY(random(200),formatdatetime('hh:mm:ss',now));
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var
i:integer;
Series2: TFastLineSeries;
begin
if not assigned(form2) then
exit;
for i:=0 to form2.chart1.SeriesCount-1 do
form2.chart1.Series.Free;
series2:=TFastLineSeries.Create(nil);
series2.Assign(series1);
form2.chart1.AddSeries(series2);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if not assigned(form2) then
form2:=tform2.create(Application);
form2.showmodal;
form2.free;
form2:=nil;
end;
end.
你试一下,完全没有问题的