简体   繁体   English

顺序图节点d3js

[英]Order graph nodes d3js

I have a database where I maintain an entity Ids in one table while maintaining a source and target entity on other table. 我有一个数据库,在其中一个表中维护一个实体ID,而在另一表中维护一个源和目标实体。

I have generated a json of nodes and links. 我已经生成了节点和链接的json。 and used the following example as a reference (thought it would be enough to only generate the json file): 并使用以下示例作为参考(认为仅生成json文件就足够了):

Force directed graph for D3.js v4 with labelled edges and arrows 具有标记的边缘和箭头的D3.js v4的强制有向图

Same code with my generated data 与我生成的数据相同的代码

The issue is that the graph is messy and I can't infer anything by looking at it. 问题在于该图很乱,我无法通过查看来推断任何内容。 so what I'm trying to do is, since I am familiar with the relations between the entities I would like the nodes to be ordered top down by labels by some certain order. 所以我想做的是,因为我熟悉实体之间的关系,所以我希望节点按标签从上到下的某种顺序排列。 eg siteref -> ro -> ba -> gr -> ca siteref -> 反渗透 -> -> -> CA

Is that achievable at all? 这完全可以实现吗? I have looked around for some other examples but did not find anything that could suit my needs. 我到处寻找其他示例,但没有找到任何适合我需要的示例。

You can add forceY , and optionally pass it a strength . 您可以添加forceY ,还可以选择将其传递给strength In the forceY function you can set to return 0 for siteref , 100 for ro , and so on. 在forceY功能,可以设置返回0 siteref为100 ro ,等等。 Then you can tune in at your needs by playing a little bit with the strength in the links and in the different forces. 然后,您可以通过在链接和不同作用力中发挥一些作用来调整自己的需求。 Here is an updated fiddle so you can take a look at the idea. 这是更新的小提琴,所以您可以看一下这个想法。 Update fiddle 更新小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM