Adding tooltips to Choropleth map

I’ve been having some trouble adding tooltips to my Choropleth map, and would love to have a second eye on my notebook. I’ve been able to plot the map:

But I can’t seem to be able to get the tooltip box to display correctly (currently configured to just print out the words “Insert Text Here” whenever it hovers over a county. I am able to have it hover over correctly (i.e., when the mouse cursor is on top of the map a red box is outlined) but I can’t seem to print out a text box with the words “Insert Text Here”.

Your code seems to be meant for d3v5 or earlier. Starting with d3 v6, you need to change the way you read the pointer position from d3.mouse to d3.pointer:

      .on("mousemove", function(event) {
        tooltip.attr(
          "transform",
          `translate(${d3.pointer(event)})`
        );
      })

see D3 6.0 migration guide / D3 | Observable

1 Like