Page 1 of 1

Show Chart Legend on Preview/Print

Posted: Thu Apr 05, 2018 10:32 am
by 16582208
Hi,

Using TChart in my application I do not use/show the ChartLegend, rather I have my own 'Legend' using some CheckListBoxes to Hide/Show ChartSeries.
Now when I preview/print my TChart I would like to show the standard ChartLegend.

So my questions is: Is there a way to display the ChartLegend on Print/Preview without having the Chart.Legend.Visible := true; in my main application?

Thanks,
Leo

Re: Show Chart Legend on Preview/Print

Posted: Mon Apr 09, 2018 10:48 am
by yeray
Hello Leo,

If you aren't calling print/printpreview manually in a button or similar, you could use events. Ie:

Code: Select all

procedure TForm1.Chart1BeforeDrawChart(Sender: TObject);
begin
  if Chart1.Printing then
     Chart1.Legend.Show;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
   Chart1.Legend.Hide;
end;

Re: Show Chart Legend on Preview/Print

Posted: Tue Apr 10, 2018 8:05 am
by 16582208
Thank you, that did the trick

Leo