Hello all,
I am using version 8.04 and I need some hints on how to fix the legend position relative to top left point of the Y axis. I want to make sure that regardless the dimensions of my plots the legend is always inside the chart.
Regards
Fixed legend position
Hi johnnix!!
You can solve the problem using event AfterDraw with the corresponent code, for exemple:
But, also you have to put next line to code in the FormCreate, but because don't draw legend to position indicated:
Best Regards,
Sandra Pazos
Steema Support Central
http://support.steema.com
You can solve the problem using event AfterDraw with the corresponent code, for exemple:
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var
x,y:Integer;
begin
Chart1.Legend.CustomPosition:=True;
x:=Chart1.ChartRect.Left;
y:=Chart1.ChartRect.Top;
Chart1.Legend.Left:=x;
Chart1.Legend.Top:=y;
end;
Code: Select all
Chart1.Draw;
Best Regards,
Sandra Pazos
Steema Support Central
http://support.steema.com
Hello,
Than you for your reply. My issue with this code is that somewhere in my app I use the following code:
var m : TMetafile;
begin
if Sender.Name='pic1' then
begin
m := my_plot.TeeCreateMetafile(false,
Rect(0, 0, Round(Sender.Width), Round(Sender.Height)));
TfrxPictureView(Sender).Picture.Assign(m);
m.Free;
end;
This code assigns the plot metafile to a picture object of a FReport. After the code runs the legend makes a "jump" (moves a little bit) and I need to resize the plot in order to return to his original position. Obviously the AfterDraw procedure is called when calling the TeeCreateMetafile function.
Is there another way to do such a task using e.g. the OnGetLegendRect or OnGetLegendPos functions?
Regards
Than you for your reply. My issue with this code is that somewhere in my app I use the following code:
var m : TMetafile;
begin
if Sender.Name='pic1' then
begin
m := my_plot.TeeCreateMetafile(false,
Rect(0, 0, Round(Sender.Width), Round(Sender.Height)));
TfrxPictureView(Sender).Picture.Assign(m);
m.Free;
end;
This code assigns the plot metafile to a picture object of a FReport. After the code runs the legend makes a "jump" (moves a little bit) and I need to resize the plot in order to return to his original position. Obviously the AfterDraw procedure is called when calling the TeeCreateMetafile function.
Is there another way to do such a task using e.g. the OnGetLegendRect or OnGetLegendPos functions?
Regards
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi johnnix,
Yes, you can do this:
Yes, you can do this:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Draw;
end;
procedure TForm1.Chart1GetLegendRect(Sender: TCustomChart;
var Rect: TRect);
var w, h: Integer;
begin
w:=Chart1.Legend.Width;
h:=Chart1.Legend.Height;
Chart1.Legend.CustomPosition:=true;
Rect.Left:=Chart1.ChartRect.Left;
Rect.Top:=Chart1.ChartRect.Top;
Rect.Right:=Rect.Left+w;
Rect.Bottom:=Rect.Top+h;
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 |
Instructions - How to post in this forum |