Hello,
I have an issue with placing the legend in a custom position, I have some code set inside the OnGetLegendRect to set the Rect position but I need to get an axis IAxisSize (I have a custom bottom axis). Once my application loads data to the plot the legend appears a little off position but once I move the mouse over the plot the legend jumps back to the correct position. Is there a way to make the chart recalculate the values IStartPos, IStartEnd etc?
Legend custom position
Re: Legend custom position
Hello,
You probably need to force a chart repaint so some internal properties are calculated the second time the OnGetLegendRect event is fired.
You probably need to force a chart repaint so some internal properties are calculated the second time the OnGetLegendRect event is fired.
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
//...
Chart1.Draw;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Legend custom position
Hello,
Thank you for your reply, I already tried that, has an affect on the position of the legend but it still moves once the mouse pasts over the plot.
Regards
Thank you for your reply, I already tried that, has an affect on the position of the legend but it still moves once the mouse pasts over the plot.
Regards
Re: Legend custom position
Hello,
If you could send us a simple example project to reproduce the problem here it could help us to provide a fix/workaround.
If you could send us a simple example project to reproduce the problem here it could help us to provide a fix/workaround.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Legend custom position
Hello,
It looks like I cannot reproduce the issue outside my application so I would like to ask this question, I need the legend rectangle to be drawn in a specific position inside the chart area for example 20 pixels above bottom axis and 20 pixels right of the left axis (plot can be empty of data but there is always at least 1 line series attached)
Regards
It looks like I cannot reproduce the issue outside my application so I would like to ask this question, I need the legend rectangle to be drawn in a specific position inside the chart area for example 20 pixels above bottom axis and 20 pixels right of the left axis (plot can be empty of data but there is always at least 1 line series attached)
Regards
Re: Legend custom position
Hello,
You could use the Legend in CustomPosition. Ie:
The only problem is the ChartRect is defined later than than the Legend drawing. That's why you should make sure the chart has been redrawn before using ChartRect to set the Legend position.
You could use the Legend in CustomPosition. Ie:
Code: Select all
uses Series;
procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
begin
Chart1.Legend.CustomPosition:=True;
Chart1.Legend.Left:=TChart(Sender).ChartRect.Left+20;
Chart1.Legend.Top:=TChart(Sender).ChartRect.Bottom-20-Chart1.Legend.Height;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=False;
Chart1.Legend.LegendStyle:=lsSeries;
Chart1.AddSeries(TLineSeries);
Chart1.Draw;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |