How do I program MSChart so that I can drag points of an X-Y plot in the Y direction? That is, using the mouse I want to modify values in the array from which the plot was generated.
'You can drag the datapoint to any direction with this code
Option Explicit
Dim OldX As Single, OldY As Single
Dim DragPoint As Integer, DragSeries As Integer
Dim Dragging As Boolean
Private Sub MSChart1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ThePart%, TheSeries%, ThePoint%, P3%, P4%
If Not Dragging Then
MSChart1.TwipsToChartPart X, Y, ThePart, TheSeries, ThePoint, P3, P4
If ThePart = VtChPartTypePoint Then
OldX = X
OldY = Y
DragSeries = TheSeries
DragPoint = ThePoint
Dragging = True
End If
End If
End Sub
Private Sub MSChart1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ThePart%, TheSeries%, ThePoint%, P3%, P4%
Dim TheData As Double
Dim TheNull As Integer
If Dragging Then
MSChart1.DataGrid.GetData DragPoint, DragSeries, TheData, TheNull
If Y < OldY Then
OldY = Y
TheData = TheData + 1
Else
OldY = Y
TheData = TheData - 1
End If
MSChart1.DataGrid.SetData DragPoint, DragSeries, TheData, TheNull
MSChart1.Refresh
' Display Label To Show Current Value
'MsgBox MSChart1.Plot.SeriesCollection.Item(DragSeries).DataPoints.count
With MSChart1.Plot.SeriesCollection.Item(DragSeries).DataPoints.Item(DragPoint).DataPointLabel
.LocationType = VtChLabelLocationTypeAbovePoint
.Component = VtChLabelComponentValue
.ValueFormat = "0.0"
.Backdrop.Frame.Style = VtFrameStyleSingleLine
End With
End If
End Sub
Private Sub MSChart1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Turn Dragging Off
Dragging = False
' Turn Point Label Off
With MSChart1.Plot.SeriesCollection.Item(DragSeries).DataPoints.Item(DragPoint).DataPointLabel
.LocationType = VtChLabelLocationTypeNone
End With
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.