D3 tree vertical separation

前端 未结 4 524
时光说笑
时光说笑 2020-12-30 08:03

I am using the D3 tree layout, such as this one: http://mbostock.github.com/d3/talk/20111018/tree.html

I have modified it for my needs and am running into an issue.

4条回答
  •  Happy的楠姐
    2020-12-30 08:44

    I know I'm not supposed to respond to other answers, but I don't have enough reputation to add a comment.

    Anyway, I just wanted to update this for people using the latest d3.v3.js file. (I assume this is because of a new version, because the line references in the accepted answer were wrong for me.)

    The d3.layout.tree function that you are editing is found between lines 6236 and 6345. d3_layout_treeVisitAfter starts on line 6318. The hierarchy variable is declared on line 6237. The bit about tree.elementsize still stands - I put it on line 6343.

    Lastly (I assume this was an error): when you create the tree, put the dimensions inside square brackets, like you normally do with "size". So:

    var tree = d3.layout.tree()
             .size(null)
             .elementsize([50, 240]);
    

提交回复
热议问题