Draw horizontal line with DrawLine tool

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Arnold D
Newbie
Newbie
Posts: 5
Joined: Sun Nov 04, 2001 5:00 am

Draw horizontal line with DrawLine tool

Post by Arnold D » Mon Mar 20, 2006 4:13 pm

Is it possible to draw an horizontal line with drawline?

I've tried the ondrawline event and set the toPoint.Y := FromPoint.Y, but then I get rumble during the dragging. A redraw isn't the solution too.

I'm using D7 + Tchart 7

ps. I want to use the right mouse button to drag a line.

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

Post by Narcís » Mon Mar 20, 2006 5:39 pm

Hi Arnold D,

You can easily do that custom drawin on TChart's canvas doing something like this:

Code: Select all

var
  Form1: TForm1;
  X0,Y0,X1,Y1: Integer;
  Down: boolean;

implementation

{$R *.dfm}

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

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Button=mbRight) then
  begin
    X1:=X;
    Y1:=Y;
    Down:=false;
    Chart1.Draw;
  end;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  With Chart1.Canvas do
  begin
    MoveTo(X0,Y0);
    LineTo(X1,Y0);
  end;
end;

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

    Chart1.Draw;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 Down:=false;
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

Arnold D
Newbie
Newbie
Posts: 5
Joined: Sun Nov 04, 2001 5:00 am

Post by Arnold D » Tue Mar 21, 2006 7:36 am

Thanks!

Post Reply