gpt4 book ai didi

javascript - d3.js 上传到 bl.ocks.org 时动态高度变化

转载 作者:行者123 更新时间:2023-12-03 07:58:38 25 4
gpt4 key购买 nike

This我的例子是来自example1和示例2(bl.ocks.org/larskotthoff/7022289)。

我的index.html与example2相同,但我想合并example1的 View 框(窗口?)的动态扩展,同时保持所有节点默认折叠。

最佳答案

您可以根据要显示的节点数在每次更新时增加 svg 的高度。

  //the height as per the number of nodes in the display.
var height = Math.max(500, nodes.length * barHeight );

d3.select("svg").transition()
.duration(duration)
.attr("height", height);

工作代码here

希望这有帮助!

关于javascript - d3.js 上传到 bl.ocks.org 时动态高度变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34687139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com