Page 1 of 1
Zoompercent and graph scrolling
Posted: Fri Jan 27, 2012 11:49 am
by 16561106
Hi all,
I use a simple zoompercent(110) on a chart (data origin on left and bottom axis are 0). After zooming in, data origin is changed, as if axes where scrolled (after a few tests, it looks like if zoompercent(110) performed a zoomrect at the center of my graph).
I tried to scroll axes, but I cannot get the value of the first visible graduation (tick) on the left axis (on the screenshot it is 0,4)...
How can I adjust my graph to get back my origin to (0,0) ?
Any idea is welcome !
Re: Zoompercent and graph scrolling
Posted: Mon Jan 30, 2012 12:34 pm
by yeray
Hi,
You could restore the default view setting the axes automatic property to true. For example:
Code: Select all
procedure TForm1.ZoomInClick(Sender: TObject);
begin
Chart1.ZoomPercent(110);
end;
procedure TForm1.ZoomOutClick(Sender: TObject);
begin
Chart1.ZoomPercent(90);
end;
procedure TForm1.ZoomResetClick(Sender: TObject);
begin
Chart1.Axes.Bottom.Automatic:=true;
Chart1.Axes.Left.Automatic:=true;
end;
Re: Zoompercent and graph scrolling
Posted: Wed May 09, 2012 2:24 pm
by 16561106
Hi Yeray,
Thanks for your answer.
Unfortunately, this does not solve my problem. I probably did't explain myself clearly enough.
When I perform
, the chart origin is changed from (0,0) to (0.4,10). I wanted to keep chart origin at (0,0).
Restoring the default view setting the axes automatic property to true (
Code: Select all
Chart1.Axes.Bottom.Automatic:=true;
) does not help, since it unzoom the graph.
Can you advise ?
Best regards,
Chesnetda
Re: Zoompercent and graph scrolling
Posted: Fri May 11, 2012 2:02 pm
by yeray
Hi,
If I'm not wrong, you are source code customer. As you'll see, the CalcAxisScale procedure, nested into TCustomChart.ZoomPercent, in Chart.pas does:
Code: Select all
if ApplyZoom then
begin
tmpDelta:=(AMax-AMin)*(PercentZoom-100.0)*0.01;
tmpA:=AMin+tmpDelta;
tmpB:=AMax-tmpDelta;
end
Changing it for this, I think it behaves as you want, applying the ZoomPercent to the left&bottom axes maximum, not to the minimum.
Code: Select all
if ApplyZoom then
begin
tmpDelta:=(AMax-AMin)*(PercentZoom-100.0)*0.01;
tmpA:=AMin;
tmpB:=AMax-tmpDelta*2;
end
Re: Zoompercent and graph scrolling
Posted: Tue May 15, 2012 9:18 am
by 16561106
Hello Yeray,
That's an elegant solution !
You're right, I should be diving into TeeChart source code more often...
Thanks a lot for your help !
All the Best,
DAvid
Re: Zoompercent and graph scrolling
Posted: Wed May 16, 2012 10:07 am
by yeray
Hi David,
You're welcome! I'm glad to see you're satisfied with it.