TeeChart Legend

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Sharpenski
Newbie
Newbie
Posts: 36
Joined: Wed Aug 24, 2016 12:00 am

TeeChart Legend

Post by Sharpenski » Tue Sep 20, 2016 1:25 pm

Is there a means of allowing the user to drag and resize the legend for a chart?

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

Re: TeeChart Legend

Post by Yeray » Wed Sep 21, 2016 9:37 am

Hello,

You can do it manually using the mouse events. Ie:

Code: Select all

uses Series;

var legendDragging: Boolean;
    oldPos: TPoint;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  Chart1.AddSeries(TBarSeries).FillSampleValues();

  legendDragging:=false;
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Chart1.Legend.Clicked(X, Y)>-1 then
  begin
    legendDragging:=True;
    oldPos:=Point(X,Y);
  end;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  legendDragging:=False;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if Chart1.Legend.Clicked(X, Y)>-1 then
  begin
    Chart1.Cursor:=crHandPoint;
  end;

  if legendDragging then
  begin
    Chart1.Legend.CustomPosition:=true;
    Chart1.Legend.Left:=Chart1.Legend.Left+(X-oldPos.X);
    Chart1.Legend.Top:=Chart1.Legend.Top+(Y-oldPos.Y);
    oldPos:=Point(X,Y);
  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

Post Reply