-1

I will be very thankfull if somebody could help me with my problem. I have some data plotted on VB.Net Chart like on the picture bellow. Chart Example

What I need is to select with mouse some points (I figured out how to select one point, but the trick is to select group of points...) on chart and put them in certain array?

Looking forward to your answers.

  • When asking a question about a problem caused by your code, you will get much better answers if you provide code people can use to reproduce the problem. Please see http://stackoverflow.com/help/mcve to help you write a Minimal, Complete, and Verifiable example. – Baddack May 16 '16 at 23:50

1 Answers1

0

I will try to be more precise. This is what i have been done so far and that is not much. I am beginner in programming so be gentle:)

 chGrupa1.ChartAreas(0).CursorX.IsUserSelectionEnabled = True
    chGrupa1.ChartAreas(0).CursorY.IsUserSelectionEnabled = True
    Dim htrResult As HitTestResult = chGrupa1.HitTest(Cursor.Position.X, Cursor.Position.Y)
    For Each dp As DataPoint In chGrupa1.Series(0).Points
        ListBox2.Items.Add(dp.XValue.ToString())
        ListBox3.Items.Add(dp.YValues(0).ToString())
    Next dp

Example I found on internet looks like code bellow:

' Mouse Down Event Private Sub Chart1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseDown

' Call Hit Test Method Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)

If result.ChartElementType = ChartElementType.DataPoint Then

'Create Dialog
Dim dlg As New Dialog()

'Initialize members
dlg.ChartRef = Chart1
dlg.pointIndex = result.PointIndex

' Show dialog
dlg.Show()

Else
If result.ChartElementType <> ChartElementType.Nothing Then
    Dim elementType As String = result.ChartElementType.ToString()
    MessageBox.Show(Me, "Selected Element is: " + elementType)
End If
End If

End Sub 'Chart1_MouseDown

' Mouse Move Event Private Sub Chart1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseMove

' Call Hit Test Method Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)

' If a Data Point or a Legend item is selected.
If result.ChartElementType = ChartElementType.DataPoint Or result.ChartElementType = ChartElementType.LegendItem Then
    ' Set cursor type 
    Me.Cursor = Cursors.Hand
Else
    If result.ChartElementType <> ChartElementType.Nothing And result.ChartElementType <> ChartElementType.PlottingArea Then
        ' Set cursor type 
        Me.Cursor = Cursors.Hand
    Else
        ' Set default cursor
        Me.Cursor = Cursors.Default
    End If
End If

End Sub 'Chart1_MouseMove

Main problem for me, is how to determine which points are inside of selected area and how to get their indexes...