Skip to content

Instantly share code, notes, and snippets.

@MaximPiessen
Created April 10, 2019 19:24
Show Gist options
  • Save MaximPiessen/c6c894ad11b5d47caeb283a6aa9ed318 to your computer and use it in GitHub Desktop.
Save MaximPiessen/c6c894ad11b5d47caeb283a6aa9ed318 to your computer and use it in GitHub Desktop.
div.tooltip {
position: absolute;
text-align: center;
padding: 4px;
font: 12px sans-serif;
background: white;
border: 0px;
border-radius: 3px;
pointer-events: none;
}
// Define the div for the tooltip
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
node.on("mouseover", function(d) {
div.transition()
.duration(200)
.style("opacity", .9);
div .html(d.name)
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
node.on("mouseout", function(d) {
div.transition()
.duration(500)
.style("opacity", 0);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment