@ -152,6 +154,122 @@ var data = new vis.DataView(dataset, options)
</li>
</li>
</ul>
</ul>
<h2id="Methods">Methods</h2>
<p>DataView contains the following methods.</p>
<table>
<colgroup>
<colwidth="200">
</colgroup>
<tr>
<th>Method</th>
<th>Return Type</th>
<th>Description</th>
</tr>
<tr>
<td>
get([options] [, data])<br>
get(id [,options] [, data])<br>
get(ids [, options] [, data])
</td>
<td>Object | Array | DataTable</td>
<td>
Get a single item, multiple items, or all items from the DataView.
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> is provided, items will be appended to this array or table, which is required in case of Google DataTable.
</td>
</tr>
<tr>
<td>
getDataSet()
</td>
<td>DataSet</td>
<td>
Get the DataSet to which the DataView is connected.
</td>
</tr>
<tr>
<td>
getIds([options])
</td>
<td>Number[]</td>
<td>
Get ids of all items or of a filtered set of items.
Available <code>options</code> are described in section <ahref="dataset.html#Data_Selection">Data Selection</a>, except that options <code>fields</code> and <code>type</code> are not applicable in case of <code>getIds</code>.
</td>
</tr>
<tr>
<td>off(event, callback)</td>
<td>none</td>
<td>
Unsubscribe from an event, remove an event listener. See section <ahref="#Subscriptions">Subscriptions</a>.
</td>
</tr>
<tr>
<td>on(event, callback)</td>
<td>none</td>
<td>
Subscribe to an event, add an event listener. See section <ahref="#Subscriptions">Subscriptions</a>.
</td>
</tr>
<tr>
<td>refresh()</td>
<td>none</td>
<td>
Refresh the filter results of a DataView. Useful when the filter function contains dynamic properties, like:
<preclass="prettyprint lang-js">var data = new vis.DataSet(...);
var view = new vis.DataView(data, {
filter: function (item) {
return item.value > threshold;
}
});</pre>
In this example, <code>threshold</code> is an external parameter. When the value of <code>threshold</code> changes, the DataView must be notified that the filter results may have changed by calling <code>DataView.refresh()</code>.
</td>
</tr>
<tr>
<td>
setDataSet(data)
</td>
<td>none</td>
<td>
Replace the DataSet of the DataView. Parameter <code>data</code> can be a DataSet or a DataView.
</td>
</tr>
</table>
<h2id="Properties">Properties</h2>
<p>DataView contains the following properties.</p>
<table>
<colgroup>
<colwidth="200">
</colgroup>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>length</td>
<td>Number</td>
<td>The number of items in the DataView.</td>
</tr>
</table>
<h2id="Getting_Data">Getting Data</h2>
<h2id="Getting_Data">Getting Data</h2>
<p>
<p>
@ -165,8 +283,8 @@ var items = view.get();
<p>
<p>
Data of a DataView can be filtered and formatted again, in exactly the
Data of a DataView can be filtered and formatted again, in exactly the
same way as in a DataSet. See sections
same way as in a DataSet. See sections
<ahref="dataset.html#Data_Filtering">Data Filtering</a> and
<ahref="dataset.html#Data_Formatting">Data Formatting</a> for more
<ahref="dataset.html#Data_Manipulation">Data Manipulation</a> and
<ahref="dataset.html#Data_Selection">Data Selection</a> for more
@ -737,6 +737,22 @@ The options colored in green can also be used as options for the groups. All opt
If not provided, the earliest date present in the events is taken as start date.</td>
If not provided, the earliest date present in the events is taken as start date.</td>
</tr>
</tr>
<tr>
<td>timeAxis.scale</td>
<td>string</td>
<td>none</td>
<td>Set a fixed scale for the time axis of the Timeline. Choose from <code>'millisecond'</code>, <code>'second'</code>, <code>'minute'</code>, <code>'hour'</code>, <code>'weekday'</code>, <code>'day'</code>, <code>'month'</code>, <code>'year'</code>.</td>
</tr>
<tr>
<td>timeAxis.step</td>
<td>number</td>
<td>1</td>
<td>
Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
inside an object <code>nodes</code> in the networks options object.</p> All options in green boxes can be defined per-node as well.
inside an object <code>nodes</code> in the networks options object.</p> All options in green boxes can be defined per-node as well.
All options defined per-node override these global settings.
All options defined per-node override these global settings.
<table>
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<tr>
<tdclass="greenField">borderWidth</td>
<tdclass="greenField">borderWidth</td>
<td>Number</td>
<td>Number</td>
@ -861,6 +868,31 @@ All options defined per-node override these global settings.
<td>undefined</td>
<td>undefined</td>
<td>The width of the border of the node when it is selected. If left at undefined, double the borderWidth will be used.</td>
<td>The width of the border of the node when it is selected. If left at undefined, double the borderWidth will be used.</td>
</tr>
</tr>
<tr>
<td>customScalingFunction</td>
<td>Function</td>
<td>Function</td>
<td>This is a function you can override to make the nodes scale the way you want them based on their values. The default function is this: <br>
<preclass="prettyprint lang-js">
function (min,max,total,value) {
if (max == min) {
return 0.5;
}
else {
var scale = 1 / (max - min);
return Math.max(0,(value - min)*scale);
}
};
</pre>
The function receives the minimum value of the set, the maximum value, the total sum of all values and finally the value of the node or edge it works on. It has to return a value between 0 and 1.
The nodes and edges then calculate their size as follows:
<preclass="prettyprint lang-js">
var scale = customScalingFunction(min,max,total,value);
var diff = maxSize - minSize;
mySize = minSize + diff * scale;</pre>
</td>
</tr>
<tr>
<tr>
<tdclass="greenField">color</td>
<tdclass="greenField">color</td>
<td>String | Object</td>
<td>String | Object</td>
@ -927,6 +959,38 @@ All options defined per-node override these global settings.
<td>14</td>
<td>14</td>
<td>Font size in pixels for label in the node.</td>
<td>Font size in pixels for label in the node.</td>
</tr>
</tr>
<tr>
<td>scaleFontWithValue</td>
<td>Boolean</td>
<td>false</td>
<td>When using values, you can let the font scale with the size of the nodes if you enable the this option.</td>
</tr>
<tr>
<td>fontSizeMin</td>
<td>Number</td>
<td>14</td>
<td>When using values, you can let the font scale with the size of the nodes if you enable the scaleFontWithValue option. This is the minimum value of the fontSize.</td>
</tr>
<tr>
<td></td>fontSizeMax</td>
<td>Number</td>
<td>30</td>
<td>When using values, you can let the font scale with the size of the nodes if you enable the scaleFontWithValue option. This is the maximum value of the fontSize.</td>
</tr>
<tr>
<td>fontSizeMaxVisible</td>
<td>Number</td>
<td>30</td>
<td>When using values, you can let the font scale with the size of the nodes if you enable the scaleFontWithValue option. If you have a wide distribution of values and have a large max fontSize,
the text will become huge if you zoom in on it. This option limits the percieved fontSize to avoid this. If you set it to 20, no label will be larger than fontsize 20 (at scale = 1) regardless of the scale.</td>
</tr>
<tr>
<td>fontDrawThreshold</td>
<td>Number</td>
<td>3</td>
<td>When zooming out, the text becomes smaller. This option sets the minimum size of the label before not being drawn. Just like the fontSizeMaxVisible option, this is the relative fontSize (fontSize * scale).
You can combine this with the min and max values to have the labels of influential nodes show earlier when zooming in.</td>
</tr>
<tr>
<tr>
<tdclass="greenField">fontFill</td>
<tdclass="greenField">fontFill</td>
<td>String</td>
<td>String</td>
@ -1197,7 +1261,12 @@ var options = {
<td>Possible values: <code>"line-above", "line-center", "line-below"</code>. The alignment of the label when drawn on the edge.
<td>Possible values: <code>"line-above", "line-center", "line-below"</code>. The alignment of the label when drawn on the edge.
If <code>horizontal</code> it will align the label absolute horizontial.</td>
If <code>horizontal</code> it will align the label absolute horizontial.</td>
</tr>
</tr>
<tr>
<tdclass="greenField">opacity</td>
<td>Number</td>
<td>1.0</td>
<td>Possible values: <code>[0 .. 1]</code>. This opacity value is added on top of the color information. This only happens for the unselected state.</td>
</tr>
<tr>
<tr>
<tdclass="greenField">style</td>
<tdclass="greenField">style</td>
<td>string</td>
<td>string</td>
@ -1727,7 +1796,8 @@ var options = {
radius: 1},
radius: 1},
maxNodeSizeIncrements: 600,
maxNodeSizeIncrements: 600,
activeAreaBoxSize: 100,
activeAreaBoxSize: 100,
clusterLevelDifference: 2
clusterLevelDifference: 2,
clusterByZoom: true
}
}
}
}
// OR to just load the module with default values:
// OR to just load the module with default values:
@ -1870,6 +1940,12 @@ var options = {
If the highest level of your network at any given time is 3, nodes that have not clustered or
If the highest level of your network at any given time is 3, nodes that have not clustered or
have clustered only once will join their neighbour with the lowest cluster level.</td>
have clustered only once will join their neighbour with the lowest cluster level.</td>
</tr>
</tr>
<tr>
<td>clusterByZoom</td>
<td>Boolean</td>
<td>true</td>
<td>You can toggle the clustering by zoom level using this option.</td>
<td>This defines the zoomspeed when using the keyboard navigation.</td>
<td>This defines the zoomspeed when using the keyboard navigation.</td>
</tr>
</tr>
<tr>
<td>bindToWindow</td>
<td>Boolean</td>
<td>true</td>
<td>If this is true, global keyboard events will be used. If it is false, the keyboard events are only used when the network is active. It is activated on mouseOver automatically.</td>
</tr>
</table>
</table>
@ -2202,11 +2285,18 @@ var options = {
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td>getBoundingBox()</td>
<td>getBoundingBox(nodeId)</td>
<td>Object</td>
<td>Object</td>
<td>Returns a bounding box for the node including label in the format: {top:Number,left:Number,right:Number,bottom:Number}. These values are in canvas space.
<td>Returns a bounding box for the node including label in the format: {top:Number,left:Number,right:Number,bottom:Number}. These values are in canvas space.
</td>
</td>
</tr>
</tr>
<tr>
<td>getConnectedNodes(nodeId)</td>
<td>Array</td>
<td>Returns an array with nodeIds of nodes that are connected to this node. Network keeps track of the connected nodes so this function allows you
to quickly get them without iterating over all edges manually. This is a lot faster for cases with many edges.
<td>Calling freezeSimulation(true) immmediately stops the simulation and triggerst the stabilized event. This does not mean that the network
is physically stabilized but the nodes are not moving anymore. To continue the simulation call freezeSimulation(false).
</td>
</tr>
<tr>
<tr>
<td>releaseNode()</td>
<td>releaseNode()</td>
<td>none</td>
<td>none</td>
@ -2322,6 +2419,12 @@ var options = {
nodes with id 3 and 5. The highlisghEdges boolean can be used to automatically select the edges connected to the node.
nodes with id 3 and 5. The highlisghEdges boolean can be used to automatically select the edges connected to the node.
</td>
</td>
</tr>
</tr>
<tr>
<td>getConnectedNodes(nodeId)</td>
<td>Array</td>
<td>Get an array of (unique) nodeIds that are directly connected to this node.
</td>
</tr>
<tr>
<tr>
<td>selectEdges(selection)</td>
<td>selectEdges(selection)</td>
<td>none</td>
<td>none</td>
@ -2341,7 +2444,7 @@ var options = {
or in percentages.</td>
or in percentages.</td>
</tr>
</tr>
<tr>
<tr>
<td>getPositions([ids])</td>
<td>getPositions([nodeIds])</td>
<td>Object</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>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>
</td>
@ -2363,6 +2466,7 @@ var options = {
options can just be a boolean. When true, the zoom is animated, when false there is no animation.
options can just be a boolean. When true, the zoom is animated, when false there is no animation.
Alternatively, you can supply an object.
Alternatively, you can supply an object.
<br/><br/> The object can consist of:<br/>
<br/><br/> The object can consist of:<br/>
<b><code>nodes: [nodeIds]</code></b><br/> - an optional subset of nodes to zoom in on,<br/>
<b><code>duration: Number</code></b><br/> - the duration of the animation in milliseconds,<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/>
<b><code>easingFunction: String</code></b><br/> - the easing function of the animation, available are:<br/>
<code>showMinorLabels</code> are false, no horizontal axis will be
<code>showMinorLabels</code> are false, no horizontal axis will be
visible.</td>
visible.</td>
</tr>
</tr>
<tr>
<tr>
<td>stack</td>
<td>stack</td>
<td>Boolean</td>
<td>Boolean</td>
@ -749,6 +750,16 @@ var options = {
<td>If true (default), items will be stacked on top of each other such that they do not overlap.</td>
<td>If true (default), items will be stacked on top of each other such that they do not overlap.</td>
</tr>
</tr>
<tr>
<td>snap</td>
<td>function | null</td>
<td>function</td>
<td>When moving items on the Timeline, they will be snapped to nice dates like full hours or days, depending on the current scale. The <code>snap</code> function can be replaced with a custom function, or can be set to <code>null</code> to disable snapping. The signature of the snap function is:
The parameter <code>scale</code> can be can be 'millisecond', 'second', 'minute', 'hour', 'weekday, 'day, 'month, or 'year'. The parameter <code>step</code> is a number like 1, 2, 4, 5.
</td>
</tr>
<tr>
<tr>
<td>start</td>
<td>start</td>
<td>Date | Number | String</td>
<td>Date | Number | String</td>
@ -764,6 +775,26 @@ var options = {
<td>A template function used to generate the contents of the items. The function is called by the Timeline with an items data as argument, and must return HTML code as result. When the option template is specified, the items do not need to have a field <code>content</code>. See section <ahref="#Templates">Templates</a> for a detailed explanation.</td>
<td>A template function used to generate the contents of the items. The function is called by the Timeline with an items data as argument, and must return HTML code as result. When the option template is specified, the items do not need to have a field <code>content</code>. See section <ahref="#Templates">Templates</a> for a detailed explanation.</td>
</tr>
</tr>
<tr>
<td>timeAxis.scale</td>
<td>string</td>
<td>none</td>
<td>Set a fixed scale for the time axis of the Timeline. Choose from <code>'millisecond'</code>, <code>'second'</code>, <code>'minute'</code>, <code>'hour'</code>, <code>'weekday'</code>, <code>'day'</code>, <code>'month'</code>, <code>'year'</code>. Example usage:
<preclass="prettyprint lang-js">var options = {
timeAxis: {scale: 'minute', step: 5}
}</pre>
</td>
</tr>
<tr>
<td>timeAxis.step</td>
<td>number</td>
<td>1</td>
<td>
Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
Choose for example 1, 2, 5, or 10.</td>
</tr>
<tr>
<tr>
<td>type</td>
<td>type</td>
<td>String</td>
<td>String</td>
@ -921,7 +952,9 @@ timeline.clear({options: true}); // clear options only
<tr>
<tr>
<td>redraw()</td>
<td>redraw()</td>
<td>none</td>
<td>none</td>
<td>Force a redraw of the Timeline. Can be useful to manually redraw when option autoResize=false.
<td>Force a redraw of the Timeline. The size of all items will be recalculated.
Can be useful to manually redraw when option <code>autoResize=false</code> and the window
has been resized, or when the items CSS has been changed.