Graph has a menu with navigation controls, which is disabled by default.
Graph has a menu with navigation controls, which is disabled by default.
It can be configured with the following settings.
It can be configured with the following settings.
</p>
</p>
<preclass="prettyprint">
<preclass="prettyprint">
// These variables must be defined in an options object named navigationUI.
// If a variable is not supplied, the default value is used.
// simple use of navigation controls
var options: {
var options: {
navigationUI: {
enabled: false,
iconPath: this._getIconURL() // automatic loading of the default icons
}
navigation: true
}
}
// OR to just load the module with default values:
// advanced use of navigation controls
var options: {
var options: {
navigationUI: true
navigation: {
iconPath: '/path/to/navigation/icons/'
}
}
}
</pre>
</pre>
@ -1318,16 +1310,10 @@ var options: {
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<td>enabled</td>
<td>Boolean</td>
<td>false</td>
<td>On/off switch for the navigation UI elements.</td>
</tr>
<tr>
<tr>
<td>iconPath</td>
<td>iconPath</td>
<td>string</td>
<td>string</td>
<td>[path to vis.js]/UI_icons/</td>
<td>"/img"</td>
<td>The path to the icon images can be defined here. If custom icons are used, they have to have the same filename as the ones originally packaged with vis.js.</td>
<td>The path to the icon images can be defined here. If custom icons are used, they have to have the same filename as the ones originally packaged with vis.js.</td>
</tr>
</tr>
</table>
</table>
@ -1336,21 +1322,24 @@ var options: {
<p>
<p>
The graph can be navigated using shortcut keys.
The graph can be navigated using shortcut keys.
It can be configured with the following user-configurable settings.
It can be configured with the following user-configurable settings.
The default state for the keyboard navigation is <b>off</b>. The predefined keys can be found in the <ahref="../examples/graph/20_UI_example.html">UI example.</a>
The default state for the keyboard navigation is <b>off</b>. The predefined keys can be found in the example <ahref="../examples/graph/20_navigation.html">20_navigation.html</a>.
</p>
</p>
<preclass="prettyprint">
<preclass="prettyprint">
// These variables must be defined in an options object named keyboardNavigation.
// If a variable is not supplied, the default value is used
// simple use of keyboard controls
var options: {
var options: {
keyboardNavigation: {
enabled: false,
speed: {x: 10, y: 10, zoom: 0.02}
}
keyboard: true
}
}
// OR to just load the module with default values:
// advanced configuration for keyboard controls
var options: {
var options: {
keyboardNavigation: true
keyboard: {
speed: {
x: 10,
y: 10,
zoom: 0.02
}
}
}
}
</pre>
</pre>
@ -1362,12 +1351,6 @@ var options: {
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<td>enabled</td>
<td>Boolean</td>
<td>false</td>
<td>On/off switch for the keyboard navigation.</td>
</tr>
<tr>
<tr>
<td>speed.x</td>
<td>speed.x</td>
<td>Number</td>
<td>Number</td>
@ -1401,6 +1384,33 @@ var options: {
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<td>getSelection()</td>
<td>Array of ids</td>
<td>Returns an array with the ids of the selected nodes.
Returns an empty array if no nodes are selected.
The selections are not ordered.
</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>
</tr>
<tr>
<td>off(event, callback)</td>
<td>none</td>
<td>Remove an event listener created before via function <code>on(event, callback)</code>. See section <ahref="#Events">Events</a> for more information.</td>
</tr>
<tr>
<td>redraw()</td>
<td>none</td>
<td>Redraw the graph. Useful when the layout of the webpage changed.</td>
</tr>
<tr>
<tr>
<td>setData(data,[disableStart])</td>
<td>setData(data,[disableStart])</td>
<td>none</td>
<td>none</td>
@ -1420,21 +1430,6 @@ var options: {
</td>
</td>
</tr>
</tr>
<tr>
<td>getSelection()</td>
<td>Array of ids</td>
<td>Returns an array with the ids of the selected nodes.
Returns an empty array if no nodes are selected.
The selections are not ordered.
</td>
</tr>
<tr>
<td>redraw()</td>
<td>none</td>
<td>Redraw the graph. Useful when the layout of the webpage changed.</td>
</tr>
<tr>
<tr>
<td>setSelection(selection)</td>
<td>setSelection(selection)</td>
<td>none</td>
<td>none</td>
@ -1458,7 +1453,7 @@ var options: {
<h2id="Events">Events</h2>
<h2id="Events">Events</h2>
<p>
<p>
Graph fires events after one or multiple nodes are selected.
Graph fires events after one or multiple nodes are selected or deselected.
The event can be catched by creating a listener.
The event can be catched by creating a listener.
</p>
</p>
@ -1467,13 +1462,30 @@ var options: {
</p>
</p>
<preclass="prettyprint lang-js">
<preclass="prettyprint lang-js">
function onSelect() {
alert('selected nodes: ' + graph.getSelection());
graph.on('select', function (properties) {
alert('selected nodes: ' + properties.nodes);
});
</pre>
<p>
A listener can be removed via the function <code>off</code>:
<td>The initial end date for the axis of the timeline.
<td>The initial end date for the axis of the timeline.
If not provided, the latest date present in the items set is taken as
If not provided, the latest date present in the items set is taken as
@ -387,7 +388,7 @@ var options = {
<tr>
<tr>
<td>max</td>
<td>max</td>
<td>Date</td>
<td>Date | Number | String</td>
<td>none</td>
<td>none</td>
<td>Set a maximum Date for the visible range.
<td>Set a maximum Date for the visible range.
It will not be possible to move beyond this maximum.
It will not be possible to move beyond this maximum.
@ -404,7 +405,7 @@ var options = {
<tr>
<tr>
<td>min</td>
<td>min</td>
<td>Date</td>
<td>Date | Number | String</td>
<td>none</td>
<td>none</td>
<td>Set a minimum Date for the visible range.
<td>Set a minimum Date for the visible range.
It will not be possible to move beyond this minimum.
It will not be possible to move beyond this minimum.
@ -482,7 +483,7 @@ var options = {
<tr>
<tr>
<td>start</td>
<td>start</td>
<td>Date</td>
<td>Date | Number | String</td>
<td>none</td>
<td>none</td>
<td>The initial start date for the axis of the timeline.
<td>The initial start date for the axis of the timeline.
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>
@ -544,12 +545,32 @@ var options = {
<td>Retrieve the custom time. Only applicable when the option <code>showCustomTime</code> is true.
<td>Retrieve the custom time. Only applicable when the option <code>showCustomTime</code> is true.
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td>setCustomTime(time)</td>
<td>setCustomTime(time)</td>
<td>none</td>
<td>none</td>
<td>Adjust the custom time bar. Only applicable when the option <code>showCustomTime</code> is true. <code>time</code> is a Date object.
<td>Adjust the custom time bar. Only applicable when the option <code>showCustomTime</code> is true. <code>time</code> is a Date object.
</td>
</td>
</tr>
</tr>
<tr>
<td>getSelection()</td>
<td>ids</td>
<td>Get an array with the ids of the currently selected items.</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>rangechange</code>, <code>rangechanged</code>, <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 for more information</a>.</td>
</tr>
<tr>
<td>off(event, callback)</td>
<td>none</td>
<td>Remove an event listener created before via function <code>on(event, callback)</code>. See section <ahref="#Events">Events for more information</a>.</td>
</tr>
<tr>
<tr>
<td>setGroups(groups)</td>
<td>setGroups(groups)</td>
<td>none</td>
<td>none</td>
@ -560,6 +581,7 @@ var options = {
must correspond with the id of the group.
must correspond with the id of the group.
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td>setItems(items)</td>
<td>setItems(items)</td>
<td>none</td>
<td>none</td>
@ -572,12 +594,107 @@ var options = {
<tr>
<tr>
<td>setOptions(options)</td>
<td>setOptions(options)</td>
<td>none</td>
<td>none</td>
<td>Set or update options. It is possible to change any option
of the timeline at any time. You can for example switch orientation
on the fly.
<td>Set or update options. It is possible to change any option of the timeline at any time. You can for example switch orientation on the fly.
</td>
</tr>
<tr>
<td>setSelection([ids])</td>
<td>none</td>
<td>Select or deselect items. Currently selected items will be unselected.
</td>
</tr>
</table>
<h2id="Events">Events</h2>
<p>
Timeline fires events when changing the visible window by dragging, or when
selecting items.
</p>
<p>
Here an example on how to listen for a <code>select</code> event.
</p>
<preclass="prettyprint lang-js">
timeline.on('select', function (properties) {
alert('selected items: ' + properties.nodes);
});
</pre>
<p>
A listener can be removed via the function <code>off</code>:
</p>
<preclass="prettyprint lang-js">
function onSelect (properties) {
alert('selected items: ' + properties.nodes);
}
// add event listener
timeline.on('select', onSelect);
// do stuff...
// remove event listener
timeline.off('select', onSelect);
</pre>
<p>
The following events are available.
</p>
<table>
<colgroup>
<colstyle="width: 20%;">
<colstyle="width: 40%;">
<colstyle="width: 40%;">
</colgroup>
<tr>
<th>name</th>
<th>Description</th>
<th>Properties</th>
</tr>
<tr>
<td>rangechange</td>
<td>Fired repeatedly when the user is dragging the timeline window.
</td>
<td>
<ul>
<li><code>start</code> (Number): timestamp of the current start of the window.</li>
<li><code>end</code> (Number): timestamp of the current end of the window.</li>
</ul>
</td>
</tr>
<tr>
<td>rangechanged</td>
<td>Fired once after the user has dragging the timeline window.
</td>
<td>
<ul>
<li><code>start</code> (Number): timestamp of the current start of the window.</li>
<li><code>end</code> (Number): timestamp of the current end of the window.</li>
</ul>
</td>
</td>
</tr>
</tr>
<tr>
<td>select</td>
<td>Fired after the user selects or deselects items by tapping or holding them.
Not fired when the method <code>setSelection</code>is executed.
</td>
<td>
<ul>
<li><code>items</code>: an array with the ids of the selected items</li>
<h2>Navigation controls and keyboad navigation</h2>
<divstyle="width: 700px; font-size:14px;">
This example is the same as example 2, except for the navigation controls that has been activated. The navigation controls are described below. <br/><br/>