2014-02-24 40 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 
);