[英]LINKS IN Collapsible Tree in D3.js
I am new to D3 so I want to figure out some of the following things in this tree layout example( http://bl.ocks.org/mbostock/4339083 ) . 我是D3的新手,所以我想在这个树布局示例中找出以下一些内容( http://bl.ocks.org/mbostock/4339083 )。
Please help me solve these problems as i'm not able to understand the way it has to be done. 请帮我解决这些问题,因为我无法理解必须要做的事情。
Thank you. 谢谢。
For labels, you need to append text
elements to the link paths: 对于标签,您需要将
text
元素附加到链接路径:
link.enter().insert("text", "g")
.attr("x", function(d) { return (d.source.x+d.target.x)/2; })
.attr("y", function(d) { return (d.source.y+d.target.y)/2; })
.text(function(d) { return d.target.name; });
You may want to adjust the label positions. 您可能需要调整标签位置。
To change the width of the link, you need to set the stroke-width
attribute of the path: 要更改链接的宽度,需要设置路径的
stroke-width
属性:
link.enter().insert("path", "g")
.attr("class", "link")
.attr("stroke-width", function(d) { return d.target.size; })
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.