How to synchronize the zoom range of multiple charts

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Thomas
Newbie
Newbie
Posts: 7
Joined: Tue May 11, 2004 4:00 am

How to synchronize the zoom range of multiple charts

Post by Thomas » Thu Aug 19, 2004 2:15 pm

Is there a simple solution to synchronize the zoom ranges of multiple charts?
I want that if one chart is zoomed the other charts show the same zoom range.

thanks in advance,

Thomas

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Thu Aug 19, 2004 4:10 pm

Hi, Thomas.
Yes, this can be done. All you have to do is capture one chart axis scale (minimum and maximum) and then use these values for other chart axes. You can check for axis scale in chart OnZoom, OnUndoZoom and OnScroll events and then use this info for other chart axes. Something like this (for three charts):

Code: Select all

Procedure AssignScales(Source,Dest:TCustomChart);
begin
  With Source.Axes.Bottom do Dest.Axes.Bottom.SetMinMax(Minimum,Maximum);
  With Source.Axes.Left do Dest.Axes.Left.SetMinMax(Minimum,Maximum);
end;

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
     AssignScales(Chart1,Chart2);
     AssignScales(Chart1,Chart3);
end;

procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
     AssignScales(Chart1,Chart2);
     AssignScales(Chart1,Chart3);

end;

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
     AssignScales(Chart1,Chart2);
     AssignScales(Chart1,Chart3);
end;

procedure TForm1.Chart2Zoom(Sender: TObject);
begin
     AssignScales(Chart2,Chart1);
     AssignScales(Chart2,Chart3);

end;

procedure TForm1.Chart2UndoZoom(Sender: TObject);
begin
     AssignScales(Chart2,Chart1);
     AssignScales(Chart2,Chart3);
end;

procedure TForm1.Chart2Scroll(Sender: TObject);
begin
     AssignScales(Chart2,Chart1);
     AssignScales(Chart2,Chart3);
end;
Marjan Slatinek,
http://www.steema.com

Post Reply