I'm using react-d3-graph
for adding several nodes with and without links.
When I'm adding several nodes without a link, they are all in the top left corner, which means that they are always above each other.
Is there any config I can set to auto spread them on the graph?
Here is an example of that case:
The data:
const data = {
nodes: [
{
id: "node-1",
fx: 100,
fy: 100
},
{
id: "node-2",
fx: 200,
fy: 200
},
{
id: "node-3",
fx: 300,
fy: 300
},
{
id: "node-4",
fx: 300,
fy: 300
}
],
links: [
{
source: "node-1",
target: "node-2"
}
]
};
And you can see the node-1
and node-2
are connected, so they are aligned correctly, but node-3
and node-4
are not connected, so they are overlapping on the top-left point.
Please take a look to this example I created.
Note 1: I used the trick by adding the cyrcle link to the unlinked nodes. While direction arrow is need not to be displayed - it is Ok, otherwise...
Note 2: the Graph should be initiated with the empty object. And receive the real data after small delay.
Note 3: pay attention to the used configuration.