我试图实现this graph,如下所示:
我的图表只有那些黄色节点。显然黄色节点具有随机位置。我怎么能做出这样的立场?
这是我目前的代码:
foreach ($subjects as $key => $subject){
$nodes[] = [ "data" => [ "id" => "$subject->id",
"Strength" => 5,
"selected" => false,
"cytoscape_alias_list" => ["Aarauer Bierdeckel"],
"canonicalName" => "Aarauer Bierdeckel",
"Milk" => "$subject->body",
"Synonym" => "Kuentener",
"Quality" => 290,
"Type" => "Semi-soft",
"SUID" => $subject->id,
"NodeType" => "Cheese",
"name" => "$subject->title",
"Country" => "Switzerland",
"shared_name" => "$subject->title"
],
"position" => ["x"=>$key*2,"y"=>$key*2], // please focus on this line
"selected" => false,
];
}
如您所见,我为节点设置了$key*2
。这是输出:
所有节点彼此相连,看起来并不好。无论如何,有什么想法如何为节点制作一个俗气的坐标数?
注意到如果你对节点关系及其坐标点有任何建议会很棒。我的意思是我可以更改查询并获得与节点相关的任何所需数量。关系。