Tooltip for D3 Bar Graph

I’m working on the first project for the data visualization certification and I can’t figure out how to get the tooltip to show when I mouse over the rect elements. I’m doing it exactly the same way as the tutorial but nothing is showing up. Here’s my GitHub repository with all the code.

You’re adding a title attribute to a rect, which the browser might not render. You could add a title element, but not sure.

https://stackoverflow.com/questions/34420192/svg-rectangle-display-html-title-on-mouseover

The way I did it was to append a div to the body element with a hidden style and show it by adding .on('mouseover', mouseover) to the rect which calls the mouseover function when you go on the rect.

The mouseover function unhides the div and contains any logic write to the html of the div.

I discovered this method here, where it’s explained more clearly in code:https://d3-graph-gallery.com/graph/scatter_tooltip.html

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.