Zooming from Outside Chart axes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
X-Ray
Newbie
Newbie
Posts: 49
Joined: Fri Jan 27, 2012 12:00 am

Zooming from Outside Chart axes

Post by X-Ray » Mon Jan 18, 2016 11:25 am

Hello,

often when a range that needs to be zoomed in is close to an axis its not easy to achieve because the zoom rectangle can
only be started inside the chart axes area. Is there a simple option to enable the zoom rectangle to start outside the TChart axes ?

best regards,

X-ray

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

Re: Zooming from Outside Chart axes

Post by Yeray » Mon Jan 18, 2016 3:10 pm

Hello,

You can Activate the Zoom and Panning at the OnClickBackground event as follows:

Code: Select all

procedure TForm1.Chart1ClickBackground(Sender: TCustomChart;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  with Chart1 do
  begin
    if Zoom.Allow and (Button=Zoom.MouseButton) and
       (Zoom.KeyShift<=Shift) then
    Begin
      if Zoom.Direction=tzdVertical then x:=ChartRect.Left;
      if Zoom.Direction=tzdHorizontal then y:=ChartRect.Top;

      Zoom.Activate({$IFDEF FMX}Round{$ENDIF}(x),{$IFDEF FMX}Round{$ENDIF}(y));

      if Zoom.Direction=tzdVertical then
         Zoom.X1:={$IFDEF FMX}Round{$ENDIF}(ChartRect.Right);

      if Zoom.Direction=tzdHorizontal then
         Zoom.Y1:={$IFDEF FMX}Round{$ENDIF}(ChartRect.Bottom);
    end;

    if (AllowPanning<>pmNone) and (Button=ScrollMouseButton) and
       (TeeScrollKeyShift<=Shift ) then
    Begin
      Panning.Activate({$IFDEF FMX}Round{$ENDIF}(x),
                       {$IFDEF FMX}Round{$ENDIF}(y));
    end;

    CancelMouse:=false;
  end;
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

X-Ray
Newbie
Newbie
Posts: 49
Joined: Fri Jan 27, 2012 12:00 am

Re: Zooming from Outside Chart axes

Post by X-Ray » Tue Jan 19, 2016 7:02 am

Hello Yeray,

very useful, thank You !
In fact it would be nice if this was just another flag/option of TChart.

best regards,

X-Ray

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

Re: Zooming from Outside Chart axes

Post by Yeray » Tue Jan 19, 2016 9:47 am

Hello,

Ok. I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1408
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