简体   繁体   English

在d3可折叠树上增加线/节点之间的空间

[英]Increase space between line/nodes on d3 collapsible tree

I'd like to customize my d3 chart collapsible tree 我想自定义d3图表可折叠树

Here is the D3 example if you need a source code : https://bl.ocks.org/mbostock/4339083 如果您需要源代码,这是D3示例: https : //bl.ocks.org/mbostock/4339083

I want to have more space between all the lines/nodes . 我想在所有行/节点之间留出更多空间

<rect><text>MyText in a Rectangle</text></rect> 

How can I achieve this easily using css ? 如何使用CSS轻松实现这一目标?

Best 最好

Its a SVG picture not a regular HTML DOM element. 它是SVG图片,不是常规的HTML DOM元素。 So I am not sure how to use simple CSS to fix it. 所以我不确定如何使用简单的CSS来修复它。

But I found an even simpler solution is to just access the separation property of the d3.layout.tree object that is created . 但是我发现一个更简单的解决方案是仅访问创建的d3.layout.tree对象的split属性。 On line 126 in your codepen example you just change from: 在您的代码笔示例中的第126行,您只需更改:

    .separation(function(a, b) { return (a.parent == b.parent ? 1 : 10) / a.depth; });

to

.separation(function(a, b) { return (a.parent == b.parent ? 1 : 5) / a.depth; });

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

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