Zoompercent and graph scrolling

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
chesnetda
Newbie
Newbie
Posts: 3
Joined: Fri Dec 16, 2011 12:00 am
Location: Poitiers, France
Contact:

Zoompercent and graph scrolling

Post by chesnetda » Fri Jan 27, 2012 11:49 am

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 !
Attachments
before.jpg
original chart
before.jpg (78.18 KiB) Viewed 5699 times
after.jpg
after zooming in by 10%
after.jpg (64.91 KiB) Viewed 5691 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Zoompercent and graph scrolling

Post by Yeray » Mon Jan 30, 2012 12:34 pm

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

chesnetda
Newbie
Newbie
Posts: 3
Joined: Fri Dec 16, 2011 12:00 am
Location: Poitiers, France
Contact:

Re: Zoompercent and graph scrolling

Post by chesnetda » Wed May 09, 2012 2:24 pm

Hi Yeray,
Thanks for your answer.
Unfortunately, this does not solve my problem. I probably did't explain myself clearly enough.
When I perform

Code: Select all

Chart1.ZoomPercent(110);
, 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

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Zoompercent and graph scrolling

Post by Yeray » Fri May 11, 2012 2:02 pm

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

chesnetda
Newbie
Newbie
Posts: 3
Joined: Fri Dec 16, 2011 12:00 am
Location: Poitiers, France
Contact:

Re: Zoompercent and graph scrolling

Post by chesnetda » Tue May 15, 2012 9:18 am

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

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Zoompercent and graph scrolling

Post by Yeray » Wed May 16, 2012 10:07 am

Hi David,

You're welcome! I'm glad to see you're satisfied with it. :)
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply