Lor*_*a L 3 highlight hyperlink d3.js
所以首先,我的数据格式与下面的 Miserables.json 相同\n https://bl.ocks.org/mbostock/4062045
\n\n我希望能够在单击节点时将连接到节点的链接设为红色。\n因此 psuedo\xe2\x81\xbbcode 如下
\n\nselectAll(.links)\nif links.source=nodeID or links.target=nodeID\nthen links.color=red\n
Run Code Online (Sandbox Code Playgroud)\n\n但我还做不到。我的最终目标是将其与下面的弧图集成\n http://bl.ocks.org/sjengle/5431779
\n你的伪代码是一个好的开始。您可以使用filter
在选择中实现 if 条件。注意,链接的.source
和.target
是由 d3 编辑的,它们不再是节点的 id,而是节点本身:
thisNode = nodeObject; // where nodeObject is the javascript object for the node, it's probably called "d" in your function.
d3.selectAll(".link")
.filter(function(d) {
return (d.source === thisNode) || (d.target === thisNode);
})
.style("stroke", "red")
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3088 次 |
最近记录: |