Problems with Cursor interval Chart - vb 2010

lkmaurik

New member
Joined
Jan 14, 2013
Messages
2
Programming Experience
1-3
Hey all,

This is my first day on this forum. So let’s start whit a Question.

I'm trying to make a chart where my cursor says the X and Y values. Sadly I can’t get an interval of 0.1 at these values. The smallest interval I can get is 1.

As example, I cant get the values between 1 and 2. The cursor jumps auto to value 1 or 2.

For my test program I'm using the following code:

VB.NET:
 Private Sub chart1_MouseWhatever(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseMove

        If GraphOn = True Then

            'Aanmaken van variabels
            Dim test2 As HitTestResult = Chart1.HitTest(e.X, e.Y)

            Dim Cursorx As Integer = e.X
            Dim Cursory As Integer = e.Y

            Dim xvalue As Int64
            Dim yvalue As Int64


            'Als je in het plottinggebied komt dan
            If test2.ChartElementType = ChartElementType.PlottingArea Then

                'Set X-line 
                Chart1.ChartAreas(0).AxisX.MajorTickMark.Interval = 0.1
                Chart1.ChartAreas(0).AxisX.Interval = 0.1
                Chart1.ChartAreas(0).CursorX.Interval = 0.1

                xvalue = Chart1.ChartAreas(0).AxisX.PixelPositionToValue(Cursorx)


                Chart1.ChartAreas(0).CursorX.IntervalType = DateTimeIntervalType.Auto

                Chart1.ChartAreas(0).CursorX.SetCursorPosition(xvalue)

                'Set y-line 
                yvalue = Chart1.ChartAreas(0).AxisY.PixelPositionToValue(Cursory)
                Chart1.ChartAreas(0).CursorY.Interval = 0
                Chart1.ChartAreas(0).CursorY.SetCursorPosition(yvalue)

                Label1.Text = "Cursor = " & xvalue & " , " & yvalue & " (x,y)"

            End If

        End If
    End Sub

Hopefully someone can tell me why I can get a smaller interval.

Thanks in advance.
 
Hey all,

Problem solved. I changed the variable 'xvalue' and 'yvalue' as int64 in a double.

Now the code is working.

I have no idea how to solve this post.

Leroy
 
Last edited:
Back
Top