Show Chart Legend on Preview/Print

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Leo_
Newbie
Newbie
Posts: 2
Joined: Fri Nov 03, 2017 12:00 am

Show Chart Legend on Preview/Print

Post by Leo_ » Thu Apr 05, 2018 10:32 am

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Show Chart Legend on Preview/Print

Post by Yeray » Mon Apr 09, 2018 10:48 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Leo_
Newbie
Newbie
Posts: 2
Joined: Fri Nov 03, 2017 12:00 am

Re: Show Chart Legend on Preview/Print

Post by Leo_ » Tue Apr 10, 2018 8:05 am

Thank you, that did the trick

Leo

Post Reply