How to get the text of a Legend item

TeeChart FireMonkey (Windows,OSX,iOS & Android) for Embarcadero RAD Studio, Delphi and C++ Builder (XE5+)
Post Reply
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

How to get the text of a Legend item

Post by realsol » Thu Mar 09, 2017 7:06 pm

I searched but couldn't find this anywhere. Right now, I have created drill-down charts when a user clicks on a slice in a pie chart by adjusting the SQL. Getting the text was easy.

Code: Select all

But OnClickLegend does not return a ValueIndex. I want to drill-down the same way in the legend as I do now in the Chart. How can I get the text of a legend item when clicked?

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

Re: How to get the text of a Legend item

Post by Yeray » Fri Mar 10, 2017 10:05 am


This works fine for me:

Code: Select all

procedure TForm1.Chart1ClickLegend(Sender: TCustomChart; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  Caption:=Chart1.Legend.Item[Chart1.Legend.Clicked(X, Y)].Text;
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

Post Reply