简体   繁体   English

D3可折叠树:树的可滚动容器

[英]D3 Collapsible tree: Scrollable container for tree

I am using D3 collapsible tree. 我正在使用D3可折叠树。 And its size increase dynamically. 它的大小动态增加。 Can I use a div tag and its class to make it scrollable? 我可以使用div标签及其class来使其可滚动吗? So that when size of tree increase it can be scrollable. 因此,当树的大小增加时,它可以滚动。

http://jsfiddle.net/bSQ8U/159/ is the problem example. http://jsfiddle.net/bSQ8U/159/是问题的例子。 Here when I expand all nodes. 这时我扩展了所有节点。 I will not be able to see full tree. 我将无法看到完整的树。

You can set the height of the svg as it exapnds/collapses. 您可以设置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.

working code here 这里工作代码

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM