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
|
procedure TForm1.Timer1Timer(Sender: TObject);
const
MAX = 48;
var
Index : Integer;
S1, S2: TLineSeries;
X: Integer;
begin
Chart1.Axes.Bottom.Automatic := False; // pas la peine de le faire dans le Timer mais c'est pour l'exemple
Chart1.Axes.Bottom.Maximum := MAX;
Index := Timer1.Tag;
if Index < MAX then // nombre maxi de valeurs
begin
S1 := Series1; // on alimente la série 1
S2 := Series2; // on efface la série 2
X := Index;
end else begin
S1 := Series2; // on alimente la série 2
S2 := Series1; // on efface la série 1
X := Index - MAX; // X reprend à 0
end;
S1.AddXY(X, 400 + 200 * Sin(Index * PI/5), IntToStr(X), clRed); // fonction bidon
if S2.Count > 0 then
S2.Delete(0); // effacer la série que l'on remplace
Inc(Index); // pour la prochaine fois
if Index = 2 * MAX then // au bout de 2 passages, on reprend au départ
Index := 0;
Timer1.Tag := Index;
end; |
Partager