1

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...

Leo Bruno
  • 474
  • 3
  • 16
  • Addenddum:I can´t use anything related to mouse click, since I´m already dragging an object to the TChart Object; – Leo Bruno Apr 11 '17 at 22:21
  • Perhaps you could use method CalcClickedPart (http://www.teechart.net/docs/teechart/vclfmx/lib/html/TCustomChart.CalcClickedPart.html) which allows you to get information about which TeeChart component is below the mouse pointer. Another method that could be usefull to you is GetCursorValueIndex (http://www.teechart.net/docs/teechart/vclfmx/lib/html/TChartSeries.GetCursorValueIndex.html) of specific series which returns index value of the closest series point. – SilverWarior Apr 12 '17 at 05:51
  • Thanks for your help. I keep getting index 0, no matter whitch series I drag the object to. I have tried the two methods you mentioned, but no success at all. – Leo Bruno Apr 12 '17 at 11:44

2 Answers2

2

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;
Yeray
  • 5,009
  • 1
  • 13
  • 25
  • This is what I´ve done before posting this thread. I keep geting index 0 no matter to which series I drag the object. Perhaps because the series was not clicked. For this reason I have mentioned that I can´t use anything related to MouseClick. But thanks anyway. – Leo Bruno Apr 12 '17 at 11:16
  • Gee, My bad. I was under the impression that I should work with the "Clicked(x,y)" value, and I should work with the loop index instead. Thanks – Leo Bruno Apr 12 '17 at 12:15
  • The `Clicked` function returns the `ValueIndex` of the point at the given X,Y position. It returns `-1` if no point is at that position. – Yeray Apr 13 '17 at 08:47
0

The "AChart[SeriesIndex].Clicked(X, Y)" method solves the problem. I realized that I was using the return value of the method, instead of using the loop index.

Leo Bruno
  • 474
  • 3
  • 16