Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript D3可折叠树:树的可滚动容器_Javascript_Html_Css_D3.js_Svg - Fatal编程技术网

Javascript 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

我使用的是D3可折叠树。并且它的大小是动态增长的。我可以使用
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.
工作代码


希望这有帮助

也许这个链接很有用。不,画布的大小在这里是固定的。当我们展开所有节点时,它将合并。我想看到完整的树通过滚动,若树的大小增加。可能是这个链接是有用的。不,画布的大小在这里是固定的。当我们展开所有节点时,它将合并。我想看到完整的树滚动,若树的大小增加。