在 D3.js 中,似乎在其他对象之前绘制的对象然后使它们变得模糊对鼠标悬停侦听器变得不可见。有解决方法吗?
请参阅此工作示例。
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<script type="text/javascript" src="scripts/d3.v3.js"></script>
</head>
<body>
<div id="viz"></div>
<script type="text/javascript">
d3.select("body").style("background-color", "black");
var sampleSVG = d3.select("#viz")
.append("svg")
.attr("width", 400)
.attr("height", 200);
sampleSVG.append("circle")
.style("fill", "grey")
.style("stroke-width", 2)
.attr("r", 60)
.attr("cx", 150)
.attr("cy", 100)
.on("mouseover", function(){d3.select(this).style("fill", "red");})
.on("mouseout", function(){d3.select(this).style("fill", "grey");});
sampleSVG.append("circle")
.style("stroke", "yellow")
.style("opacity", 0.5)
.style("stroke-width", 2)
.attr("r", 100)
.attr("cx", 250)
.attr("cy", 100)
</script>
</body>
</html>