我用d3js创建了一个网络图。我有不同半径的圆。圆之间的每一行都有一个指向其源的箭头。如何根据圆的半径适当调整箭头标记?
下面是jsfiddle http://jsfiddle.net/2NJ25/10/中代码的链接
这就是我如何将箭头附加到行中
svg.append("defs").append("marker")
.attr("id", "arrow")
.attr("refX", 10)
.attr("refY", 2.2)
.attr("markerWidth", 10)
.attr("markerHeight", 10)
.attr("orient", "auto")
.append("path")
.attr("d", "M0,0 V4 L5,2 Z10");
发布于 2013-09-22 05:02:15
您可以调整链接。这将调整附加到它的箭头的大小。
var links = svg.append("g").selectAll("line.link")
.data(force.links())
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) {
return (d.target.cRadius) / 5; })
.attr("marker-end", "url(#arrow)");
我注意到你的标记路径有一个错误。下面是我使用的方法:
svg.append("defs").append("marker")
.attr("id", "arrow")
.attr("viewBox", "0 -5 10 10")
.attr("refX", 21)
.attr("refY", 0)
.attr("markerWidth", 5)
.attr("markerHeight", 5)
.attr("orient", "auto")
.append("path")
.attr("d", "M0,-5L10,0L0,5");
完整的代码在这里:
https://stackoverflow.com/questions/18933437
复制相似问题