Closed Thread
Results 1 to 9 of 9

Hover labels on scatterplot points

  1. #1
    Registered User
    Join Date
    01-31-2015
    Location
    New York
    MS-Off Ver
    2010
    Posts
    4

    Hover labels on scatterplot points

    Hi Everyone,

    I am hoping someone can point me in the right direction on a challenge I am trying to solve.
    I have data on an xy scatterplot and would like to be able to move by mouse over the points and have a label show up for each point showing the X,Y value of the point and also text from a comment cell. I know excel has these hover labels but i cant seem to find a way to edit them.
    I also need to be able to use slicers to filter the data on the chart, so having the chart on a chart sheet may not work?

    Not sure if this is clear but if anyone has any thoughts or suggestions I would very much appreciate it!

    Thanks!

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Hover labels on scatterplot points

    You can not edit the content of chart hover labels. The information they show is directly related to the underlying chart data, series name/Point/x/y

    You can use code to capture events of the chart and display your own information via a textbox.
    http://peltiertech.com/chart-events-microsoft-excel/
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    01-31-2015
    Location
    New York
    MS-Off Ver
    2010
    Posts
    4

    Re: Hover labels on scatterplot points

    Thanks so much for this Andy! It was quite helpful!

    Can i pick your brain one more time?

    I wrote some code and its doing all i need - except I am trying to place a textbox label next to a point inside the chart. I cant seem to get right the alignment.
    I am not quite understanding how ActiveSheet.Shapes.AddTextbox(1, x, y, 100, 70) works. I understand X and Y are points relative to the top left corner, but what comes out in the chart is relative to the chart I guess and not the chart sheet? Not sure if I explained this correctly. I am very new to vba but amazed at how powerful it is!

    Any thoughts how I can fix this and have my code show a textbox next to the point in the series that i have the mouse over?




    Here is my code for reference - and maybe its useful for someone out there


    Please Login or Register  to view this content.
    Thanks!
    Last edited by rgonzrubio; 02-02-2015 at 11:12 AM.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Hover labels on scatterplot points

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)


    The x and y arguments are mouse coordinates and are on a different scaling to the chart element positional values.
    Simplest thing to do is use the Arg2 value to identify the point and then use it's left/top values to position textbox.

    Please Login or Register  to view this content.
    I have also modified the code so the shape is added once and then hidden or made visible as required.

  5. #5
    Registered User
    Join Date
    01-31-2015
    Location
    New York
    MS-Off Ver
    2010
    Posts
    4

    Re: Hover labels on scatterplot points

    Andy,

    Thanks so much! this worked PERFECT! very generous of you to help :-) Hope to return the favor one day.

    -R
    Ps: thanks for pointing out the rule for pasting code. Ive fixed it and learned it!

  6. #6
    Registered User
    Join Date
    01-31-2015
    Location
    New York
    MS-Off Ver
    2010
    Posts
    4

    Re: Hover labels on scatterplot points

    One last question if you dont mind Andy.
    I am trying to get the dot/point over which the mouse is located to light up red when the mouse is on top and go back to when the mouse is not there

    I added a few lines to the code but dont seem to get it to work:

    It works when I have the mouse over but not when the mouse is off. I tried to add in command after the mouse is not on top of cant get it right. Part if my fault not fully understanding how to tell the dot i just touched to go back to another color when not in there. would love your thoughts!

    Please Login or Register  to view this content.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Hover labels on scatterplot points

    Please Login or Register  to view this content.
    You need to remember the point that was coloured so you can reset the same point. mLastArg2 is used to store the value.

  8. #8
    Registered User
    Join Date
    07-10-2018
    Location
    lx
    MS-Off Ver
    2010
    Posts
    3

    Re: Hover labels on scatterplot points

    Hi to all

    I know this post is long forgotten, but im trying to implement something like this and i cant get your code to work.
    I've copy it to a module, the sheet code and nothing...

    Were do i copy this code??

    Thanks a lot
    J

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,996

    Re: Hover labels on scatterplot points

    Speed72...

    Hi.

    It's a forum rule that you start your own thread, rather than "piggy-backing" on someone else's thread. This helps prevent massive confusion arising - which will happen if it is not clear which question is being answered. So please start your own thread and explain your own problem (make sure that, right from the start, you use a meaningful title (NOT things like "help needed" or "urgent problem"... think of the Google search terms that you would use to find the solution).

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 pictures. So, prepare a SMALL sample sheet (10-20 rows, not thousands!!!). Make sure there is enough data to demonstrate your need. Make sure your desired results are shown, mock them up manually if necessary. Remember to remove ALL confidential information first!!!


    The yellow banner about sample worksheets, at the top of the screen tells you how to post a sheet here on the Forum.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to add labels to a scatterplot
    By SEMMatt in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-31-2014, 01:18 PM
  2. [SOLVED] Scatterplot data points
    By allisonnp36 in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 12-13-2013, 04:31 PM
  3. Mouse hover labels
    By SoMeOnE31619 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2012, 03:33 PM
  4. Label Points on Hover ONLY in Scatter Plot
    By elastica1234 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 08-22-2012, 02:57 PM
  5. Scatterplot Labels
    By thumper300zx in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-12-2009, 01:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1