procedure Assign(ListA: TList; AOperator: TListAssignOp laCopy; ListB: TList nil);
- créer un Composant TLineSeries - Ajouter les séries - affecter par Assign les séries à TChart dans Unit2 - libérer ton composant TLineSeries
procedure TForm1.Button1Click(Sender: TObject); var i, j : integer; cs : TChartSeries; const SeriesNames : array[0..5] of string = ('blé', 'orge', 'pommes de terre', 'betteraves', 'avoine', 'colza'); begin //Remplissage aléatoire du TStringGrid for i := 1 to StringGrid1.RowCount - 1 do begin {le nom de la série sera pris aléatoirement dans le tableau pour le jeu de tests} StringGrid1.Cells[0, i] := IntToStr(i) + ':' + SeriesNames[Random(6)]; for j := 1 to StringGrid1.ColCount - 1 do begin //Ligne du haut remplie avec des "années" StringGrid1.Cells[j, 0] := IntToStr(2000 + j); //Remplissage avec des valeurs aléatoires StringGrid1.Cells[j, i] := IntToStr(Random(60) + 40); end; end; // [1] Effacement des séries Chart1.SeriesList.Clear; for i : = 1 to StringGrid1.RowCount - 1 do begin //[2]1 ligne = 1 série cs := TLineSeries.Create(Chart1); cs.Title := StringGrid1.Cells[0, i]; // [3] Don't forget this : 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; end;