PC Review


Reply
Thread Tools Rate Thread

Chart events - how to select points and not series?

 
 
John Coleman
Guest
Posts: n/a
 
      26th Oct 2004
Greetings,
I have an embedded chart (XY-scatter) for which I have enabled
events. I want to use BeforeDoubleClick to launch a sub when a series
point is double-clicked with the coordinates of the point as
parameters of the sub. The online help says that the parameter Arg2
should be the point index of the selected point of the selected
series. This is exactly what I want, but BeforeDoubleClick seems to
set Arg2 to -1 the majority of the times. This seems to be when the
entire series rather than a point is selected. Does anyone know of a
way that I can avoid this behavior? When I put the mouse over a point
and double click I would like to be able to reliably capture the point
index.

A similar problem involves data labels.

Thank you for your time.

-John Coleman
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      26th Oct 2004
Hi John,

As you say if Arg2 is -1 would indicate the entire series has been selected.
Normally the first time you select a series/point the series is selected,
subsequent click selects a point (if over a point) but there can be a little
delay. Maybe educate your users to wait until only the point is selected
before double clicking.

Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, _
ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
Application.StatusBar = ""
If ElementID = xlSeries And Arg2 > 0 Then
Cancel = True ' avoid dialog ?
Application.StatusBar = ElementID & " : " & Arg1 & " : " & _
Arg2 & " : " & Selection.Parent.Name
End If
End Sub

Regards,
Peter

"John Coleman" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Greetings,
> I have an embedded chart (XY-scatter) for which I have enabled
> events. I want to use BeforeDoubleClick to launch a sub when a series
> point is double-clicked with the coordinates of the point as
> parameters of the sub. The online help says that the parameter Arg2
> should be the point index of the selected point of the selected
> series. This is exactly what I want, but BeforeDoubleClick seems to
> set Arg2 to -1 the majority of the times. This seems to be when the
> entire series rather than a point is selected. Does anyone know of a
> way that I can avoid this behavior? When I put the mouse over a point
> and double click I would like to be able to reliably capture the point
> index.
>
> A similar problem involves data labels.
>
> Thank you for your time.
>
> -John Coleman



 
Reply With Quote
 
Vic Eldridge
Guest
Posts: n/a
 
      27th Oct 2004
John, I think you'll like this one.

Regards,
Vic Eldridge





Dim IDNum As Long
Dim a As Long
Dim b As Long

Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long,
ByVal x As Long, ByVal y As Long)
ActiveChart.GetChartElement x, y, IDNum, a, b
End Sub

Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, ByVal
Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
If IDNum = xlSeries Or IDNum = xlDataLabel Then
MsgBox "ElementID : " & IDNum & vbLf & _
"SeriesIndex : " & a & vbLf & _
"PointIndex : " & b
Cancel = True
End If
End Sub









(E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> Greetings,
> I have an embedded chart (XY-scatter) for which I have enabled
> events. I want to use BeforeDoubleClick to launch a sub when a series
> point is double-clicked with the coordinates of the point as
> parameters of the sub. The online help says that the parameter Arg2
> should be the point index of the selected point of the selected
> series. This is exactly what I want, but BeforeDoubleClick seems to
> set Arg2 to -1 the majority of the times. This seems to be when the
> entire series rather than a point is selected. Does anyone know of a
> way that I can avoid this behavior? When I put the mouse over a point
> and double click I would like to be able to reliably capture the point
> index.
>
> A similar problem involves data labels.
>
> Thank you for your time.
>
> -John Coleman

 
Reply With Quote
 
John Coleman
Guest
Posts: n/a
 
      28th Oct 2004
Vic - this is quite nice and almost does what I want. The problem is
that it still changes the appearance of the other points in the series
(avoiding that was why I was trying to use before double click rather
than the select event in the first place) If I place the statement
Range("H15").select in your code (where H10 is a cell masked by the
chart) then this still appears as a momentary flash involving the
other points which no monkeying with screen-updating seems able to
eliminate. This is really a minor aesthetic issue which I can probably
live with. If it bugs me too much I might get radical and make each
point a separate series as my intended application will have less than
256 points.

Thanks again for the nice code.

-John Coleman

(E-Mail Removed) (Vic Eldridge) wrote in message news:<(E-Mail Removed)>...
> John, I think you'll like this one.
>
> Regards,
> Vic Eldridge
>
>
>
>
>
> Dim IDNum As Long
> Dim a As Long
> Dim b As Long
>
> Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long,
> ByVal x As Long, ByVal y As Long)
> ActiveChart.GetChartElement x, y, IDNum, a, b
> End Sub
>
> Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, ByVal
> Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
> If IDNum = xlSeries Or IDNum = xlDataLabel Then
> MsgBox "ElementID : " & IDNum & vbLf & _
> "SeriesIndex : " & a & vbLf & _
> "PointIndex : " & b
> Cancel = True
> End If
> End Sub
>
>
>
>
>
>
>
>
>
> (E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> > Greetings,
> > I have an embedded chart (XY-scatter) for which I have enabled
> > events. I want to use BeforeDoubleClick to launch a sub when a series
> > point is double-clicked with the coordinates of the point as
> > parameters of the sub. The online help says that the parameter Arg2
> > should be the point index of the selected point of the selected
> > series. This is exactly what I want, but BeforeDoubleClick seems to
> > set Arg2 to -1 the majority of the times. This seems to be when the
> > entire series rather than a point is selected. Does anyone know of a
> > way that I can avoid this behavior? When I put the mouse over a point
> > and double click I would like to be able to reliably capture the point
> > index.
> >
> > A similar problem involves data labels.
> >
> > Thank you for your time.
> >
> > -John Coleman

 
Reply With Quote
 
Vic Eldridge
Guest
Posts: n/a
 
      29th Oct 2004
John,

The Select method is renowned for side effects like that.
So don't use it. I am 99.99% sure there's no valid reason
to be selecting a cell in the middle of your algorithm.


Regards,
Vic Eldridge


(E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> Vic - this is quite nice and almost does what I want. The problem is
> that it still changes the appearance of the other points in the series
> (avoiding that was why I was trying to use before double click rather
> than the select event in the first place) If I place the statement
> Range("H15").select in your code (where H10 is a cell masked by the
> chart) then this still appears as a momentary flash involving the
> other points which no monkeying with screen-updating seems able to
> eliminate. This is really a minor aesthetic issue which I can probably
> live with. If it bugs me too much I might get radical and make each
> point a separate series as my intended application will have less than
> 256 points.
>
> Thanks again for the nice code.
>
> -John Coleman
>
> (E-Mail Removed) (Vic Eldridge) wrote in message news:<(E-Mail Removed)>...
> > John, I think you'll like this one.
> >
> > Regards,
> > Vic Eldridge
> >
> >
> >
> >
> >
> > Dim IDNum As Long
> > Dim a As Long
> > Dim b As Long
> >
> > Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long,
> > ByVal x As Long, ByVal y As Long)
> > ActiveChart.GetChartElement x, y, IDNum, a, b
> > End Sub
> >
> > Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, ByVal
> > Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
> > If IDNum = xlSeries Or IDNum = xlDataLabel Then
> > MsgBox "ElementID : " & IDNum & vbLf & _
> > "SeriesIndex : " & a & vbLf & _
> > "PointIndex : " & b
> > Cancel = True
> > End If
> > End Sub
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > (E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> > > Greetings,
> > > I have an embedded chart (XY-scatter) for which I have enabled
> > > events. I want to use BeforeDoubleClick to launch a sub when a series
> > > point is double-clicked with the coordinates of the point as
> > > parameters of the sub. The online help says that the parameter Arg2
> > > should be the point index of the selected point of the selected
> > > series. This is exactly what I want, but BeforeDoubleClick seems to
> > > set Arg2 to -1 the majority of the times. This seems to be when the
> > > entire series rather than a point is selected. Does anyone know of a
> > > way that I can avoid this behavior? When I put the mouse over a point
> > > and double click I would like to be able to reliably capture the point
> > > index.
> > >
> > > A similar problem involves data labels.
> > >
> > > Thank you for your time.
> > >
> > > -John Coleman

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      29th Oct 2004
> The problem is that it still changes the
> appearance of the other points in the series


In what way, do you mean whole series gets selected instead of single point
/ label, or do you want to end up with nothing on the chart selected.
Depending on what you want to do maybe play around with the extra stuff I've
inserted into Vic's code. Try the Deselect line in different places, MouseUp
perhaps.

Sounds like you are working with a chart object on a worksheet, so I assume
you have got your own "Withevents" class.

'with module variables and MouseDown per Vic's original
Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, _
ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
If IDNum = xlSeries Or IDNum = xlDataLabel Then
If Arg2 = -1 Then
On Error Resume Next
If IDNum = xlSeries Then
Selection.Points(b).Select
Else: Selection(b).Select
'or if label selected select point
'Selection.Parent.Points(b).Select
End If
End If
MsgBox "ElementID : " & IDNum & vbLf & _
"SeriesIndex : " & a & vbLf & _
"PointIndex : " & b
Cancel = True
ActiveChart.Deselect
End If
End Sub

Regards,
Peter

"John Coleman" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Vic - this is quite nice and almost does what I want. The problem is
> that it still changes the appearance of the other points in the series
> (avoiding that was why I was trying to use before double click rather
> than the select event in the first place) If I place the statement
> Range("H15").select in your code (where H10 is a cell masked by the
> chart) then this still appears as a momentary flash involving the
> other points which no monkeying with screen-updating seems able to
> eliminate. This is really a minor aesthetic issue which I can probably
> live with. If it bugs me too much I might get radical and make each
> point a separate series as my intended application will have less than
> 256 points.
>
> Thanks again for the nice code.
>
> -John Coleman
>
> (E-Mail Removed) (Vic Eldridge) wrote in message

news:<(E-Mail Removed)>...
> > John, I think you'll like this one.
> >
> > Regards,
> > Vic Eldridge
> >
> >
> >
> >
> >
> > Dim IDNum As Long
> > Dim a As Long
> > Dim b As Long
> >
> > Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long,
> > ByVal x As Long, ByVal y As Long)
> > ActiveChart.GetChartElement x, y, IDNum, a, b
> > End Sub
> >
> > Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, ByVal
> > Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
> > If IDNum = xlSeries Or IDNum = xlDataLabel Then
> > MsgBox "ElementID : " & IDNum & vbLf & _
> > "SeriesIndex : " & a & vbLf & _
> > "PointIndex : " & b
> > Cancel = True
> > End If
> > End Sub
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > (E-Mail Removed) (John Coleman) wrote in message

news:<(E-Mail Removed)>...
> > > Greetings,
> > > I have an embedded chart (XY-scatter) for which I have enabled
> > > events. I want to use BeforeDoubleClick to launch a sub when a series
> > > point is double-clicked with the coordinates of the point as
> > > parameters of the sub. The online help says that the parameter Arg2
> > > should be the point index of the selected point of the selected
> > > series. This is exactly what I want, but BeforeDoubleClick seems to
> > > set Arg2 to -1 the majority of the times. This seems to be when the
> > > entire series rather than a point is selected. Does anyone know of a
> > > way that I can avoid this behavior? When I put the mouse over a point
> > > and double click I would like to be able to reliably capture the point
> > > index.
> > >
> > > A similar problem involves data labels.
> > >
> > > Thank you for your time.
> > >
> > > -John Coleman



 
Reply With Quote
 
John Coleman
Guest
Posts: n/a
 
      29th Oct 2004
Vic,
My idea of the select is to minimize a side effect. I know of no
other way to de-select the series other than selecting something else.
It would be nice if something like object.deselect were possible.

-John Coleman

(E-Mail Removed) (Vic Eldridge) wrote in message news:<(E-Mail Removed)>...
> John,
>
> The Select method is renowned for side effects like that.
> So don't use it. I am 99.99% sure there's no valid reason
> to be selecting a cell in the middle of your algorithm.
>
>
> Regards,
> Vic Eldridge
>
>
> (E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> > Vic - this is quite nice and almost does what I want. The problem is
> > that it still changes the appearance of the other points in the series
> > (avoiding that was why I was trying to use before double click rather
> > than the select event in the first place) If I place the statement
> > Range("H15").select in your code (where H10 is a cell masked by the
> > chart) then this still appears as a momentary flash involving the
> > other points which no monkeying with screen-updating seems able to
> > eliminate. This is really a minor aesthetic issue which I can probably
> > live with. If it bugs me too much I might get radical and make each
> > point a separate series as my intended application will have less than
> > 256 points.
> >
> > Thanks again for the nice code.
> >
> > -John Coleman
> >
> > (E-Mail Removed) (Vic Eldridge) wrote in message news:<(E-Mail Removed)>...
> > > John, I think you'll like this one.
> > >
> > > Regards,
> > > Vic Eldridge
> > >
> > >
> > >
> > >
> > >
> > > Dim IDNum As Long
> > > Dim a As Long
> > > Dim b As Long
> > >
> > > Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long,
> > > ByVal x As Long, ByVal y As Long)
> > > ActiveChart.GetChartElement x, y, IDNum, a, b
> > > End Sub
> > >
> > > Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, ByVal
> > > Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
> > > If IDNum = xlSeries Or IDNum = xlDataLabel Then
> > > MsgBox "ElementID : " & IDNum & vbLf & _
> > > "SeriesIndex : " & a & vbLf & _
> > > "PointIndex : " & b
> > > Cancel = True
> > > End If
> > > End Sub
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > (E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> > > > Greetings,
> > > > I have an embedded chart (XY-scatter) for which I have enabled
> > > > events. I want to use BeforeDoubleClick to launch a sub when a series
> > > > point is double-clicked with the coordinates of the point as
> > > > parameters of the sub. The online help says that the parameter Arg2
> > > > should be the point index of the selected point of the selected
> > > > series. This is exactly what I want, but BeforeDoubleClick seems to
> > > > set Arg2 to -1 the majority of the times. This seems to be when the
> > > > entire series rather than a point is selected. Does anyone know of a
> > > > way that I can avoid this behavior? When I put the mouse over a point
> > > > and double click I would like to be able to reliably capture the point
> > > > index.
> > > >
> > > > A similar problem involves data labels.
> > > >
> > > > Thank you for your time.
> > > >
> > > > -John Coleman

 
Reply With Quote
 
Vic Eldridge
Guest
Posts: n/a
 
      30th Oct 2004
Hi John,

One or two Sendkeys"{ESC}" might get you where you want to go.
Or as Peter T. mentioned, Activechart.Deselect could be the one.

Or perhaps if you filled us in on your grand plan we could offer
some better advice. What is it that you need to do after clicking
or double-clicking on the chart's data point ?
And what side effect are you trying to minimise ?


Regards,
Vic Eldridge



(E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> Vic,
> My idea of the select is to minimize a side effect. I know of no
> other way to de-select the series other than selecting something else.
> It would be nice if something like object.deselect were possible.
>
> -John Coleman
>
> (E-Mail Removed) (Vic Eldridge) wrote in message news:<(E-Mail Removed)>...
> > John,
> >
> > The Select method is renowned for side effects like that.
> > So don't use it. I am 99.99% sure there's no valid reason
> > to be selecting a cell in the middle of your algorithm.
> >
> >
> > Regards,
> > Vic Eldridge
> >
> >
> > (E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> > > Vic - this is quite nice and almost does what I want. The problem is
> > > that it still changes the appearance of the other points in the series
> > > (avoiding that was why I was trying to use before double click rather
> > > than the select event in the first place) If I place the statement
> > > Range("H15").select in your code (where H10 is a cell masked by the
> > > chart) then this still appears as a momentary flash involving the
> > > other points which no monkeying with screen-updating seems able to
> > > eliminate. This is really a minor aesthetic issue which I can probably
> > > live with. If it bugs me too much I might get radical and make each
> > > point a separate series as my intended application will have less than
> > > 256 points.
> > >
> > > Thanks again for the nice code.
> > >
> > > -John Coleman
> > >
> > > (E-Mail Removed) (Vic Eldridge) wrote in message news:<(E-Mail Removed)>...
> > > > John, I think you'll like this one.
> > > >
> > > > Regards,
> > > > Vic Eldridge
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Dim IDNum As Long
> > > > Dim a As Long
> > > > Dim b As Long
> > > >
> > > > Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long,
> > > > ByVal x As Long, ByVal y As Long)
> > > > ActiveChart.GetChartElement x, y, IDNum, a, b
> > > > End Sub
> > > >
> > > > Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, ByVal
> > > > Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
> > > > If IDNum = xlSeries Or IDNum = xlDataLabel Then
> > > > MsgBox "ElementID : " & IDNum & vbLf & _
> > > > "SeriesIndex : " & a & vbLf & _
> > > > "PointIndex : " & b
> > > > Cancel = True
> > > > End If
> > > > End Sub
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > (E-Mail Removed) (John Coleman) wrote in message news:<(E-Mail Removed)>...
> > > > > Greetings,
> > > > > I have an embedded chart (XY-scatter) for which I have enabled
> > > > > events. I want to use BeforeDoubleClick to launch a sub when a series
> > > > > point is double-clicked with the coordinates of the point as
> > > > > parameters of the sub. The online help says that the parameter Arg2
> > > > > should be the point index of the selected point of the selected
> > > > > series. This is exactly what I want, but BeforeDoubleClick seems to
> > > > > set Arg2 to -1 the majority of the times. This seems to be when the
> > > > > entire series rather than a point is selected. Does anyone know of a
> > > > > way that I can avoid this behavior? When I put the mouse over a point
> > > > > and double click I would like to be able to reliably capture the point
> > > > > index.
> > > > >
> > > > > A similar problem involves data labels.
> > > > >
> > > > > Thank you for your time.
> > > > >
> > > > > -John Coleman

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Chart - Too many data points in Series? Will H. Microsoft Excel Misc 1 16th Dec 2008 07:35 AM
Supressing warning about too many data points in a chart series. Kevin Burton Microsoft Excel Programming 0 3rd Jun 2008 08:10 PM
not able to link chart points from same series =?Utf-8?B?ZF9jYW1wZWxvQGhvdG1haWwuY29t?= Microsoft Excel Charting 1 19th Sep 2006 01:36 PM
Line chart with two series; how to add points to one and not the other? chowgirl Microsoft Excel Charting 0 8th Feb 2006 09:10 PM
Suppress series data-points in chart Don Niall Microsoft Excel Charting 1 6th Jul 2004 08:22 PM


Features
 

Advertising
 

Newsgroups
 


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