unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Chart1: TChart;
    StringGrid1: TStringGrid;
    Button1: TButton;
    Series1: TBarSeries;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
  //wypełnianie tabeli
   with StringGrid1 do
   begin
     Cells[0,0]:='Imię';
     Cells[1,0]:='Średnia ocen';
     for i:=1 to 4 do
     begin
       Cells[0,i]:='Ala'+IntToStr(i);
       Cells[1,i]:=FloatToStrF(i*1.5,ffFixed,4,2);
     end;
   end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
   //rysowanie wykresu
   with StringGrid1 do
   begin
     Series1.Clear;
     Series1.Title:=Cells[1,0]; //tytuł serii danych - w legendzie
     Chart1.LeftAxis.Title.Caption:=Cells[1,0];   //nazwa osi y
     Chart1.BottomAxis.Title.Caption:=Cells[0,0]; //nazwa osi x
     for i:=1 to 4 do  Series1.Add(StrToFloat(Cells[1,i]),Cells[0,i]);
   end;
end;

end.
