unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, TeEngine, Series, TeeProcs, Chart, StdCtrls, Spin;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TFastLineSeries;
    Timer1: TTimer;
    Label1: TLabel;
    SpinEdit1: TSpinEdit;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Number:integer=0;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
    Chart1.BottomAxis.Automatic  :=   False;
    Chart1.BottomAxis.Maximum   :=   SpinEdit1.Value;
    Chart1.BottomAxis.Minimum   :=   0;
    Chart1.LeftAxis.Automatic := False;
    Chart1.LeftAxis.Maximum := 100.0;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 Inc(Number);
 Series1.Add(random(100));
 if  Number > SpinEdit1.Value  then
 begin
  Chart1.BottomAxis.Maximum   :=   Number;
  Chart1.BottomAxis.Minimum   :=   Number- SpinEdit1.Value;
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;

end.
