I'm using the force layout to represent a directed unweighted network. My inspiration comes from the following example: http://bl.ocks.org/mbostock/1153292
My problem is that in my case there much more links between nodes and I have the feeling that giving a fixed linkDistance, which is always the same, is a very big constraint for my layout.
Is it possible to set a dynamic linkDistance
, such that a link grows in length if it's useful to reduce link crossing inside the graph?
Just two steps:
Step1: Add a parameter in main json as follows:
{source: "Microsoft", target: "Amazon", type: "licensing", value: 60}, {source: "Microsoft", target: "HTC", type: "licensing",value: 60}, {source: "Samsung", target: "Apple", type: "suit",value:60},
Step2: Update linkdistance to accept method.
From the documentation:
Note that the link distance is still adjusted as the layout runs. You may also find setting
linkStrength()
useful.