基于强制布局的每个链接可以有不同的链接强度或长度属性吗?
下面是一个示例数据集,其中每个链接的长度和强度将被定义为属性
var dataset = {
nodes: [
{ name: "Adam" },
{ name: "Iris" },
{ name: "Jerry" }
],
edges: [
{ source: 0, target: 1, strength : .1, length: 50 },
{ source: 0, target: 2, strength: 1, length: 100 },
答案 0 :(得分:1)
是的,force.linkStrength
accepts a function。同样适用于linkDistance。您甚至可以看到how it's implemented.
d3.layout.force()
...
.links(dataset.edges)
.linkStrength( function(edge, i) { return edge.strength; } )