Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 64
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   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 461
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   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 64
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   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 461
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   Report Post  
Posted to microsoft.public.excel.charting
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




  #6   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 461
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   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 64
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Elementary question ozalid Excel Discussion (Misc queries) 8 October 29th 08 03:38 PM
where can I see my question and answer? Yesterday I ask a question IP Excel Discussion (Misc queries) 2 May 10th 08 04:08 PM
Im sure this question is elementary... Wheezl Excel Worksheet Functions 4 May 23rd 06 01:10 AM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM


All times are GMT +1. The time now is 06:38 PM.

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

About Us

"It's about Microsoft Excel"