2014-02-24 81 views
1

任何人都可以请详细说明它可以用来THETA和案件或情况的意义是什么?D3.JS THETA

其实我想使图形的视觉表现,但它是不是给节点的理想位置。因为它包含太多使图形不清楚的周期。 目前我在d3js中使用强制布局。在这种情况下,请说明theta的使用效果。

此外,如果您有任何其他想法,请大方的通知。

+0

你有没有看一下[文件](https://github.com/mbostock/D3 /维基/强制布局#维基-θ)? Theta本身并不影响图形的布局。 –

+0

您可能会有更多的运气调整电荷和链路强度参数。 – AmeliaBR

+0

但在更改费用和链接强度时需要考虑哪些因素?有什么建议么? –

回答

0

我发现学习和试验力量如何影响图表的最简单方法是制作临时滑块,以便观察变化的力如何实时影响事物。

例如,在HTML我把这个(表格只是格式化它的最快和最肮脏的样子):

<form oninput="chargeOut.value=chargeInput.value"> 
<table style="width:150px"> 
    <tr><td colspan="2">Charge: 
    <output name="chargeOut" for="chargeInput"> </output> 
    </td></tr> 
    <tr><td colspan="2" align="center"> 
    <input type="range" id="chargeInput" name="chargeInput" min="-350" 
     max="-1" value="-60" style="width:100%"> 
    </td></tr> 
</table> 
</form> 

<form oninput="linkStrOut.value=linkStrInput.value"> 
<table style="width:150px"> 
    <tr><td colspan="2">Link Strength: 
    <output name="linkStrOut" for="linkStrInput"> </output> 
    </td></tr> 
    <tr><td colspan="2" align="center"> 
    <input type="range" id="linkStrInput" name="linkStrInput" min="0" 
     max="1" value="0.03" step="0.01" style="width:100%"> 
    </td></tr> 
</table> 
</form> 

,并在脚本中,我把这个:

d3.select("#chargeInput").on("input", function() { 
    force.charge(chargeInput.value).start() 
}) 

d3.select("#linkStrInput").on("input", function() { 
    force.linkStrength(linkStrInput.value).start() 
}) 

然后,您可以对chargeDistance,摩擦等进行相同的操作。完成后,您可以找出您喜欢的设置并将其设置为默认设置。

关于THETA,因为他们上面说不会改变它的外观,但as per the documentation,它可以帮助加快大图。我希望这有帮助。

+0

你能为它提供一个小提琴吗? – vishB

2

这是jsfiddle with sliders基于MaxF的优秀答案和MBostock的规范force layout example

需要注意的是,如果你想D3块实例加载到小提琴,你可以将其替换d3.json(function(error, json)

function load(json) { 
    // same code as d3.json(... 
} 

load({ 
    "nodes":[ 
    {"name":"Myriel","group":1}, 
    {"name":"Napoleon","group":1}, 
    //... copy this from the block 
);