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
How to synchronize the zoom range of multiple charts
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):
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
http://www.steema.com