每当我很快地将鼠标悬停在我的元素上时,最终结果都是不可预测的。
在 D3 中是否有一种分层过渡的方法可以防止这个问题,或者它只是你必须处理的事情,比如将元素放置得更远?
我还尝试使用mousemove,以便在元素上连续移动会将其刷新到正确的状态,但元素会随着您的移动而变大(即使它设置为静态数字)并且还会出现很多闪烁。
这是我所有的互动。它是一组排列成圆形的椭圆,带有文本标签和将它们相互连接的路径。(D3 上的捆绑包布局)。在鼠标悬停时,仅显示您悬停的那个以及相关的连接节点和路径。但是,如果我从椭圆到椭圆真的很快,椭圆会改变大小,但路径将是不可预测的。我必须故意将鼠标移出椭圆并从没有听众的区域返回。
nodeGroup.on("mouseenter",function(){
//hides ALL circles
svg.selectAll("ellipse")
.style("opacity","0");
//reshow the one you mouse over
d3.select(this).select("ellipse")
.style("opacity","1")
.transition()
.attr("rx", magnifiedCircle)
.attr("ry", magnifiedCircle/2);
//make text bigger
d3.select(this).select("text")
//.transition()
.style("font-size","25");
//remove all paths (draw relevant ones below)
d3.selectAll("path")
.style("opacity",0);
//name of selected node
var thisID = (d3.select(this).attr("id"));
//draw alls path related to selected node
nodeGroup.selectAll("path")
.style("opacity", function(d,i){
if(d[0] == thisID){
//draw related circles
svg.selectAll("#Circle_" + trimWhitespace(d[1]))
.style("opacity", 1);
svg.select("#Circle_" + trimWhitespace(d[0]))
.style("opacity", 1);
return 1;
}
else
return 0;
});