使用d3.js对SVG圈子进行分组

时间:2017-08-16 19:54:22

标签: javascript html d3.js svg

我有这些数据:

>>> original = {'a':[], 'b':[]}
>>> extracted = {k:v for (k,v) in original.items() if k == 'a'}
>>> extracted['a'].append(1)  # change one value in extracted in-place
>>> original                  # original also changed
{'a': [1], 'b': []}
>>> extracted
{'a': [1]}

这是我的代码:

[{"node":"A","group":"1","type":"node"},
 {"node":"B","group":"2","type":"node"},
 {"node":"D","group":"1","type":"node"},
 {"node":"C","group":"2","type":"node"},
 {"type":"link","interest":"1","source":"A","target":"B"},
 {"type":"link","interest":"2","source":"A","target":"C"},
 {"type":"link","interest":"10","source":"B","target":"C"},
 {"type":"link","interest":"3","source":"D","target":"B"}]

我想在不同的组中显示4个圆圈(A,B,C,D): 第1组 - (A,D)|第2组 - (B,C)。

分组应该是使用属性“group”自动进行的。

通过创建d3力布局对象

来完成模拟

0 个答案:

没有答案