tooltip = {
chart
const tooltip =
d3.select('body').append('div')
.attr('class', 'tooltip')
.style('position', 'absolute')
.style('visibility', 'hidden')
d3.selectAll("path")
.on("mouseover", function(e, d){
d3.select(this).transition()
.attr("stroke-width", d=> 1.3 * Math.sqrt(area(d["MP followers"])))
.attr("stroke-opacity", 1)
})
.on("mousemove", function(e, d){
return tooltip.html(`\
<b>Name:</b> ${d.Name}
<b>MP followers:</b> ${d["MP followers"]}
<b>Con followers:</b> ${d["Con followers"]}
<b>Lab followers:</b> ${d["Lab followers"]}
<b>Click to visit ${d.Name}.</b>`)
.style("top", (e.pageY-10)+"px")
.style("left",(e.pageX+20)+"px")
.style("visibility", "visible");
})
.on("mouseout", function(e, d){
d3.select(this).transition()
.attr("stroke-width", d=> Math.sqrt(area(d["MP followers"])))
.attr("stroke-opacity", d=> opacity(d["MP followers"]))
return tooltip.html(``).style("visibility", "hidden");
})
.on("click", function(e, d) {
d3.select(this).transition()
window.open("https://twitter.com/"+d.Name);
})
}