类似这样的程序,我可以得到随机数的值并能得到相应的图像。(已实现)
我希望出现的随机数图像不断地像内侧滚动,而不是不断积压。
郁闷好多天了,各位大虾帮帮忙,小女子在此谢谢了。程序如下:
procedure TForm1.Timer1Timer(Sender: TObject);
var  Temp,j,i:integer;
     M:array[0..50]of Integer;
begin
    randomize;
for i:=0 to 50 do
 M[i]:=i;
 for i:=0 to 50 do
  begin
  j:=random(50);
  Temp:=M[i];
  M[i]:=M[j];
  M[j]:=Temp;
  end;
    Chart1.View3D:=false;
  Chart1.LeftAxis.Automatic:=false;
  Chart1.LeftAxis.Maximum:=50;
  Chart1.LeftAxis.Minimum:=0;
  Series1.Add(j,''+inttostr(j),clPurple );
     time := time +1;
   if time>50 then time:=0;//time已经在别处定义
   Chart1.Refresh;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
time:=0;
end;

解决方案 »

  1.   

    你说的是chart1上的图片处理吧,很难啊,tchar是看不到vcl源代码的,不容易知道它的处理思路,
    如果有高人指点,我也在此学习,关注
      

  2.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    var  Temp,j,i:integer;
         M:array[0..50]of Integer;
    begin
        randomize;
    for i:=0 to 50 do
     M[i]:=i;
     for i:=0 to 50 do
      begin
      j:=random(50);
      Temp:=M[i];
      M[i]:=M[j];
      M[j]:=Temp;
      end;
        Chart1.View3D:=false;
      Chart1.LeftAxis.Automatic:=false;
      Chart1.LeftAxis.Maximum:=50;
      Chart1.LeftAxis.Minimum:=0;
      Series1.Add(j,''+inttostr(j),clPurple );
      if Series1.Count > 10 then
        series1.Delete(0);
         time := time +1;
       if time>50 then time:=0;//timeÒѾ­Ôڱ𴦶¨Òå
       Chart1.Refresh;
    end;
      

  3.   

    if Series1.Count > 10 then
        series1.Delete(0);加入这个就行了。10设为你所需要的数量。
      

  4.   

    可是当程序执行到某一点的时候就成为一条直线,虽然图像变化了,可是并不是滚动的效果。
    当Series1.Count > 10 时,即删除了第一个点,我想要的效果是Series1.Count > 10,第一个
    点消失,第二个点移动到第一个点的位置,在最后增加一个点,不断的循环.......
      

  5.   

    ar  Temp,j,i:integer;
         M:array[0..50]of Integer;
    begin
      randomize;
      j:=random(50);  Chart1.View3D:=false;
      Chart1.LeftAxis.Automatic:=false;
      Chart1.LeftAxis.Maximum:=50;
      Chart1.LeftAxis.Minimum:=0;
      if Series1.Count = 5 then
      begin
        Series1.Delete(0);
    //    Series1.Delete(0);
      end;
      if Series1.Count = 0 then
       Series1.addxy( 0,j ,''+inttostr(j),clPurple )
      else
       Series1.addxy( Series1.XValues.Last+1,j ,''+inttostr(j),clPurple );end;
    改进了下。你参考吧
      

  6.   

    对不起,刚才没贴完。
    procedure TForm1.Timer1Timer(Sender: TObject);
    var  Temp,j,i:integer;
         M:array[0..50]of Integer;
    begin
      randomize;
      j:=random(50);  Chart1.View3D:=false;
      Chart1.LeftAxis.Automatic:=false;
      Chart1.LeftAxis.Maximum:=50;
      Chart1.LeftAxis.Minimum:=0;
      if Series1.Count = 5 then
      begin
        Series1.Delete(0);
    //    Series1.Delete(0);
      end;
      if Series1.Count = 0 then
       Series1.addxy( 0,j ,''+inttostr(j),clPurple )
      else
       Series1.addxy( Series1.XValues.Last+1,j ,''+inttostr(j),clPurple );end;