Thanks very much for your help @twotani . The const tooltip… section helped a lot. I still couldn’t get the mouseenter function to work but eventually settled on this code that worked for me:
Glad to hear your code is working. I was also handling mouseover, but I switched to handling mouseenter. Handling mouseenter seems to result in a more stable behavior of the tooltip. When I was handling mouseover, I noticed that moving mouse very quickly sometimes resulted in the tooltip remaining on the screen. I think using either event is fine (as long as we pass the FCC tests ).
I forgot to mention that you probably want to set
pointer-events: none; /* critical to disable mouse */
for the tooltip attribute. This is my styling for #tooltip in my CSS file
You applied yScale when assigning the y position, but you didn’t use xScale for the x position. Your xScale is based on scaleTime, so the x position of the rect needs to match that. This is how I’m assigning the x position
You need to play around a bit to fit your situation. If you adjust the width and height of svg by adding some padding, that could impact how you assign the x and y values. You will encounter this issue in latter projects too. I played around and made them work, but I now know the importance of defining and applying xScale and yScale properly so everything fits together correctly.