Chart with lineseries, <1000 x and y values forming a curve. I would like to zoom right into the data so only about 30 points are displayed on chart. Would then like to have the chart cycle through the data one point at a time, ie. scrolling along the curve, always showing 30 points. One way to do this would be to centre the chart on [x1,y1], then [x2,y2], then [x3,y3] etc. Is there a way to centre a chart on any [x,y] pair?
thanks
Sean
Centre chart at Tlineseries X and Y
-
- Newbie
- Posts: 48
- Joined: Fri Mar 12, 2004 5:00 am
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Sean,
Yes, this can be done getting [X,Y] pair values and setting left and bottom axes accordingly as shown in the code below. In this example two options are shown:
1) The Button1Click code centers the chart to the center value of the series.
2) The Timer1Timer code authomatically scrolls series starting at its center and looping through series points.
Yes, this can be done getting [X,Y] pair values and setting left and bottom axes accordingly as shown in the code below. In this example two options are shown:
1) The Button1Click code centers the chart to the center value of the series.
2) The Timer1Timer code authomatically scrolls series starting at its center and looping through series points.
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
for i:=0 to 100 do Series1.AddXY(i,i*i);
CenterIndex:=Series1.Count div 2;
Timer1.Enabled:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
With Chart1.Axes do
begin
Left.SetMinMax(Series1.YValue[CenterIndex]-Series1.YValue[CenterIndex-10],
Series1.YValue[CenterIndex]+Series1.YValue[CenterIndex+10]);
Bottom.SetMinMax(Series1.XValue[CenterIndex]-Series1.XValue[CenterIndex-10],
Series1.XValue[CenterIndex]+Series1.XValue[CenterIndex+10]);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
With Chart1.Axes do
begin
Left.SetMinMax(Series1.YValue[CenterIndex]-Series1.YValue[CenterIndex-10],
Series1.YValue[CenterIndex]+Series1.YValue[CenterIndex+10]);
Bottom.SetMinMax(Series1.XValue[CenterIndex]-Series1.XValue[CenterIndex-10],
Series1.XValue[CenterIndex]+Series1.XValue[CenterIndex+10]);
end;
if CenterIndex=100 then CenterIndex:=0
else inc(CenterIndex);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled:=true;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |