@ -3,37 +3,39 @@
< head >
< head >
< title > Network | Static smooth curves< / title >
< title > Network | Static smooth curves< / title >
< script type = "text/javascript" src = "../../dist/vis.js" > < / script >
< link href = "../../dist/vis.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../../../ dist/vis.js" > < / script >
< link href = "../../../../ dist/vis.css" rel = "stylesheet" type = "text/css" / >
< style type = "text/css" >
< style type = "text/css" >
#mynetwork {
#mynetwork {
width: 4 00px;
height: 4 00px;
width: 5 00px;
height: 5 00px;
border: 1px solid lightgray;
border: 1px solid lightgray;
}
}
< / style >
< / style >
< script src = "../googleAnalytics.js" > < / script >
< script src = "../../../ googleAnalytics.js" > < / script >
< / head >
< / head >
< body >
< body >
< h2 > Static s mooth curves< / h2 >
< h2 > Smooth curves< / h2 >
< div style = "width:700px; font-size:14px; text-align: justify;" >
< div style = "width:700px; font-size:14px; text-align: justify;" >
All the smooth curves in the examples so far have been using dynamic smooth curves. This means that each curve has a
All the smooth curves in the examples so far have been using dynamic smooth curves. This means that each curve has a
support node which takes part in the physics simulation. For large networks or dense clusters, this may not be the ideal
support node which takes part in the physics simulation. For large networks or dense clusters, this may not be the ideal
solution. To solve this, static smooth curves have been added. The static smooth curves are based only on the positions of the connected
solution. To solve this, static smooth curves have been added. The static smooth curves are based only on the positions of the connected
nodes. There are multiple ways to determine the way this curve is drawn. This example shows the effect of the different
nodes. There are multiple ways to determine the way this curve is drawn. This example shows the effect of the different
types. < br / > < br / >
types. < br / > < br / >
Drag the nodes around each other to see how the smooth curves are drawn for each setting. For animated system, we
Drag the node around to see how the smooth curves are drawn for each setting. For animated system, we
recommend only the continuous mode. In the next example you can see the effect of these methods on a large network. Keep in mind
recommend only the continuous mode. In the next example you can see the effect of these methods on a large network. Keep in mind
that the direction (the from and to) of the curve matters.
that the direction (the from and to) of the curve matters.
< br / > < br / >
< br / > < br / >
When you select the dynamic type, you can see the interaction with the fixed node and the edge, any other type will not interact with other nodes.
< br / > < br / >
< / div >
< / div >
< p >
< p >
Smooth curve type:
Smooth curve type:
< select id = "dropdownID" >
< select id = "dropdownID" onchange = "update();" >
< option value = "continuous" selected = "selected" > continuous< / option >
< option value = "continuous" selected = "selected" > continuous< / option >
< option value = "discrete" > discrete< / option >
< option value = "discrete" > discrete< / option >
< option value = "diagonalCross" > diagonalCross< / option >
< option value = "diagonalCross" > diagonalCross< / option >
@ -42,10 +44,12 @@
< option value = "vertical" > vertical< / option >
< option value = "vertical" > vertical< / option >
< option value = "curvedCW" > curvedCW< / option >
< option value = "curvedCW" > curvedCW< / option >
< option value = "curvedCCW" > curvedCCW< / option >
< option value = "curvedCCW" > curvedCCW< / option >
< option value = "dynamic" > dynamic< / option >
< option value = "none" > none< / option >
< / select >
< / select >
< / p >
< / p >
< p >
< p >
Roundness (0..1): < input type = "range" min = "0" max = "1" value = "0.5" step = "0.05" style = "width:200px" id = "roundnessSlider" > < input id = "roundnessScreen" value = "0.5" > (0.5 is max roundness for continuous, 1.0 for the others)
Roundness (0..1): < input type = "range" min = "0" max = "1" value = "0.5" step = "0.05" style = "width:200px" id = "roundnessSlider" onchange = "update();" > < input id = "roundnessScreen" style = "width:30px;" value = "0.5" > < br > (0.5 is max roundness for continuous, 1.0 for the others)
< / p >
< / p >
< div id = "mynetwork" > < / div >
< div id = "mynetwork" > < / div >
@ -53,20 +57,18 @@
< script type = "text/javascript" >
< script type = "text/javascript" >
var dropdown = document.getElementById("dropdownID");
var dropdown = document.getElementById("dropdownID");
dropdown.onchange = update;
var roundnessSlider = document.getElementById("roundnessSlider");
var roundnessSlider = document.getElementById("roundnessSlider");
roundnessSlider.onchange = update;
var roundnessScreen = document.getElementById("roundnessScreen");
var roundnessScreen = document.getElementById("roundnessScreen");
// create an array with nodes
// create an array with nodes
var nodes = [
var nodes = [
{id: 1, label: 'Node 1'},
{id: 2, label: 'Node 2', x:150, y:130, allowedToMoveX: true, allowedToMoveY: true}
{id: 1, label: 'Fixed node', x:0, y:0, fixed:true},
{id: 2, label: 'Drag me', x:150, y:130, physics:false},
{id: 3, label: 'Obstacle', x:80, y:-80, fixed:true, mass:5}
];
];
// create an array with edges
// create an array with edges
var edges = [
var edges = [
{from: 1, to: 2, style:"arrow "}
{from: 1, to: 2, arrows:'to '}
];
];
// create a network
// create a network
@ -76,17 +78,10 @@
edges: edges
edges: edges
};
};
var options = {
var options = {
physics:{
barnesHut: {
gravitationalConstant:0,
springConstant:0,
centralGravity: 0
}
},
physics:true,
edges: {
edges: {
smooth: {
smooth: {
dynamic: false,
type: '1'
type: 'continuous'
}
}
}
}
};
};
@ -94,16 +89,26 @@
function update() {
function update() {
var type = dropdown.value;
var type = dropdown.value;
var options;
var roundness = parseFloat(roundnessSlider.value);
var roundness = parseFloat(roundnessSlider.value);
roundnessScreen.value = roundness;
roundnessScreen.value = roundness;
var options = {
edges: {
smooth: {
type: type,
roundness: roundness
if (type === 'none') {
options = {
edges: {
smooth: false
}
}
}
};
};
}
else {
options = {
edges: {
smooth: {
type: type,
roundness: roundness
}
}
};
}
network.setOptions(options);
network.setOptions(options);
}
}