[英]how can i hide the names of ancestors of a node
我是 d3 的新手,我试图用 d3 圆形包装来表示代码模型。 问题是类和接口太多,圆圈的标签难以阅读。 我发现我可能需要隐藏父节点的名称以使事情更清楚,如下所示:
var node = svg.append("g").selectAll("circle")
.data(root.descendants())
.join("circle")
.on("mouseover", d =>{
//hide the label of the parent of the node
var parentNodeLabel = label.filter((e) =>{
return e == d.parent;
})
.style("fill-opacity", "0")
})
}
它按预期工作,但后来我意识到只隐藏父母的名字并没有多大作用,所以现在我试图隐藏所有祖先的名字。 我试过这样:
.on("mouseover", function(d) {
var ancestorNodeLabels = label.filter((e) =>{
return e == d.ancestors().slice(1);
})
.style("fill-opacity", "0")
})
}
但它似乎根本不起作用。 我需要有关如何完成我正在尝试做的事情的提示。
没关系,我只是愚蠢。 我需要检查 e 是否包含在祖先中,不要将其分配给它们。
var ancestorNodeLabels = label.filter((e) =>{
return (d.ancestors().slice(1)).includes(e);
})
.style("fill-opacity", "0")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.