Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSChart

Status
Not open for further replies.

acoust

Technical User
Oct 20, 2001
4
US
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 = &quot;0.0&quot;
.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

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top