circles = viz.selectAll("circle")
.data(shuffledData)
.join("circle")
.attr("cx", (d, i) => 40 + i * (30 * 2 + padding))
.attr("cy", 250)
.attr("r", 30)
.attr("class", d => d["Country name"])
.attr("stroke", "white")
.attr("stroke-width", 1.5)
.attr("fill", d => colorScale(+d.Perception))
.on("mouseover", function(event, d) {
d3.select(this).attr("stroke", "black").attr("stroke-width", 2.5);
tooltip.style("visibility", "visible")
.html(`Country: ${d["Country name"]}`);
})
.on("mousemove", function(event) {
tooltip.style("top", (event.pageY - 10) + "px").style("left", (event.pageX + 10) + "px");
})
.on("mouseout", function() {
d3.select(this).attr("stroke", "white").attr("stroke-width", 1.5);
tooltip.style("visibility", "hidden");
})
.call(drag);