TeeChart Legend
Posted: Tue Sep 20, 2016 1:25 pm
Is there a means of allowing the user to drag and resize the legend for a chart?
Steema Software - Customer Support Forums
http://teechart.com/support/
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;