@ -1020,7 +1020,7 @@ All options defined per-node override these global settings.
<p>
Edges can be configured with different length and styling. To configure edges, provide an object named <code>edges</code> in the <code>options</code> for the Network.
Because the length of an edge is a property of the physics simulation, you can change the length of the edge by changing the springLength in your selected physics solver.
To change the edge length of individual edges, you can use the <code>length</code> property in the <ahref="Edges">edge definition</a>.
To change the edge length of individual edges, you can use the <code>length</code> property in the <ahref="#Edges">edge definition</a>.
</p>
<p>
@ -2146,10 +2146,20 @@ var options: {
</td>
</tr>
<tr>
<td>focusOnNode(nodeId, [zoomLevel])</td>
<td>focusOnNode(nodeId, [options])</td>
<td>none</td>
<td>This function will move the view to center on the specified node. An optional zoomLevel can be passed where 1.0 is 100%, between 0.0 and 1.0 is zooming out and > 1.0 is zooming in. Generally, close to 1.0 is sufficient.
If this argument is not passed the view will only move, not zoom.
<td>This function will move the view to center on the specified node. An optional options object can submitted where you can define the animation properties. <br/>
The options that can be defined are:<br/>
<b><code>scale:Number</code></b><br/> - to zoom to that scale,<br/>
<b><code>offset:{x:Number, y:Number}</code></b><br/> - to offset the position from the center of the canvas (in DOM units),<br/>
<b><code>animation: Object || Boolean</code></b><br/> - to define the specifics of the animation. True is animated with default settings, false is not animated.<br/>
<br/>
The animation object can consist of:<br/>
<b><code>duration: Number</code></b><br/> - the duration of the animation in milliseconds,<br/>
<b><code>easingFunction: String</code></b><br/> - the easing function of the animation, available are:<br/>
<td>This function converts canvas coordinates to coordinates on the DOM. Input and output are in the form of {x:xpos,y:ypos}. The DOM values are relative to the network container.
</td>
</tr>
<tr>
<tr>
<td>moveTo(options)</td>
<td>object</td>
<td>This function allows you to programmatically move the view. The options that can be defined are:<br/>
<b><code>position:{x:Number, y:Number}</code></b><br/> - to move to that position (in canvas units), <br/>
<b><code>scale:Number</code></b><br/> - to zoom to that scale,<br/>
<b><code>offset:{x:Number, y:Number}</code></b><br/> - to offset the position from the center of the canvas (in DOM units),<br/>
<b><code>animation: Object || Boolean</code></b><br/> - to define the specifics of the animation.<br/>
<br/>
The animation object can consist of:<br/>
<b><code>duration: Number</code></b><br/> - the duration of the animation in milliseconds,<br/>
<b><code>easingFunction: String</code></b><br/> - the easing function of the animation, available are:<br/>
<i>You will have to define at least a scale or a position. Otherwise, there is nothing to move to.</i>
</td>
</tr>
<tr>
<td>on(event, callback)</td>
<td>none</td>
<td>Create an event listener. The callback function is invoked every time the event is triggered. Avialable events: <code>select</code>. The callback function is invoked as <code>callback(properties)</code>, where <code>properties</code> is an object containing event specific properties. See section <ahref="#Events">Events</a> for more information.</td>
@ -2248,9 +2278,18 @@ var options: {
</tr>
<tr>
<td>zoomExtent()</td>
<td>zoomExtent([options])</td>
<td>none</td>
<td>Scales the network so all the nodes are in center view.</td>
<td>Scales the network so all the nodes are in center view. Optionally you can supply options for animation. These
options can just be a boolean. When true, the zoom is animated, when false there is no animation.
Alternatively, you can supply an object.
<br/><br/> The object can consist of:<br/>
<b><code>duration: Number</code></b><br/> - the duration of the animation in milliseconds,<br/>
<b><code>easingFunction: String</code></b><br/> - the easing function of the animation, available are:<br/>
var offsetx = parseInt(document.getElementById("offsetx").value);
var offsety = parseInt(document.getElementById("offsety").value);
var scale = parseFloat(document.getElementById("scale").value);
var positionx = parseInt(document.getElementById("positionx").value);
var positiony = parseInt(document.getElementById("positiony").value);
var easingFunction = document.getElementById("easingFunction").value;
var options = {
position: {x:positionx,y:positiony},
scale: scale,
offset: {x:offsetx,y:offsety},
animation: true // default duration is 1000ms and default easingFunction is easeInOutQuad.
}
statusUpdateSpan.innerHTML = "Doing Animation.";
finishMessage = "Animation finished."
network.moveTo(options);
}
function doAnimation() {
var offsetx = parseInt(document.getElementById("offsetx").value);
var offsety = parseInt(document.getElementById("offsety").value);
var duration = parseInt(document.getElementById("duration").value);
var scale = parseFloat(document.getElementById("scale").value);
var positionx = parseInt(document.getElementById("positionx").value);
var positiony = parseInt(document.getElementById("positiony").value);
var easingFunction = document.getElementById("easingFunction").value;
var options = {
position: {x:positionx,y:positiony},
scale: scale,
offset: {x:offsetx,y:offsety},
animation: {
duration: duration,
easingFunction: easingFunction
}
}
statusUpdateSpan.innerHTML = "Doing Animation.";
finishMessage = "Animation finished."
network.moveTo(options);
}
function focusRandom() {
var nodeId = Math.floor(Math.random() * 25);
var offsetx = parseInt(document.getElementById("offsetx").value);
var offsety = parseInt(document.getElementById("offsety").value);
var duration = parseInt(document.getElementById("duration").value);
var scale = parseFloat(document.getElementById("scale").value);
var easingFunction = document.getElementById("easingFunction").value;
var options = {
// position: {x:positionx,y:positiony}, // this is not relevant when focusing on nodes
scale: scale,
offset: {x:offsetx,y:offsety},
animation: {
duration: duration,
easingFunction: easingFunction
}
}
statusUpdateSpan.innerHTML = "Focusing on node: " + nodeId;
finishMessage = "Node: " + nodeId + " in focus.";
network.focusOnNode(nodeId, options);
}
var showInterval = false;
var showPhase = 1;
function startShow() {
if (showInterval !== false) {
showInterval = false;
showButton.value = "Start a show!";
network.zoomExtent();
}
else {
showButton.value = "Stop the show!";
var duration = parseInt(document.getElementById("duration").value);
focusRandom();
window.setTimeout(doTheShow, duration);
showInterval = true;
}
}
function doTheShow() {
if (showInterval == true) {
var duration = parseInt(document.getElementById("duration").value);
if (showPhase == 0) {
focusRandom();
showPhase = 1;
}
else {
zoomExtentAnimated();
showPhase = 0;
}
window.setTimeout(doTheShow, duration);
}
}
</script>
</head>
<bodyonload="draw();">
<h2>Camera animations</h2>
<divstyle="width:700px; font-size:14px;">
You can move the view around programmatically using the .moveTo(options) function. The options supplied to this function can
also be (partially) supplied to the .zoomExtent() and .focusOnNode() methods. These are explained in the docs.
<br/><br/>
The buttons below take the fields from the table when they can. For instance, the "Animate with default settings." takes the position, scale and offset while using
the default animation values for duration and easing function. The focusOnNode takes everything except the position and the zoomExtent takes only the duration and easing function.
<br/><br/>
Here you can see a full description of the options you can supply to moveTo:
</div>
<pre>
var moveToOptions = {
position: {x:x, y:x}, // position to animate to (Numbers)
scale: 1.0, // scale to animate to (Number)
offset: {x:x, y:y}, // offset from the center in DOM pixels (Numbers)
animation: { // animation object, can also be Boolean
duration: 1000, // animation duration in milliseconds (Number)
easingFunction: "easeInOutQuad" // Animation easing function, available are: