@ -117,8 +117,8 @@ var data = new vis.DataSet([data] [, options])
</p>
</p>
<p>
<p>
The parameter <code>data</code>code> is optional and can be an Array or
Google DataTable with items.
The parameter <code>data</code> is optional and can be an Array or
<ahref="https://developers.google.com/chart/interactive/docs/reference#DataTable"target="_blank">Google DataTable</a> with items.
</p>
</p>
<p>
<p>
@ -183,7 +183,7 @@ var data = new vis.DataSet([data] [, options])
<tr>
<tr>
<td>add(data [, senderId])</td>
<td>add(data [, senderId])</td>
<td>Number[]</td>
<td>Number[]</td>
<td>Add data to the DataSet. Adding an item will fail when there already is an item with the same id. The function returns an array with the ids of the added items. See section <ahref="#Data_Manipulation">Data Manipulation</a>.</td>
<td>Add one or multiple items to the DataSet. <code>data</code> can be a single item or an array with items. Adding an item will fail when there already is an item with the same id. The function returns an array with the ids of the added items. See section <ahref="#Data_Manipulation">Data Manipulation</a>.</td>
</tr>
</tr>
<tr>
<tr>
@ -216,7 +216,7 @@ var data = new vis.DataSet([data] [, options])
<td>Object | Array | DataTable</td>
<td>Object | Array | DataTable</td>
<td>
<td>
Get a single item, multiple items, or all items from the DataSet.
Get a single item, multiple items, or all items from the DataSet.
Usage examples can be found in section <ahref="#Getting_Data">Getting Data</a>, and the available <code>options</code> are described in section <ahref="#Data_Selection">Data Selection</a>. If parameter <code>data</code> isprovided, items will be appended to this array or table, which is required in case of Google DataTable.
Usage examples can be found in section <ahref="#Getting_Data">Getting Data</a>, and the available <code>options</code> are described in section <ahref="#Data_Selection">Data Selection</a>. If parameter <code>data</code> isprovided, items will be appended to this array or table, which is required in case of Google DataTable.
</td>
</td>
</tr>
</tr>
@ -290,18 +290,17 @@ var data = new vis.DataSet([data] [, options])
</td>
</td>
<td>Number[]</td>
<td>Number[]</td>
<td>
<td>
Remove on ore multiple items by id or by the items themselves. Returns an array with the ids of the removed items. See section <ahref="#Data_Manipulation">Data Manipulation</a>.
Remove one or multiple items by id or by the items themselves. Returns an array with the ids of the removed items. See section <ahref="#Data_Manipulation">Data Manipulation</a>.
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
update(id [, senderId])<br>
update(ids [, senderId])
update(data [, senderId])
</td>
</td>
<td>Number[]</td>
<td>Number[]</td>
<td>
<td>
Update on ore existing items. When an item doesn't exist, it will be created. Returns an array with the ids of the removed items. See section <ahref="#Data_Manipulation">Data Manipulation</a>.
Update on ore multiple existing items. <code>data</code> can be a single item or an array with items. When an item doesn't exist, it will be created. Returns an array with the ids of the removed items. See section <ahref="#Data_Manipulation">Data Manipulation</a>.
</td>
</td>
</tr>
</tr>
@ -448,8 +447,10 @@ function (event, properties, senderId) {
In case of the events <code>add</code>,
In case of the events <code>add</code>,
<code>update</code>, and <code>remove</code>,
<code>update</code>, and <code>remove</code>,
<code>properties</code> is always an object containing a property
<code>properties</code> is always an object containing a property
items, which contains an array with the ids of the affected
items.
<code>items</code>, which contains an array with the ids of the affected
items. The <code>update</code> event has an extra field <code>data</code>
containing the original data of the updated items, i.e. the gives the
changed fields of the changed items.
</td>
</td>
</tr>
</tr>
<tr>
<tr>
@ -861,4 +862,4 @@ var positiveBalance = dataset.get({
@ -316,10 +316,11 @@ When using a DataSet, the network is automatically updating to changes in the Da
<tr>
<tr>
<td>title</td>
<td>title</td>
<td>string | function</td>
<td>string | function | Element</td>
<td>no</td>
<td>no</td>
<td>Title to be displayed when the user hovers over the node.
<td>Title to be displayed when the user hovers over the node.
The title can contain HTML code. If using a function, returning <code>undefined</code>
The title can be an HTML element or a string containing plain text or HTML.
When title is a function, the returned result is displayed as tooltip, and returning <code>undefined</code>
will prevent the tooltip from being displayed.</td>
will prevent the tooltip from being displayed.</td>
</tr>
</tr>
@ -428,7 +429,8 @@ When using a DataSet, the network is automatically updating to changes in the Da
<td>string | function</td>
<td>string | function</td>
<td>no</td>
<td>no</td>
<td>Title to be displayed when the user hovers over the edge.
<td>Title to be displayed when the user hovers over the edge.
The title can contain HTML code. If using a function, returning <code>undefined</code>
The title can be an HTML element or a string containing plain text or HTML.
When title is a function, the returned result is displayed as tooltip, and returning <code>undefined</code>
will prevent the tooltip from being displayed.</td>
will prevent the tooltip from being displayed.</td>
</tr>
</tr>
@ -648,8 +650,8 @@ var options = {
<td>Boolean</td>
<td>Boolean</td>
<td>false</td>
<td>false</td>
<td>
<td>
With the advent of the storePosition() function, the positions of the nodes can be saved after they are stabilized. The smoothCurves require support nodes and those positions are not stored. In order
to speed up the initialization of the network by using storePosition() and loading the nodes with the stored positions, the freezeForStabilization option freezes all nodes that have been supplied with
With the advent of the storePositions() function, the positions of the nodes can be saved after they are stabilized. The smoothCurves require support nodes and those positions are not stored. In order
to speed up the initialization of the network by using storePositions() and loading the nodes with the stored positions, the freezeForStabilization option freezes all nodes that have been supplied with
an x and y position in place during the stabilization. That way only the support nodes for the smooth curves have to stabilize, greatly speeding up the stabilization process with cached positions.
an x and y position in place during the stabilization. That way only the support nodes for the smooth curves have to stabilize, greatly speeding up the stabilization process with cached positions.
</td>
</td>
</tr>
</tr>
@ -2139,6 +2141,12 @@ var options: {
Zooming in is > 1.0, zooming out is <0.Scalecannotbesmallerorequalto0.
Zooming in is > 1.0, zooming out is <0.Scalecannotbesmallerorequalto0.
</td>
</td>
</tr>
</tr>
<tr>
<td>getCenterCoordinates()</td>
<td>Number</td>
<td>Returns the x and y coodinates of the center of the screen (in canvas space).
</td>
</tr>
<tr>
<tr>
<td>getSelection()</td>
<td>getSelection()</td>
<td>Array of ids</td>
<td>Array of ids</td>
@ -2153,7 +2161,7 @@ var options: {
<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/>
<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/>
The options that can be defined are:<br/>
<b><code>scale:Number</code></b><br/> - to zoom to that scale,<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>offset:{x:Number, y:Number}</code></b><br/> - to offset the position from the center of the canvas (in pixels),<br/>
<b><code>locked: boolean</code></b><br/> - if true, the view remains locked on this node until either another focusOnNode, moveTo, releaseNode or drag is done <br/>
<b><code>locked: boolean</code></b><br/> - if true, the view remains locked on this node until either another focusOnNode, moveTo, releaseNode or drag is done <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/>
<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/>
<br/>
@ -2171,13 +2179,6 @@ var options: {
<td>When locked on to a node, this function releases it again. If the view is not locked onto a node due to the focusOnNode locked option, nothing happens.
<td>When locked on to a node, this function releases it again. If the view is not locked onto a node due to the focusOnNode locked option, nothing happens.
</td>
</td>
</tr>
</tr>
<tr>
<td>storePosition()</td>
<td>none</td>
<td>This will put the X and Y positions of all nodes in the dataset. It will also include allowedToMoveX and allowedToMoveY with the correct values.
You can use this to stablize your network once, then save the positions in a database so the next time you load the nodes, stabilization will be near instantaneous.
</td>
</tr>
<tr>
<tr>
<td>DOMtoCanvas(pos)</td>
<td>DOMtoCanvas(pos)</td>
<td>object</td>
<td>object</td>
@ -2267,16 +2268,6 @@ var options: {
edges with id 3 and 5.
edges with id 3 and 5.
</td>
</td>
</tr>
</tr>
<tr>
<td>setSelection(selection)</td>
<td>none</td>
<td>Select nodes [deprecated].
<code>selection</code> is an array with ids of nodes to be selected.
The array <code>selection</code> can contain zero or multiple ids.
Example usage: <code>network.setSelection([3, 5]);</code> will select
nodes with id 3 and 5.
</td>
</tr>
<tr>
<tr>
<td>setSize(width, height)</td>
<td>setSize(width, height)</td>
@ -2285,7 +2276,22 @@ var options: {
containing a new size for the visualization. Size can be provided in pixels
containing a new size for the visualization. Size can be provided in pixels
or in percentages.</td>
or in percentages.</td>
</tr>
</tr>
<tr>
<td>getPositions([ids])</td>
<td>Object</td>
<td>This will return an object of all nodes' positions. Data can be accessed with object[nodeId].x and .y. You can optionally supply an id as string or number or an array of ids. If no id or array of ids have been supplied, all positions are returned.
</td>
</tr>
<tr>
<td>storePositions()</td>
<td>none</td>
<td>When using the vis.DataSet to load your nodes into the network, this method will put the X and Y positions of all nodes into that dataset. It will also include allowedToMoveX and allowedToMoveY with the correct values.
If you're loading your nodes from a database and have this dynamically coupled with the DataSet, you can use this
to stablize your network once, then save the positions in that database through the DataSet so the next time you load the nodes, stabilization will be near instantaneous.
If the nodes are still moving and you're using dynamic smooth edges (which is on by default), you can use the option freezeForStabilization to improve initialization time.
<br><br><i><code>NOTE:</code>This method does not work with the hierarchical layout because the hierarchical algorithm is assigning X Y positions on load, regardless of the ones you supply it with.</i>
<td>Fired every time the network has been stabilized. This event can be used to trigger the .storePosition() function after stabilization. Fired with an object having the following properties:</td>
<td>
<ul>
<li><code>iterations</code>: number of iterations used to stabilize</li>
</ul>
<tr>
<td>startStabilization</td>
<td>Fired once when the network starts the physics calculation. This ends with the stabilized event.
<td>
none
</td>
</tr>
<tr>
<td>stabilized</td>
<td>Fired every time the network has been stabilized. This event can be used to trigger the .storePositions() function after stabilization. Fired with an object having the following properties:</td>
<td>
<ul>
<li><code>iterations</code>: number of iterations used to stabilize</li>
<td>The start date of the item, for example <code>new Date(2010,9,23)</code>.</td>
<td>The start date of the item, for example <code>new Date(2010,9,23)</code>.</td>
</tr>
</tr>
<tr>
<td>style</td>
<td>String</td>
<td>no</td>
<td>
A css text string to apply custom styling for an individual item, for
example <code>"color: red; background-color: pink;"</code>.
</td>
</tr>
<tr>
<tr>
<td>title</td>
<td>title</td>
<td>String</td>
<td>String</td>
@ -259,7 +273,7 @@ var items = [
<code>content</code>, and <code>className</code> (optional).
<code>content</code>, and <code>className</code> (optional).
</p>
</p>
<p>
<p>
Groups can be applied to a timeline using the method <code>setGroups</code>.
Groups can be applied to a timeline using the method <code>setGroups</code> or supplied in the constructor.
A table with groups can be created like:
A table with groups can be created like:
</p>
</p>
@ -268,7 +282,7 @@ var groups = [
{
{
id: 1,
id: 1,
content: 'Group 1'
content: 'Group 1'
// Optional: a field 'className'
// Optional: a field 'className', 'style'
}
}
// more groups...
// more groups...
]);
]);
@ -316,6 +330,15 @@ var groups = [
property <code>group</code> which matches the <code>id</code>
property <code>group</code> which matches the <code>id</code>
of the group.</td>
of the group.</td>
</tr>
</tr>
<tr>
<td>style</td>
<td>String</td>
<td>no</td>
<td>
A css text string to apply custom styling for an individual group label, for
example <code>"color: red; background-color: pink;"</code>.
</td>
</tr>
<tr>
<tr>
<td>title</td>
<td>title</td>
<td>String</td>
<td>String</td>
@ -381,9 +404,10 @@ var options = {
<tr>
<tr>
<td>dataAttributes</td>
<td>dataAttributes</td>
<td>Array[String]</td>
<td>Array[String] | 'all'</td>
<td>false</td>
<td>false</td>
<td>An array of fields optionally defined on the timeline items that will be appended as <code>data-</code> attributes to the DOM element of the items.</td>
<td>An array of fields optionally defined on the timeline items that will be appended as <code>data-</code> attributes to the DOM element of the items.<br>
If value is <code>'all'</code> then each field defined on the timeline item will become a <code>data-</code> attribute.</td>
</tr>
</tr>
@ -455,6 +479,16 @@ var options = {
</td>
</td>
</tr>
</tr>
<tr>
<td>hiddenDates</td>
<td>Object</td>
<td>none</td>
<td>This option allows you to hide specific timespans from the time axis. The dates can be supplied as an object:
<code>{start: '2014-03-21 00:00:00', end: '2014-03-28 00:00:00', [repeat:'daily']}</code> or as an Array of these objects. The repeat argument is optional.
The possible values are (case-sensitive): <code>daily, weekly, monthly, yearly</code>. To hide a weekend, pick any Saturday as start and the following Monday as end
This example demonstrates using templates to format item contents. In this case <ahref="http://handlebarsjs.com">handlebars</a> is used as template engine, but you can just use your favorite template engine or manually craft HTML from the data of an item.