How can I get series index from cursor position when I click TChart?
Thank you.
From your clicked event, you will get the X,Y
mouse position.
var
SeriesIndex: Integer;
begin
SeriesIndex := Series1.Clicked(X,Y);
if (SeriesIndex <> -1) then
begin
// Do something with SeriesIndex
end;
...
end;
It is also possible to assign an OnClickSeries
event to the chart.
procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);