扫一扫分享
这是一个建立在D3顶层的库,旨在改进我们处理大型杂乱图形的方式。它扩展了节点和链接与节点组的概念。当多个节点实际上是同一个节点或属于同一个组时,这很有用。
最简单的方法是ggraph.convert使用有效的D3对象调用:
var graph = {
nodes:[
{id: "Maria West", type: "female"},
{id: "Hazel Santiago", type: "male"},
{id: "Sheldon Roy", type: "male"}
],
links: [
{source: "Maria West", target: "Hazel Santiago", value:100},
{source: "Maria West", target: "Sheldon Roy"}
]
}
converted = ggraph.convert(graph);
初始化:
ggraph.init('container', 25); // Marker timeout
ggraph.draw(converted);
将节点合并到组中:
// Merge selected
ggraph.merge(selection.all());
// Into single group
ggraph.merge(['Maria West', 'Sheldon Roy']);
// Into several groups
ggraph.merge([
['A', 'B'],
['C', 'D']
]);
拆分并删除:
ggraph.split(['Maria West', 'Sheldon Roy']);
ggraph.remove(['Maria West', 'Hazel Santiago']);
手机预览