View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.charting
MikeM MikeM is offline
external usenet poster
 
Posts: 64
Default Elementary(?) GetChartElement Question

I tried your code, but there was no change.

The program was working fine, as originally written, when the data was
plotted as xyscattergrams. However, when I converted them to area plots,
that's when the problem popped up. [I should have mentioned this earlier :-(
, but I thought that this was (or should be) irrelevant. Apparently it isn't.]

"Jon Peltier" wrote:

I can't break it in 2007 SP2 or 2003 SP3 in three ways: on a chart sheet
with the code behind the sheet, on a chart sheet using a class module,
or on an embedded chart using a class module. I have in the past found
irregularities with MouseUp and MouseDown, but not in this simple exercise.

As a programming note, you really ought to use the built-in argument
names when calling a function like GetChartElement, and don't try to
save a byte or two by using the same variable for one of these arguments
and for a calculated value. It makes it hard for someone else (me) to
figure out what you're doing, and it makes it hard to debug. Suppose for
example the code stops at the CheckDate line; how do you know the values
of Arg1 and Arg2?

Private Sub myChartClass_MouseDown(ByVal Button As Long, ByVal Shift _
As Long, ByVal x As Long, ByVal Y As Long)
Dim kMo As Long, kYr As Long, iPt As Long
Dim ElementID As Long, Arg1 As Long, Arg2 As Long
ActiveChart.GetChartElement x, Y, ElementID, Arg1, Arg2
If ElementID = 3 Then
kMo = (Arg2 - 1) Mod 12 + 1
kYr = Int((Arg2 - 0.9) / 12) + 1960
'Sheets("Sheet1").CheckDate (kMo & "/" & kYr)
End If
End Sub

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/



MikeM wrote:
MouseDown: Each point represents a month (Jan 1960 is the first month).

Private Sub myChartClass_MouseDown(ByVal Button As Long, ByVal Shift As
Long, ByVal x As Long, ByVal Y As Long)
Dim kMo As Long, kYr As Long, iPt As Long
ActiveChart.GetChartElement x, Y, kMo, kYr, iPt
If kMo = 3 Then
kMo = (iPt - 1) Mod 12 + 1
kYr = Int((iPt - 0.9) / 12) + 1960
Sheets("Sheet1").CheckDate (kMo & "/" & kYr)
End If
End Sub

"Jon Peltier" wrote:

What event are you trapping to get X and Y?

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/



MikeM wrote:
I plot a time series and want to record the specific date of a point. Using
the mouse and GetChartElement, I select the point, determine that the
ElementID is 3 and that I have selected the correct SeriesIndex. However,
PointIndex, the fifth argument in GetChartElement, returns as -1, showing
that the entire series has been selected. How can I determine the point
number?

TIA,
Mike