Sven
Sven

Reputation: 53

Events in a chart win forms for a point which lies on the axis line in VB.net

Chart form where the point which lies on the axis

In a chart windows form the point the events for the point which lies on the axis line is not functioning . I have added a tool tip and chart mousedown/chart mouseup functions for the points. But when I change move the axis minimum value it seems to function. For other points which do not lie on the axis the tool tip functions work.

Upvotes: 1

Views: 50

Answers (1)

Sven
Sven

Reputation: 53

With the reference of the below links I was able to make changes in the code and that worked . I segregated the cases for on the axis and the remaining other points in the chart.

Problem with Point ToolTip in Microsoft Charts

https://social.msdn.microsoft.com/Forums/vstudio/en-US/04c23273-c683-437c-8f6e-db81e93b54c8/tooltip-for-chart-does-not-show-when-datapoints-are-on-the-axes?forum=MSWinWebChart

Private Sub Chart1_GetToolTipText(ByVal sender As Object, ByVal e As System.Windows.Forms.DataVisualization.Charting.ToolTipEventArgs) Handles Chart1.GetToolTipText

        Select Case e.HitTestResult.ChartElementType
            Case ChartElementType.Axis, ChartElementType.TickMarks
                Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y, ChartElementType.DataPoint)
                If result.ChartElementType = ChartElementType.DataPoint Then
                    e.Text = result.Series.Points(result.PointIndex).XValue.ToString & " : " & result.Series.Points(result.PointIndex).YValues(0).ToString
                End If
                Exit Select
        End Select
    End Sub

Upvotes: 1

Related Questions