1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
Option Explicit
Public WithEvents Graph As Chart
'*** Utilisation des évènements *********
Private Sub Graph_MouseMove(ByVal Button As Long, ByVal Shift As Long, _
ByVal X As Long, ByVal y As Long)
Dim pt As POINTAPI
GetCursorPos pt
Dim dX As Single, dY As Single
dX = X - (X - 5): dY = y - (y / 2 - 15)
Dim ElementID As Long
Dim Arg1 As Long, Arg2 As Long
On Error Resume Next
ActiveChart.GetChartElement X, y, ElementID, Arg1, Arg2
Dim OuX As Single, OuY As Single
OuX = X
OuY = (y / 100 + (dY / 0.6))
Application.StatusBar = y & " " & OuY
With ActiveChart.Shapes("Rectangle 1")
.Visible = msoTrue
.TextFrame.Characters.Text = _
Worksheets("STATS").Range("V1").Offset(Arg2 - 1, 4).Value
.AutoSize = True
If Worksheets("STATS").Range("V1").Offset(Arg2 - 1, 4).Value > 250 Then
.Fill.ForeColor.RGB = RGB(255, 0, 0)
Else
.Fill.ForeColor.RGB = RGB(0, 0, 0)
End If
.Left = OuX - 100
.Top = OuY - 100
End With
With ActiveChart.Shapes("Rectangle 2")
.Visible = msoTrue
.TextFrame.Characters.Text = _
Worksheets("STATS").Range("V1").Offset(Arg2 - 1, -1).Value
.ScaleHeight 1.5, msoTrue
.Fill.ForeColor.RGB = RGB(10, 0, 0)
.Left = OuX
.Top = OuY - 75
End With
End Sub |
Partager