unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    StringGrid1: TStringGrid;
    Chart1: TChart;
    Series1: TBarSeries;
    Series2: TBarSeries;
    Series3: TBarSeries;
    procedure PageControl1Change(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
   with Stringgrid1 do
   begin
     Cells[0,0]:='Lp.';
     Cells[1,0]:='Dane1';
     Cells[2,0]:='Dane2';
     Cells[3,0]:='Dane3';
     for i:= 1 to RowCount - 1 do
       begin
         Cells[0,i]:=Inttostr(i);
         Cells[1,i]:=Inttostr(i*i+2);
         Cells[2,i]:=Inttostr(2*i);
         Cells[3,i]:=Inttostr(1+Random(40));
       end;
   end;
   PageControl1.ActivePage:=Tabsheet1;
end;

procedure TForm1.PageControl1Change(Sender: TObject);
var i:integer;
begin
  if PageControl1.ActivePage=Tabsheet2 then
  begin
   Series1.Title:='Dane1';
   Series2.Title:='Dane2';
   Series3.Title:='Dane3';
   //rysuj wykres
   for i:=0 to Chart1.SeriesCount-1 do Chart1.Series[i].Clear;
   with Stringgrid1 do
   for i:=1 to RowCount - 1 do
     if (Cells[1,i]<>'')AND (Cells[2,i]<>'')AND(Cells[3,i]<>'') then
     begin
       Series1.Add(StrtoInt(Cells[1,i]),Cells[0,i]);
       Series2.Add(StrtoInt(Cells[2,i]),Cells[0,i]);
       Series3.Add(StrtoInt(Cells[3,i]),Cells[0,i]);
     end;
   end;
end;

end.
