Created
April 10, 2019 19:24
-
-
Save MaximPiessen/c6c894ad11b5d47caeb283a6aa9ed318 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div.tooltip { | |
position: absolute; | |
text-align: center; | |
padding: 4px; | |
font: 12px sans-serif; | |
background: white; | |
border: 0px; | |
border-radius: 3px; | |
pointer-events: none; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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