D3可折叠树:树的可滚动容器
问题描述:
我正在使用D3可折叠树。它的大小会动态增加。我可以使用div
标签及其class
使其可滚动吗?所以当树的大小增加时它可以滚动。D3可折叠树:树的可滚动容器
http://jsfiddle.net/bSQ8U/159/是问题的例子。在这里,当我展开所有节点。我将无法看到完整的树。
答
您可以设置svg在扩展/折叠时的高度。
window.setTimeout(function() {
var max = d3.max(d3.selectAll(".node")[0], function(g) {
return d3.transform(d3.select(g).attr("transform")).translate[1];
});
//set the max of the group
d3.select("svg").attr("height", max + 100)
console.log(max)
}, 800)//execute after 800 milliseconds after the update.
工作代码here
希望这有助于!
+0
G8 Cyril非常感谢你......我一直在寻找它...... –
可能是此链接很有用。 http://bl.ocks.org/CrandellWS/ca7e6626c9e6b1413963 – Gilsha
不,这里画布的大小是固定的。当我们展开所有节点时,它会合并。如果树的大小增加,我想通过滚动查看完整的树。 –