Have you ever wanted to ID a "slice"of a MSChart PieChart by simply moving the mouse over it?
Well, here is a possible way to do so using a ToolTip.
Here is a screenshot
![Name: MSChartCB1.png
Views: 51
Size: 6.3 KB]()
Unfortunately, my use of Paint did not grab the mouse pointer.
However, it is in the blue slice.
Comments
HTH
EDIT-1
I noticed that if the mouse is over the control (within the border but not on a slice)
Spoo
Well, here is a possible way to do so using a ToolTip.
Code:
Dim sX()
Private Sub Command1_Click()
'
With Command1
.Top = 800
.Left = 500
End With
With MSChart1
.Top = 500
.Left = 2000
.Height = 3500
.Width = 3000
.Visible = True
'
ReDim sX(1 To 4)
sX(1) = 1.25
sX(2) = 2.25
sX(3) = 3.25
sX(4) = 5.25
'
.ChartData = sX
.ChartType = VtChChartType2dPie
.Title = "Totals Split by Acct"
'
.Column = 1
.ColumnLabel = "Acct 1"
.Column = 2
.ColumnLabel = "Acct 2"
.Column = 3
.ColumnLabel = "Acct 3"
.Column = 4
.ColumnLabel = "Acct 4"
End With
'
End Sub
Private Sub MSChart1_Mousemove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'
Dim Part As Integer
Dim Series As Integer
Dim DataPoint As Integer
Dim Index3 As Integer
Dim Index4 As Integer
'
'
With MSChart1
.TwipsToChartPart X, Y, Part, Series, DataPoint, Index3, Index4
If Series > 0 Then
.Column = Series
txt = .ColumnLabel
.ToolTipText = txt & " ... " & sX(Series)
End If
End With
'
End Sub
Unfortunately, my use of Paint did not grab the mouse pointer.
However, it is in the blue slice.
Comments
- Truth be told, I had not used a PieChart, let alone a MSChart before encountering this thread
- Credit is due to starscrea2 for the basics
- Credit is due to chosk for pointing out the TwipsToChartPart Method
- Credit is due to DEXWERX for suggesting the CodeBank location.
HTH
EDIT-1
I noticed that if the mouse is over the control (within the border but not on a slice)
- I got a Tooltip for Series 0
- so I added the test If Series > 0 Then
Spoo