【发布时间】:2017-04-24 15:39:00
【问题描述】:
总结
使用下面的示例,我创建了一个数据库驱动的树视图,其中包含信息块而不是圆形节点。
Interactive d3.js tree diagram
请看下面的示例截图:
这个想法是让行从块结束的地方开始。我认为这与以下功能有关:
// Custom projection
var linkProjection = d3.svg.diagonal()
.source(function (d) {
return { "y": d.source.y, "x": d.source.x };
})
.target(function (d) {
return { "y": d.target.y, "x": d.target.x };
})
.projection(function (d) {
return [d.y, d.x];
});
// Enter any new links at the parent's previous position.
link.enter().insert("path", "g")
.attr("class", "link")
.style("fill", "none")
.style("stroke", "#d1d6da")
.style("stroke-width", "1")
.attr("d", function (d) {
var s = { x: source.x0, y: source.y0 };
var t = { x: source.x0, y: source.y0 };
return linkProjection({ source: s, target: t });
});
我尝试将块宽度添加到 y 坐标,但尽管它从正确的位置开始绘制,但它再次在块的开头结束。
有什么建议吗?
【问题讨论】:
-
我猜它在这段代码中的某个地方 var s = { x: source.x0, y: source.y0 }; x 坐标如果您共享您的代码,那么它会有所帮助
标签: javascript d3.js projection