tree.nodeSize()在D3树状图中无法正常工作.节点之间的空间 [英] tree.nodeSize() not working in D3 tree graph to inc. the space between nodes

查看:522
本文介绍了tree.nodeSize()在D3树状图中无法正常工作.节点之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想垂直增加节点之间的空间,为此我发现d3从v3开始具有nodeSize(),我在堆栈和混淆中发现了类似的问题,并且一切正常.但就我而言,此nodeSize()无法正常工作.

I wanted to inc the space between nodes vertically and for that I find out that d3 have nodeSize() from v3 onward , I find out similar questions on stack and fuddles and there everything works fine. But in my case this nodeSize() is not working.

我创建了一个包含我的代码的js小提琴,但是d3图形与我在dev server bec中包含的Angular和js调用并不完全相同,但是我认为这不会影响此大小问题.这样您就可以了解我做了什么以及为什么nodeSize()无法正常工作

I have created a js fiddle which includes my code but d3 graph is not exactly the same as i have in my dev server bec that includes angular and js calls too but I think that will not affect this size problem . So you can get an idea what I did and why nodeSize() is not working

http://jsfiddle.net/9428byn7/

我只是发现在他们的示例中,nodeSize也不起作用 http://bl.ocks.org/robschmuecker/7880033

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

可能是因为他们正在使用viewHieght和viewWidth,任何解决方案吗?

may be bec they are using viewHieght and viewWidth , any solution ?

推荐答案

如果您阅读该文档,则可以: https://github.com/mbostock/d3/wiki/Tree-Layout#size 其状态在文档中明确指出: size属性与tree.nodeSize互斥;设置tree.size将tree.nodeSize设置为null.

Ok if you read the document: https://github.com/mbostock/d3/wiki/Tree-Layout#size Its states clearly in the doc: The size property is exclusive with tree.nodeSize; setting tree.size sets tree.nodeSize to null.

因此在小提琴中的更新功能中( http://jsfiddle.net/9428byn7/)检查第473行: 您已写过:

So in your update function in the fiddle(http://jsfiddle.net/9428byn7/) check line 473: You have written:

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

根据文档和我们所看到的,这将使您的tree.nodeSize无效. 因此,不要执行上述操作,而是执行以下操作:

Which nullifies your tree.nodeSize as per doc and as we are seeing it. so instead of doing the above line instead do:

tree.nodeSize([200,600]);

工作代码此处.

希望这可以澄清您的担忧!

Hope this clarifies your concern!

这篇关于tree.nodeSize()在D3树状图中无法正常工作.节点之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆