I think that transition
is already included in d3 so you don’t have to import another package.
You can also specify the duration of the transition, like this:
tooltip
.transition()
.duration(300);
Regarding your error, try modifying the tooltip positioning on mouseover, because it seems that it’s overlapping with the cursor:
d.pageX + "px"
d.pageY + "px"
Lastly, now that you created the tooltip using d3 you can use it to replace the repetitions in your code:
document.getElementById("tooltip").innerHTML = d.path[0].dataset.date.slice(0,4) + " " + temp + "<br>$" + d.path[0].dataset.gdp + "billion";
document.getElementById("tooltip").style.visibility = "visible";
document.getElementById("tooltip").setAttribute("data-date", d.path[0].dataset.date);
It should go like this:
tooltip
.style('visibility', 'visible')
... and so on