Reputation: 137
I tried reading the documentation but couldn't find what I was looking for. This is what I want, how can I do it? Thank you.
Upvotes: 1
Views: 1010
Reputation: 29172
You can use the initRedraw
event to calculate and to set the node coordinates for a circular layout:
var radius = 150
network.on('initRedraw', function () {
var ids = data.nodes.getIds()
var d = 2 * Math.PI / ids.length // Angular pitch
ids.forEach(function(id, i) {
var x = radius * Math.cos(d * i)
var y = radius * Math.sin(d * i)
network.moveNode(id, x, y)
})
})
https://jsfiddle.net/L6s6hjwz/
Upvotes: 1