Javascript D3可折叠树:树的可滚动容器
我使用的是D3可折叠树。并且它的大小是动态增长的。我可以使用Javascript D3可折叠树:树的可滚动容器,javascript,html,css,d3.js,svg,Javascript,Html,Css,D3.js,Svg,我使用的是D3可折叠树。并且它的大小是动态增长的。我可以使用div标记及其class使其可滚动吗?所以当树的大小增加时,它可以滚动 这就是问题的例子。在这里,当我展开所有节点时。我将无法看到完整的树。您可以在svg展开/折叠时设置其高度 window.setTimeout(function() { var max = d3.max(d3.selectAll(".node")[0], function(g) { return d3.transform(d3.select(g
div
标记及其class
使其可滚动吗?所以当树的大小增加时,它可以滚动
这就是问题的例子。在这里,当我展开所有节点时。我将无法看到完整的树。您可以在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.
工作代码
希望这有帮助 您可以设置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.
工作代码
希望这有帮助 也许这个链接很有用。不,画布的大小在这里是固定的。当我们展开所有节点时,它将合并。我想看到完整的树通过滚动,若树的大小增加。可能是这个链接是有用的。不,画布的大小在这里是固定的。当我们展开所有节点时,它将合并。我想看到完整的树滚动,若树的大小增加。