Zoom outside of Plot rectangle

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
BE
Newbie
Newbie
Posts: 41
Joined: Tue Nov 16, 2004 5:00 am

Zoom outside of Plot rectangle

Post by BE » Tue Dec 18, 2007 1:26 pm

Hi,

Is there a way to zoom starting from out side of the plot rectangle? I've been trying to zoom with mouse down at the outside of plot rectangle (within the Chart), but as soon as mouse is down out side of the plot rectangle, the zoom function disables. I'd like to zoom in (zoom rectangle covers both in and out of the plot) at the edge of the plot rectangle without have to move the plot first.

Thanks

-Bill

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Dec 18, 2007 2:21 pm

Hi Bill,

In that case you can zoom doing something like this:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if MouseOutOfChartRect(X,Y) then
  begin
    X0:=X;
    Y0:=Y;
  end;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var R: TRect;
begin
  if ((X0<>-1) and (Y0<>-1)) then
  begin
    R.Left:=X0;
    R.Top:=Y0;
    R.Right:=X;
    R.Bottom:=Y;
    Chart1.ZoomRect(R);
  end;

  X0:=-1;
  Y0:=-1;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  X0:=-1;
  Y0:=-1;
end;

function TForm1.MouseOutOfChartRect(X, Y: Integer): boolean;
begin
  result:=((X<Chart1.ChartRect.Left) or (Y<Chart1.ChartRect.Top));
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  X1:=X;
  Y1:=Y;

  Chart1.Repaint;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  if ((X0<>-1) and (Y0<>-1)) then
  begin
    Chart1.Canvas.Brush.Style:=bsClear;
    Chart1.Canvas.Pen.Color:=Chart1.Zoom.Pen.Color;
    Chart1.Canvas.Pen.Style:=Chart1.Zoom.Pen.Style;
    Chart1.Canvas.Rectangle(X0,Y0,X1,Y1);
  end;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply