Reputation: 15
For exemple I have a simple network:
var options = {
style = {
hierarchical = {
sortMethod = 'directed'
}
}
}
var nodes = new vis.DataSet([
{id: 1, label: 'Node 1'},
{id: 2, label: 'Node 2'},
{id: 3, label: 'Node 3'},
{id: 4, label: 'Node 4'},
{id: 5, label: 'Node 5'}
]);
var edges = new vis.DataSet([
{from: 1, to: 2},
{from: 2, to: 3},
{from: 4, to: 3},
{from: 5, to: 3}
]);
Is there a way to indicate that I want the node 2 to be rendered between node 4 and 5?
Upvotes: 1
Views: 70
Reputation: 8316
I'm afraid the only way is to set coordinates of the nodes explicitly:
var nodes = new vis.DataSet([
{id: 1, label: 'Node 1', x: 0, y: -100},
{id: 2, label: 'Node 2', x: 0, y: 0},
{id: 3, label: 'Node 3', x: 0, y: 100},
{id: 4, label: 'Node 4', x: 100, y: 0},
{id: 5, label: 'Node 5', x: -100, y: 0}
]);
The point is, physics works only with existing nodes and edges. Still, you can try one of the following tricks:
Upvotes: 1