when user click in the legend area. Suppose i have 5 series, how to detect which series is being clicked.
thank you
Detect which series is being clicked when clicking legend
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Herman,
You can use the chart's OnClickLegend event. Using the Clicked method you will get the series index starting at 0 and with the index you will be able to address each sereis. This is a small example on how to use this:
You can use the chart's OnClickLegend event. Using the Clicked method you will get the series index starting at 0 and with the index you will be able to address each sereis. This is a small example on how to use this:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
for i:=0 to Chart1.SeriesCount-1 do
begin
Chart1[i].FillSampleValues();
Chart1[i].SeriesColor:=clRed;
end;
end;
procedure TForm1.Chart1ClickLegend(Sender: TCustomChart;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
SeriesIndex: Integer;
begin
SeriesIndex:=Chart1.Legend.Clicked(X,Y);
Chart1[SeriesIndex].SeriesColor:=clBlue;
Chart1.Title.Text.Clear;
Chart1.Title.Text.Add(IntToStr(SeriesIndex));
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |