Example of TnT Tooltip showing how different IDs affect the displayed tooltips. Red circles display tooltips with the same ID which is different from the ID of the blue circles. For this reason only one tooltip of each type (red / blue) can be displayed at the same time.
Last active
October 10, 2018 08:48
-
-
Save emepyc/fe6dc27fe84ba26fff13 to your computer and use it in GitHub Desktop.
Tooltip IDs
This file contains 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
<!DOCTYPE html> | |
<head> | |
<script src="http://d3js.org/d3.v5.min.js" charset="utf-8"></script> | |
<link rel="stylesheet" href="http://tntvis.github.io/tnt.tooltip/build/tnt.tooltip.css" type="text/css"/> | |
<script src="http://tntvis.github.io/tnt.tooltip/build/tnt.tooltip.min.js"></script> | |
</head> | |
<body> | |
<div id="container" style="position:relative"></div> | |
<script> | |
var myTooltip = function (data) { | |
var obj = {}; | |
obj.header = "Circle"; | |
obj.rows = []; | |
obj.rows.push({ | |
label : "type", | |
value : data.type | |
}); | |
tooltip.table() | |
.width(200) | |
.id(data.type) | |
.call (this, obj); | |
}; | |
var container = d3.select("#container"); | |
var svg = container | |
.append("svg") | |
.attr("width", 300) | |
.attr("height", 300); | |
svg | |
.append("circle") | |
.datum({type:"red"}) | |
.attr("cx", 150) | |
.attr("cy", 150) | |
.attr("r", 50) | |
.attr("fill", "red") | |
.on("click", myTooltip); | |
svg | |
.append("circle") | |
.datum({type:"blue"}) | |
.attr("cx", 10) | |
.attr("cy", 10) | |
.attr("r", 10) | |
.attr("fill", "blue") | |
.on("click", myTooltip); | |
svg | |
.append("circle") | |
.datum({type:"blue"}) | |
.attr("cx", 220) | |
.attr("cy", 240) | |
.attr("r", 30) | |
.attr("fill", "blue") | |
.on("click", myTooltip); | |
svg | |
.append("circle") | |
.datum({type:"red"}) | |
.attr("cx", 80) | |
.attr("cy", 200) | |
.attr("r", 15) | |
.attr("fill", "red") | |
.on("click", myTooltip); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment