0

我在 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 文档

在此处输入图像描述

点击Beta应该显示 在此处输入图像描述

4

1 回答 1

1

将创建辅助节点列表的代码注释到居中节点帮助我实现了我想要实现的目标。查看注释行

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
于 2016-07-21T07:47:27.560 回答