Search code examples
delphiindexingmouseseriesteechart

Delphi TChart - How to get a series index from x,y mouse coordinates without clicking on it


I´m writing a new method fired at "OnEndDrag" Event of a TChart standard on Delphi XE7.

I need to know which series the object was dragged to, to perform some actions on a dataset linked to it.

I´m getting the correct xy positions with the event "OnDragOver" and the series gets correctly highlihghted when I drag over it.

Any clues ?

Thanx in advance...


Solution

  • You can loop your series list and call Clicked function as follows:

    var SeriesIndex: Integer;
    begin
      for SeriesIndex:=0 to AChart.SeriesCount-1 do
      begin
        if AChart[SeriesIndex].Clicked(X, Y)>-1 then
           //do whatever with AChart[SeriesIndex]
      end;
    end;