如何在 d3plus 环中仅显示主要连接
how to show only primary connection in d3plus rings
我在 d3plus 环周围工作,我只需要显示环中的主要连接。
<!doctype html>
<meta charset="utf-8">
<script src="http://www.d3plus.org/js/d3.js"></script>
<script src="http://www.d3plus.org/js/d3plus.js"></script>
<div id="viz"></div>
<script>
var connections = [ {"source": "alpha", "target": "beta"},
{"source": "alpha", "target": "gamma"},
{"source": "beta", "target": "delta"},
{"source": "beta", "target": "epsilon"},
{"source": "zeta", "target": "gamma"},
{"source": "theta", "target": "gamma"},
{"source": "eta", "target": "gamma"} ]
var visualization = d3plus.viz()
.container("#viz") // container DIV to hold the visualization
.type("rings") // visualization type
.edges(connections) // list of node connections
.focus("alpha") // ID of the initial center node
.draw() // finally, draw the visualization!
选择Gamma
时,应显示Alpha
,Zeta
,Theta
&Eta
。我尝试了 .color
方法,它说 .color(String|Function|Object)
使用 key secondary
接受值 color
。这个表达式怎么写?
请访问 D3 Plus Documentation
点击 Beta
应该显示
评论创建中心节点辅助节点列表的代码帮助我实现了我想要的。查看注释行
a = (angle-(s*children/2)+(s/2))+((s)*i)
d.d3plus.radians = a
d.d3plus.x = vars.width.viz/2 + ((secondaryRing) * Math.cos(a))
d.d3plus.y = vars.height.viz/2 + ((secondaryRing) * Math.sin(a))
//secondaries.push(d) THE LINE I COMMENTED AND GOT IT WORKING
我在 d3plus 环周围工作,我只需要显示环中的主要连接。
<!doctype html>
<meta charset="utf-8">
<script src="http://www.d3plus.org/js/d3.js"></script>
<script src="http://www.d3plus.org/js/d3plus.js"></script>
<div id="viz"></div>
<script>
var connections = [ {"source": "alpha", "target": "beta"},
{"source": "alpha", "target": "gamma"},
{"source": "beta", "target": "delta"},
{"source": "beta", "target": "epsilon"},
{"source": "zeta", "target": "gamma"},
{"source": "theta", "target": "gamma"},
{"source": "eta", "target": "gamma"} ]
var visualization = d3plus.viz()
.container("#viz") // container DIV to hold the visualization
.type("rings") // visualization type
.edges(connections) // list of node connections
.focus("alpha") // ID of the initial center node
.draw() // finally, draw the visualization!
选择Gamma
时,应显示Alpha
,Zeta
,Theta
&Eta
。我尝试了 .color
方法,它说 .color(String|Function|Object)
使用 key secondary
接受值 color
。这个表达式怎么写?
请访问 D3 Plus Documentation
点击 Beta
应该显示
评论创建中心节点辅助节点列表的代码帮助我实现了我想要的。查看注释行
a = (angle-(s*children/2)+(s/2))+((s)*i)
d.d3plus.radians = a
d.d3plus.x = vars.width.viz/2 + ((secondaryRing) * Math.cos(a))
d.d3plus.y = vars.height.viz/2 + ((secondaryRing) * Math.sin(a))
//secondaries.push(d) THE LINE I COMMENTED AND GOT IT WORKING