ChartGroup.CoordToPointIndex missing

Posted by: jason10 on 3 August 2017, 3:38 am EST

  • Posted 3 August 2017, 3:38 am EST

    The documentation specifies this method exists but it's not in the object browser and my code will not compile when attampting to use it. Can this method be made visible? I really need this. CoordToDataIndex is not good enough because I need to check against a specific series.
  • Replied 3 August 2017, 3:38 am EST

    Apparently this group is not monitored. I implemented my own solution which I am providing below. It has not been well-tested.

    Public Shared Function CoordToPointIndex( _
    ByVal Group As ChartGroup, _
    ByVal XCoord As Int32, _
    ByVal YCoord As Int32, _
    ByVal SeriesIndex As Int32, _
    ByRef PointIndex As Int32, _
    ByRef Distance As Int32 _
    ) As Boolean

    Dim liClientX As Int32
    Dim liClientY As Int32
    Dim liPointIndex As Int32
    Dim lfCompDistance As Single
    Dim lfShortestDistance As Single

    lfShortestDistance = Single.MaxValue

    With Group.ChartData.SeriesList.Item(SeriesIndex)
    For liIndex As Int32 = 0 To .Length - 1
    If Group.DataCoordToCoord(CDbl(.X.Item(liIndex)), CDbl(.Y.Item(liIndex)), liClientX, liClientY) Then
    lfCompDistance = LineLength(XCoord, YCoord, liClientX, liClientY)
    If lfShortestDistance > lfCompDistance Then
    lfShortestDistance = lfCompDistance
    liPointIndex = liIndex
    End If
    End If
    End With
    If lfShortestDistance = Single.MaxValue Then
    PointIndex = -1
    Distance = Int32.MaxValue
    PointIndex = liPointIndex
    Distance = CInt(lfShortestDistance)
    End If
    End Function
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels