1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| procedure TForm1.Button1Click(Sender: TObject);
var I,J:integer;
cs:TBarSeries;
begin
//Remplissage du TStringGrid
StringGrid1.Cells[0,1] := '1 : toto';
StringGrid1.Cells[0,2] := '2 : blé';
StringGrid1.Cells[0,3] := '3 : orge';
StringGrid1.Cells[0,4] := '4 : betteraves';
StringGrid1.Cells[1,0] := '2001';
StringGrid1.Cells[2,0] := '2002';
StringGrid1.Cells[3,0] := '2003';
StringGrid1.Cells[4,0] := '2004';
for i := 1 to StringGrid1.RowCount - 1 do
for j := 1 to StringGrid1.ColCount - 1 do
//Remplissage avec des valeurs aléatoires
StringGrid1.Cells[j, i] := IntToStr(Random(60) + 40);
// gestion du chart
//Effacement des séries 4 séries
Chart1.SeriesList.Clear;
for i := 1 to StringGrid1.RowCount - 1 do
begin
//1 ligne = 1 série
cs := TBarSeries.Create(Self);
cs.Title := 'series' + intToStr(i);
//NE SURTOUT PAS OUBLIER CECI :
cs.ParentChart := Chart1;
for j := 1 to StringGrid1.ColCount - 1 do //Ajout des valeurs à la série
cs.Add(StrToIntDef(StringGrid1.Cells[j, i], 0)); //, StringGrid1.Cells[j, 0]);
end;
series1.MultiBar := mbStacked100;
end; |
Partager