A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Elementary(?) GetChartElement Question



 
 
Thread Tools Display Modes
  #1  
Old September 6th, 2009, 11:34 PM posted to microsoft.public.excel.charting
Mikem
external usenet poster
 
Posts: 63
Default Elementary(?) GetChartElement Question

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
  #2  
Old September 6th, 2009, 11:51 PM posted to microsoft.public.excel.charting
Jon Peltier[_2_]
external usenet poster
 
Posts: 386
Default Elementary(?) GetChartElement Question

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

  #3  
Old September 7th, 2009, 01:21 AM posted to microsoft.public.excel.charting
Mikem
external usenet poster
 
Posts: 63
Default Elementary(?) GetChartElement Question

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


  #4  
Old September 8th, 2009, 12:39 PM posted to microsoft.public.excel.charting
Jon Peltier[_2_]
external usenet poster
 
Posts: 386
Default Elementary(?) GetChartElement Question

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

  #5  
Old September 8th, 2009, 05:18 PM posted to microsoft.public.excel.charting
Mikem
external usenet poster
 
Posts: 63
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


  #6  
Old September 8th, 2009, 05:27 PM posted to microsoft.public.excel.charting
Jon Peltier[_2_]
external usenet poster
 
Posts: 386
Default Elementary(?) GetChartElement Question

Mike -

That bit of information (chart type) would have been helpful. An area
chart doesn't have discrete points to click on, though you can mouse
over the general vicinity of where a marker would go and get the chart tip.

If you *need* the fill of an area chart, you could plot the area chart,
then overlay it with line chart series with the same data. Then bail out
of the event procedure if Arg2 0.

(I didn't say the code I supplied would work any better, just that it
would make your life easier.)

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



MikeM wrote:
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

  #7  
Old September 8th, 2009, 07:34 PM posted to microsoft.public.excel.charting
Mikem
external usenet poster
 
Posts: 63
Default Elementary(?) GetChartElement Question

Thanks, Jon. I didn't realize that the sub didn't work for area plots. I've
reconfigured the plot so that there is only one filled-in (area) time series,
and the points from other time series can be selected.

"Jon Peltier" wrote:

Mike -

That bit of information (chart type) would have been helpful. An area
chart doesn't have discrete points to click on, though you can mouse
over the general vicinity of where a marker would go and get the chart tip.

If you *need* the fill of an area chart, you could plot the area chart,
then overlay it with line chart series with the same data. Then bail out
of the event procedure if Arg2 0.

(I didn't say the code I supplied would work any better, just that it
would make your life easier.)

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



MikeM wrote:
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


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.