I have a chart and i want to show coordinates when moving mouse on it.
This is the software:
Private Sub Chart1_MouseMove(sender As Object, e As MouseEventArgs) Handles Chart1.MouseMove
Dim pos, settore_unita As Single
Dim x, y As Single
If Me.Chart1.ChartAreas(0).AxisY.Enabled = 1 Then
Me.Label_tempo.Visible = True
Dim ht As DataVisualization.Charting.HitTestResult = Chart1.HitTest(e.X, e.Y)
If Not ht.ChartElementType = ChartElementType.Nothing Then
Dim xx As Double = ht.ChartArea.AxisX.PixelPositionToValue(e.X)
Dim yy As Double = ht.ChartArea.AxisY.PixelPositionToValue(e.Y)
If xx >= Chart1.ChartAreas(0).AxisX.Minimum And xx <= Chart1.ChartAreas(0).AxisX.Maximum And
yy >= Chart1.ChartAreas(0).AxisY.Minimum And yy <= Chart1.ChartAreas(0).AxisY.Maximum Then
Me.Label_tempo.Text = Format(yy, "f")
End If
End If
End If
End Sub
The problem is that the resolution is low (never appears zero when on top of chart) and refreshing is slow.
The same program in VB6 works perfectely.