Page 1 of 1

Legend on top of chart?

Posted: Tue Feb 22, 2011 6:07 pm
by 9339286
As I'm showing the legend of my chart only on demand (click) i would like to have it drawn on top of the grid and all series (lower image) but it seems always to be shown below (lower image).
Is there a way to accomplish this?
legend.JPG
legend.JPG (19.44 KiB) Viewed 5584 times
TIA

Re: Legend on top of chart?

Posted: Wed Feb 23, 2011 12:55 pm
by 10050769
Hello TIA,

I couldn't reproduce your problem using last version 2010. Can you please, send us a simple project we can run as-is here? So we try to find a solution for your problem. Moreover you can tell us which version of TeeChartVCL you are using now?

Thanks,

Re: Legend on top of chart?

Posted: Wed Feb 23, 2011 6:15 pm
by 9339286
I've attached a simple form (no code). When I open the form the legend is drawn behind everything (actually showing the back wall completly hides the legend). This is the form, where yesterdays screenshot origins from.

I've had that with the older version of tchart as well as with the current (2010.02.20202).

TIA (which means Thanks In Advance :wink: )

Re: Legend on top of chart?

Posted: Thu Feb 24, 2011 11:56 am
by narcis
Hi Whookie,

Ok, I had to look at the form in text mode then :wink:

The problem was ResizeChart property set to false. To achieve what you request you should set legend to a custom position as in the code snippet below.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart.Legend.ResizeChart:=True;
  Chart.Legend.CustomPosition:=True;
  Chart.Draw;
end;

procedure TForm1.ChartAfterDraw(Sender: TObject);
begin
  Chart.Legend.Left:=Chart.ChartRect.Right - Chart.Legend.Width - 10;
  Chart.Legend.Top:=10;
end;