[Vb2010+] Spostare Series in una chart a Dx/Sn

di il
2 risposte

[Vb2010+] Spostare Series in una chart a Dx/Sn

Salve, ho questo problemino, premetto che ho dichiarato i dati inseriti nella series in double come richiesto dalla classe

e i dati inserito sono:
file 1
10.09
12.67
15.17
19.18
19.34
21.34
22.10
23.12
23.10
20.12
19.07
24.10
e sono tempi realizzati in bicicletta
non posto il codice di in inserimento perchè non è importante

ora per poter spostare una series da destra e sinistra o viceversa usavo questo codice:
 
 Private _selectedValue As Double
    Private _currentPoint As DataPoint
    Private _currentValue As Double
    Private _previousPoint As DataPoint
    Private _previousValue As Double
    Private _selectedPoint As DataVisualization.Charting.DataPoint
    Private _selectedPointIndex As Integer
    Private _selectedSeries As DataVisualization.Charting.Series
    Private eXPre As Integer
    Private eYPre As Integer
    Private selectedPointIndex As Integer = -1
 Private Sub Chart1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseMove
If CheckBox2.Checked = True Then

            Dim hitResult As DataVisualization.Charting.HitTestResult = Chart1.HitTest(e.X, e.Y)
            If hitResult.ChartElementType = DataVisualization.Charting.ChartElementType.DataPoint Then
                Chart1.Cursor = Cursors.Hand
            Else
                Chart1.Cursor = Cursors.Default
            End If

            If _selectedPoint Is Nothing Then Exit Sub
            Try
                '#############################################################################################################################

                For Each DP As DataVisualization.Charting.DataPoint In _selectedSeries.Points

                    Select Case True
                        Case CheckBox5.Checked And CheckBox6.Checked
                            ' Debug.WriteLine("Condizione 1 e 2") Spostamento Alto/Basso Destra/Sinistra
                            DP.XValue += Chart1.ChartAreas(0).AxisX.PixelPositionToValue(e.X) - Chart1.ChartAreas(0).AxisX.PixelPositionToValue(eXPre)
                            DP.YValues(0) += Chart1.ChartAreas(0).AxisY.PixelPositionToValue(e.Y) - Chart1.ChartAreas(0).AxisY.PixelPositionToValue(eYPre)
                        Case CheckBox5.Checked
                            'Debug.WriteLine("Condizione 1") Spostamento Alto/Basso
                            DP.YValues(0) += Chart1.ChartAreas(0).AxisY.PixelPositionToValue(e.Y) - Chart1.ChartAreas(0).AxisY.PixelPositionToValue(eYPre)
                        Case CheckBox6.Checked
                            ' Debug.WriteLine("Condizione 2")Spostamento Dastra/Sinistra
                            DP.XValue += Chart1.ChartAreas(0).AxisX.PixelPositionToValue(e.X) - Chart1.ChartAreas(0).AxisX.PixelPositionToValue(eXPre)
                        Case Else
                            'Debug.WriteLine("Condizione 0")

                    End Select

                Next
end if
end  sub
Private Sub Chart1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseDown
        Try
            If CheckBox3.Checked = True Then
                Me.CheckBox2.Checked = False
                Chart1.ChartAreas("ChartArea1").CursorX.IsUserEnabled = False
                Chart1.ChartAreas("ChartArea1").CursorX.IsUserSelectionEnabled = False
                Chart1.ChartAreas("ChartArea1").AxisX.ScaleView.Zoomable = False
                Chart1.ChartAreas("ChartArea1").AxisX.ScrollBar.IsPositionedInside = False
                Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)

            
           
            End If
            If CheckBox2.Checked = True Then

                '  Spostamento Punti
                Dim result As DataVisualization.Charting.HitTestResult = Chart1.HitTest(e.X, e.Y)
                If result.ChartElementType = DataVisualization.Charting.ChartElementType.DataPoint Then
                    _selectedPointIndex = result.PointIndex
                    _selectedSeries = result.Series
                    _selectedPoint = result.Series.Points(_selectedPointIndex)
                    eXPre = e.X
                    eYPre = e.Y

              
            End If
        Catch ex As Exception
        End Try
    End Sub
il problema che quando tento di spostarla il valore è minore di 1 e mi allinea la series su un asse verticale invece di spostarla, dove sbaglio?
Mi dareste una mano ?, mi risulta allineata in queto modo :

prima dello spostamento:



dopo lo spostamento:

2 Risposte

Devi accedere o registrarti per scrivere nel forum
2 risposte