Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Detect selected chart point

I want to detect by code what datapoint in an XY chart is clicked on by the
user, i.e. series collection ID and then data point ID within the series
collection. Additionally, I want to PREVENT the series collection from being
selected as a result of the user click.

What I'm trying to do is to display a XY chart, and when the user selects
any one point, I want to display additional information about that one point.
When the user selects a different point, show the information about that
other point, etc.

I've got a routine that will tell me the X and Y screen coordinates of a
user click, but I'm not looking forward to translating that into chart
coordinates, and then deciphering the data point from the chart coordinates
and I want to know if there is a more direct approach.

Finally, how do I prevent the series collection from being selected as a
result of the click?

Thanks,
-mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Detect selected chart point

Hi Mark,

If you have a typical chart, one chart group, no deleted series, you might
be able to use something simple like this:

Private Sub Chart_Select(ByVal ElementID As Long, _
ByVal Arg1 As Long, ByVal Arg2 As Long)
Dim msg As String

Select Case ElementID
Case xlSeries
msg = "Series " & Arg1
If Arg2 0 Then msg = msg & vbCr & "Point " & Arg2

If Arg1 = 2 Then 'series 2
'deselect series 2
Me.ChartArea.Select
msg = "Don't select series 2"
End If
'Case: 'other items?

End Select
If Len(msg) Then MsgBox msg

End Sub

Above is in a Chart module and assumes your chart is a chart sheet. If a
chart object on a worksheet you would need to create your own "With Events
myChart as excel.chart" Class, which will give you the same events.

Be aware that what you think is say Series 2 is not always necessarily
Seriescollection(2). You may find the old XLM Selection function more useful
to identify Series & Point. Search this ng for "WhichPoint", I think
originally by Stephen Bullen. You can link that into the chart select event.

I don't think you can prevent selection of a particular series but should be
able to select something else, eg ChartArea as in the above example.

Regards,
Peter T


I want to detect by code what datapoint in an XY chart is clicked on by

the
user, i.e. series collection ID and then data point ID within the series
collection. Additionally, I want to PREVENT the series collection from

being
selected as a result of the user click.

What I'm trying to do is to display a XY chart, and when the user selects
any one point, I want to display additional information about that one

point.
When the user selects a different point, show the information about that
other point, etc.

I've got a routine that will tell me the X and Y screen coordinates of a
user click, but I'm not looking forward to translating that into chart
coordinates, and then deciphering the data point from the chart

coordinates
and I want to know if there is a more direct approach.

Finally, how do I prevent the series collection from being selected as a
result of the click?

Thanks,
-mark



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
macro to label last point for selected series only EricBB Excel Discussion (Misc queries) 1 January 22nd 09 10:56 AM
Can I link comments on the chart to a point on the chart? RL Charts and Charting in Excel 1 October 11th 07 10:03 AM
HELP need index of the actual selected point Schlupp Charts and Charting in Excel 4 August 11th 05 06:56 AM
Detect if a selected cell is within a named range CraigB Excel Programming 2 November 25th 04 03:44 PM
chart point value Claude Excel Programming 5 June 5th 04 07:00 PM


All times are GMT +1. The time now is 04:33 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"