Tree.nodeSize () does not work in the graph of the D3 tree until inc. space between nodes

I wanted to include the space between the nodes vertically, and for this I found that d3 has nodeSize()forward from v3, I find similar questions about the stack and fuddles, and everything works fine there. But in my case, this nodeSize()does not work.

I created a js script that includes my code, but the d3 graph is not exactly the same as mine in my dev server, which includes angular and js calls, but I think this will not affect this problem size. So you can understand what I did and why it nodeSize()doesn’t work

http://jsfiddle.net/9428byn7/

Edited by:

I just find out that nodeSize is also not working in my example http://bl.ocks.org/robschmuecker/7880033

maybe because they use viewHieght and viewWidth, any solution?

+1
source share
1 answer

Well, if you read the document: https://github.com/mbostock/d3/wiki/Tree-Layout#size The staff clearly states: The size property is exceptional with tree.nodeSize; set tree.size sets tree.nodeSize to null.

So, in your update function in the script ( http://jsfiddle.net/9428byn7/ ) control line 473: You wrote:

tree = tree.size([newHeight, viewerWidth]);

Which nullifies your tree.nodeSize according to the document and, as we see it. so instead of executing the above line, do:

tree.nodeSize([200,600]);

The working code is here .

Hope this clarifies your concern!

+3

Source: https://habr.com/ru/post/1677308/


All Articles