Reputation: 747
I have a database where I maintain an entity Ids in one table while maintaining a source and target entity on other table.
I have generated a json of nodes and links. and used the following example as a reference (thought it would be enough to only generate the json file):
Force directed graph for D3.js v4 with labelled edges and arrows
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. e.g siteref ->
ro ->
ba ->
gr ->
ca
Is that achievable at all? I have looked around for some other examples but did not find anything that could suit my needs.
Upvotes: 0
Views: 259
Reputation: 1044
You can add forceY, and optionally pass it a strength
. In the forceY function you can set to return 0 for siteref
, 100 for ro
, and so on. 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
Upvotes: 2