xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500);
var front = svg.append("g").classed("front", true);
front.append("rect")
.attr("y", 50)
.attr("x", 50)
.attr("width", 200)
.attr("height", 150)
.attr("fill", "lightblue");
front.append("text").text("Test text")
.attr("y", 150)
.attr("x", 100)
;
front.append("polygon")
.attr("points", "75,75 75,125 115,100");
front.append("a")
.attr("href", "#")
.on("click", show)
.append("text").text("[i]")
.attr("x", 232)
.attr("y", 195
).append("title").text("Click here for more info about the KPI");
var bottom = svg.append("g").classed("bottom", true)
.attr("transform", "scale(1, 0.001) translate(0, 200000)");
;
bottom.append("rect")
.attr("y", 50)
.attr("x", 50)
.attr("width", 200)
.attr("height", 150)
.attr("fill", "red");
bottom.append("text").text("Hello there")
.attr("y", 150)
.attr("x", 100)
;
bottom.append("a")
.attr("href", "#")
.on("click", hide)
.append("text").text("[x]")
.attr("x", 230)
.attr("y", 65
);
/*svg.append("rect")
.classed("back", true)
.attr("y", 50)
.attr("x", 50)
.attr("width", 200)
.attr("height", 150)
.attr("fill", "none")
.attr("stroke", "black");*/
function show() {
var t = d3.transition()
.duration(600).ease(d3.easeBounce);
svg.select("g.front")
.transition(t)
.attr("transform", "scale(1,0.001) translate(0, 50000)");
svg.select("g.bottom")
.transition(t)
.attr("transform", "scale(1,1)");
}
function hide() {
var t = d3.transition()
.duration(400).ease(d3.easeBounce);
svg.select("g.front")
.transition(t)
.attr("transform", "scale(1,1)");
svg.select("g.bottom")
.transition(t)
.attr("transform", "scale(1, 0.001) translate(0, 200000)");
}
</script>
</body>
https://d3js.org/d3.v4.min.js