Browse Source

Merge remote-tracking branch 'origin/v4' into v4

flowchartTest
jos 9 years ago
parent
commit
5b76f063ba
7 changed files with 378 additions and 353 deletions
  1. +24
    -66
      dist/vis.js
  2. +1
    -1
      dist/vis.min.css
  3. +1
    -1
      docs/js/toggleTable.js
  4. +303
    -220
      docs/network/new_network.html
  5. +14
    -56
      lib/timeline/DataStep.js
  6. +5
    -9
      lib/timeline/component/DataAxis.js
  7. +30
    -0
      test/networkTest.html

+ 24
- 66
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library. * A dynamic, browser-based visualization library.
* *
* @version 4.0.0-SNAPSHOT * @version 4.0.0-SNAPSHOT
* @date 2015-05-06
* @date 2015-05-07
* *
* @license * @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com * Copyright (C) 2011-2014 Almende B.V, http://almende.com
@ -7491,9 +7491,9 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {Date} [end] The end date * @param {Date} [end] The end date
* @param {Number} [minimumStep] Optional. Minimum step size in milliseconds * @param {Number} [minimumStep] Optional. Minimum step size in milliseconds
*/ */
"use strict";
'use strict';
function DataStep(start, end, minimumStep, containerHeight, customRange, alignZeros) {
function DataStep(start, end, minimumStep, containerHeight, customRange, formattingFunction, alignZeros) {
// variables // variables
this.current = 0; this.current = 0;
@ -7501,6 +7501,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.stepIndex = 0; this.stepIndex = 0;
this.step = 1; this.step = 1;
this.scale = 1; this.scale = 1;
this.formattingFunction = formattingFunction;
this.marginStart; this.marginStart;
this.marginEnd; this.marginEnd;
@ -7647,62 +7648,21 @@ return /******/ (function(modules) { // webpackBootstrap
* Get the current datetime * Get the current datetime
* @return {String} current The current date * @return {String} current The current date
*/ */
DataStep.prototype.getCurrent = function (decimals) {
DataStep.prototype.getCurrent = function () {
// prevent round-off errors when close to zero // prevent round-off errors when close to zero
var current = Math.abs(this.current) < this.step / 2 ? 0 : this.current; var current = Math.abs(this.current) < this.step / 2 ? 0 : this.current;
var toPrecision = "" + Number(current).toPrecision(5);
// If decimals is specified, then limit or extend the string as required
if (decimals !== undefined && !isNaN(Number(decimals))) {
// If string includes exponent, then we need to add it to the end
var exp = "";
var index = toPrecision.indexOf("e");
if (index != -1) {
// Get the exponent
exp = toPrecision.slice(index);
// Remove the exponent in case we need to zero-extend
toPrecision = toPrecision.slice(0, index);
}
index = Math.max(toPrecision.indexOf(","), toPrecision.indexOf("."));
if (index === -1) {
// No decimal found - if we want decimals, then we need to add it
if (decimals !== 0) {
toPrecision += ".";
}
// Calculate how long the string should be
index = toPrecision.length + decimals;
} else if (decimals !== 0) {
// Calculate how long the string should be - accounting for the decimal place
index += decimals + 1;
}
if (index > toPrecision.length) {
// We need to add zeros!
for (var cnt = index - toPrecision.length; cnt > 0; cnt--) {
toPrecision += "0";
}
} else {
// we need to remove characters
toPrecision = toPrecision.slice(0, index);
}
// Add the exponent if there is one
toPrecision += exp;
} else {
if (toPrecision.indexOf(",") != -1 || toPrecision.indexOf(".") != -1) {
// If no decimal is specified, and there are decimal places, remove trailing zeros
for (var i = toPrecision.length - 1; i > 0; i--) {
if (toPrecision[i] === "0") {
toPrecision = toPrecision.slice(0, i);
} else if (toPrecision[i] === "." || toPrecision[i] === ",") {
toPrecision = toPrecision.slice(0, i);
break;
} else {
break;
}
}
}
var returnValue = current.toPrecision(5);
if (typeof this.formattingFunction === 'function') {
returnValue = this.formattingFunction(current);
} }
return toPrecision;
if (typeof returnValue === 'number') {
return '' + returnValue;
} else if (typeof returnValue === 'string') {
return returnValue;
} else {
return current.toPrecision(5);
}
}; };
/** /**
@ -10927,12 +10887,16 @@ return /******/ (function(modules) { // webpackBootstrap
alignZeros: true, alignZeros: true,
left: { left: {
range: { min: undefined, max: undefined }, range: { min: undefined, max: undefined },
format: { decimals: undefined },
format: function format(value) {
return '' + value.toPrecision(5);
},
title: { text: undefined, style: undefined } title: { text: undefined, style: undefined }
}, },
right: { right: {
range: { min: undefined, max: undefined }, range: { min: undefined, max: undefined },
format: { decimals: undefined },
format: function format(value) {
return '' + value.toPrecision(5);
},
title: { text: undefined, style: undefined } title: { text: undefined, style: undefined }
} }
}; };
@ -11250,7 +11214,7 @@ return /******/ (function(modules) { // webpackBootstrap
rangeEnd = this.range.end; rangeEnd = this.range.end;
} }
this.step = step = new DataStep(rangeStart, rangeEnd, minimumStep, this.dom.frame.offsetHeight, this.options[this.options.orientation].range, this.master === false && this.options.alignZeros // does the step have to align zeros? only if not master and the options is on
this.step = step = new DataStep(rangeStart, rangeEnd, minimumStep, this.dom.frame.offsetHeight, this.options[this.options.orientation].range, this.options[this.options.orientation].format, this.master === false && this.options.alignZeros // does the step have to align zeros? only if not master and the options is on
); );
// the slave axis needs to use the same horizontal lines as the master axis. // the slave axis needs to use the same horizontal lines as the master axis.
@ -11269,12 +11233,6 @@ return /******/ (function(modules) { // webpackBootstrap
// value at the bottom of the SVG // value at the bottom of the SVG
this.valueAtBottom = step.marginEnd; this.valueAtBottom = step.marginEnd;
// Get the number of decimal places
var decimals;
if (this.options[orientation].format !== undefined) {
decimals = this.options[orientation].format.decimals;
}
this.maxLabelSize = 0; this.maxLabelSize = 0;
var y = 0; // init value var y = 0; // init value
var stepIndex = 0; // init value var stepIndex = 0; // init value
@ -11285,12 +11243,12 @@ return /******/ (function(modules) { // webpackBootstrap
if (stepIndex > 0 && stepIndex !== this.amountOfSteps) { if (stepIndex > 0 && stepIndex !== this.amountOfSteps) {
if (this.options['showMinorLabels'] && isMajor === false || this.master === false && this.options['showMinorLabels'] === true) { if (this.options['showMinorLabels'] && isMajor === false || this.master === false && this.options['showMinorLabels'] === true) {
this._redrawLabel(y - 2, step.getCurrent(decimals), orientation, 'vis-y-axis vis-minor', this.props.minorCharHeight);
this._redrawLabel(y - 2, step.getCurrent(), orientation, 'vis-y-axis vis-minor', this.props.minorCharHeight);
} }
if (isMajor && this.options['showMajorLabels'] && this.master === true || this.options['showMinorLabels'] === false && this.master === false && isMajor === true) { if (isMajor && this.options['showMajorLabels'] && this.master === true || this.options['showMinorLabels'] === false && this.master === false && isMajor === true) {
if (y >= 0) { if (y >= 0) {
this._redrawLabel(y - 2, step.getCurrent(decimals), orientation, 'vis-y-axis vis-major', this.props.majorCharHeight);
this._redrawLabel(y - 2, step.getCurrent(), orientation, 'vis-y-axis vis-major', this.props.majorCharHeight);
} }
this._redrawLine(y, orientation, 'vis-grid vis-horizontal vis-major', this.options.majorLinesOffset, this.props.majorLineWidth); this._redrawLine(y, orientation, 'vis-grid vis-horizontal vis-major', this.options.majorLinesOffset, this.props.majorLineWidth);
} else { } else {

+ 1
- 1
dist/vis.min.css
File diff suppressed because it is too large
View File


+ 1
- 1
docs/js/toggleTable.js View File

@ -47,7 +47,7 @@ function toggleTable(tableId, parent, clickedRow) {
} }
else { else {
spans = document.getElementsByClassName('right-caret') spans = document.getElementsByClassName('right-caret')
clickedRow.className = clickedRow.className.replace(' collapsible','');
clickedRow.className = clickedRow.className.replace(' collapsible','').replace('collapsible','');;
} }
for (var i = 0; i < spans.length; i++) { for (var i = 0; i < spans.length; i++) {

+ 303
- 220
docs/network/new_network.html View File

@ -7,7 +7,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content=""> <meta name="description" content="">
<meta name="author" content=""> <meta name="author" content="">
<link rel="icon" HREF="favicon.ico">
<title>vis.js - A dynamic, browser based visualization library.</title> <title>vis.js - A dynamic, browser based visualization library.</title>
<!-- Bootstrap core CSS --> <!-- Bootstrap core CSS -->
@ -51,7 +50,18 @@
} }
tr.subHeader td { tr.subHeader td {
padding-top: 40px;
padding-top: 30px;
}
td.mid {
width: 150px;
background-color: #ffffff;
border: 1px solid #dddddd;
}
tr.visible td {
padding: 10px;
} }
</style> </style>
@ -75,7 +85,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
<a class="navbar-brand hidden-sm" href="http://www.visjs.org/index.html">vis.js</a>
</div> </div>
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
@ -241,216 +251,258 @@ network.setOptions(options);
<h3>All Methods</h3> <h3>All Methods</h3>
<p>This is a list of all the methods in the public API. They have been grouped by category, which correspond to the <p>This is a list of all the methods in the public API. They have been grouped by category, which correspond to the
modules listed above. They are initially collapsed and colored alternatively.</p>
<table class="moduleTable" id="moduleTable">
<tr class="header">
<td class="methodName">name</td>
<td>returns</td>
<td>description</td>
modules listed above.</p>
<table class="moduleTable" id="methodTable">
<tr class="subHeader">
<td colspan="2">Global methods for the network.</td>
</tr> </tr>
<tr class="subHeader evenRow toggle collapsible" onclick="toggleTable('moduleTable','global', this);">
<td colspan="3"><span parent="color" class="right-caret"></span> Global methods for the network.</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','destroy', this);">
<td colspan="2"><span parent="destroy" class="right-caret"></span> destroy()</td>
</tr> </tr>
<tr class="evenRow hidden" parent="global">
<td>destroy()</td>
<td class="mid">none</td>
<tr class="hidden" parent="destroy">
<td class="mid">Returns: none</td>
<td>Remove the network from the DOM and remove all Hammer bindings and references.</td> <td>Remove the network from the DOM and remove all Hammer bindings and references.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="global">
<td>setData({<br><code><i>nodes: vis DataSet/Array</i></code>,<br><code><i>edges: vis
DataSet/Arary</i></code><br>})
<tr class="collapsible toggle" onclick="toggleTable('methodTable','setData', this);">
<td colspan="2"><span parent="setData" class="right-caret"></span> setData({<code><i>nodes: vis
DataSet/Array</i></code>,<code><i>edges: vis
DataSet/Array</i></code>})
</td> </td>
<td class="mid">none</td>
</tr>
<tr class="hidden" parent="setData">
<td class="mid">Returns: none</td>
<td>Override all the data in the network. If stabilization is enabled in the <a href="physics.html">physics <td>Override all the data in the network. If stabilization is enabled in the <a href="physics.html">physics
module</a>, the network will stabilize again. This method is also performed when first initializing the module</a>, the network will stabilize again. This method is also performed when first initializing the
network. network.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="global">
<td>setOptions(<code>Object options</code>)</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','setOptions', this);">
<td colspan="2"><span parent="setOptions" class="right-caret"></span> setOptions(<code>Object options</code>)
</td>
</tr>
<tr class="hidden" parent="setOptions">
<td class="mid">Returns: none</td>
<td>Set the options. All available options can be found in the modules above. Each module requires it's own <td>Set the options. All available options can be found in the modules above. Each module requires it's own
container with the module name to contain its options. container with the module name to contain its options.
</td> </td>
</tr> </tr>
<tr class="subHeader oddRow toggle collapsible" onclick="toggleTable('moduleTable','canvas', this);">
<td colspan="3"><span parent="color" class="right-caret"></span> Methods related to the canvas.</td>
<tr class="subHeader">
<td colspan="2">Methods related to the canvas.</td>
</tr> </tr>
<tr class="oddRow hidden" parent="canvas">
<td>canvasToDOM({<br>&nbsp;&nbsp;&nbsp;<code><i>x: Number</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>y:
Number</i></code><br>})
<tr class="collapsible toggle" onclick="toggleTable('methodTable','canvasToDOM', this);">
<td colspan="2"><span parent="canvasToDOM" class="right-caret"></span> canvasToDOM({<code><i>x:
Number</i></code>,<code><i>y:
Number</i></code>})
</td> </td>
<td class="mid">Object</td>
</tr>
<tr class="hidden" parent="canvasToDOM">
<td class="mid">Returns: Object</td>
<td>This function converts canvas coordinates to coordinates on the DOM. Input and output are in the form of <td>This function converts canvas coordinates to coordinates on the DOM. Input and output are in the form of
<code>{x:Number,y:Number}</code>. The DOM values are relative to the network container. <code>{x:Number,y:Number}</code>. The DOM values are relative to the network container.
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="canvas">
<td>DOMtoCanvas({<br>&nbsp;&nbsp;&nbsp;<code><i>x: Number</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>y:
Number</i></code><br>})
<tr class="collapsible toggle" onclick="toggleTable('methodTable','DOMtoCanvas', this);">
<td colspan="2"><span parent="DOMtoCanvas" class="right-caret"></span> DOMtoCanvas({<code><i>x:
Number</i></code>,<code><i>y:
Number</i></code>})
</td> </td>
<td class="mid">Object</td>
</tr>
<tr class="hidden" parent="DOMtoCanvas">
<td class="mid">Returns: Object</td>
<td>This function converts DOM coordinates to coordinates on the canvas. Input and output are in the form of <td>This function converts DOM coordinates to coordinates on the canvas. Input and output are in the form of
<code>{x:Number,y:Number}</code>. The DOM values are relative to the network container. <code>{x:Number,y:Number}</code>. The DOM values are relative to the network container.
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="canvas">
<td>redraw()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','redraw', this);">
<td colspan="2"><span parent="redraw" class="right-caret"></span> redraw()</td>
</tr>
<tr class="hidden" parent="redraw">
<td class="mid">Returns: none</td>
<td>Redraw the network.</td> <td>Redraw the network.</td>
</tr> </tr>
<tr class="oddRow hidden" parent="canvas">
<td>setSize(<br>&nbsp;&nbsp;&nbsp;<code><i>String width</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>String
height</i></code><br>)
<tr class="collapsible toggle" onclick="toggleTable('methodTable','setSize', this);">
<td colspan="2"><span parent="setSize" class="right-caret"></span> setSize(<code><i>String width</i></code>,<code><i>String
height</i></code>)
</td> </td>
<td class="mid">none</td>
</tr>
<tr class="hidden" parent="setSize">
<td class="mid">Returns: none</td>
<td>Set the size of the canvas. This is automatically done on a window resize.</td> <td>Set the size of the canvas. This is automatically done on a window resize.</td>
</tr> </tr>
<tr class="subHeader evenRow toggle collapsible" onclick="toggleTable('moduleTable','clustering', this);">
<td colspan="3"><span parent="color" class="right-caret"></span> Clustering</td>
<tr class="subHeader">
<td colspan="2">Clustering</td>
</tr> </tr>
<tr class="evenRow hidden" parent="clustering">
<td>cluster(<br>&nbsp;&nbsp;
<code>Object options</code><br>)
<tr class="collapsible toggle" onclick="toggleTable('methodTable','cluster', this);">
<td colspan="2"><span parent="cluster" class="right-caret"></span> cluster(
<code>Object options</code>)
</td> </td>
<td class="mid">none</td>
</tr>
<tr class="hidden" parent="cluster">
<td class="mid">Returns: none</td>
<td>The options object is explained in full <a data-scroll="" <td>The options object is explained in full <a data-scroll=""
data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }"
href="#optionsObject">below</a>. The joinCondition function href="#optionsObject">below</a>. The joinCondition function
is presented with all nodes. is presented with all nodes.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="clustering">
<td>clusterByConnection(<br>
&nbsp;&nbsp;<code>String nodeId</code>,<br>
&nbsp;&nbsp;<code>[Object options]</code><br>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByConnection', this);">
<td colspan="2"><span parent="clusterByConnection" class="right-caret"></span> clusterByConnection(
<code>String nodeId</code>,
<code>[Object options]</code>
) )
</td> </td>
<td class="mid">none</td>
</tr>
<tr class="hidden" parent="clusterByConnection">
<td class="mid">Returns: none</td>
<td>This method looks at the provided node and makes a cluster of it and all it's connected nodes. The <td>This method looks at the provided node and makes a cluster of it and all it's connected nodes. The
behaviour can be customized by proving the options object. All options of this object are explained <a behaviour can be customized by proving the options object. All options of this object are explained <a
data-scroll="" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }" data-scroll="" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }"
href="#optionsObject">below</a>. The joinCondition is only presented with the connected nodes. href="#optionsObject">below</a>. The joinCondition is only presented with the connected nodes.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="clustering">
<td>clusterByHubsize(<br>
&nbsp;&nbsp;<code>Number hubsize</code>,<br>
&nbsp;&nbsp;<code>[Object options]</code><br>)
<tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
<td colspan="2"><span parent="clusterByHubsize" class="right-caret"></span> clusterByHubsize(
<code>Number hubsize</code>,
<code>[Object options]</code>)
</td> </td>
<td class="mid">none</td>
</tr>
<tr class="hidden" parent="clusterByHubsize">
<td class="mid">Returns: none</td>
<td>This method checks all nodes in the network and those with a equal or higher amount of edges than <td>This method checks all nodes in the network and those with a equal or higher amount of edges than
specified with the <code>hubsize</code> qualify. Cluster by connection is performed on each of them. The specified with the <code>hubsize</code> qualify. Cluster by connection is performed on each of them. The
options object is described for <code>clusterByConnection</code> and does the same here. options object is described for <code>clusterByConnection</code> and does the same here.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="clustering">
<td>clusterOutliers(<br>
&nbsp;&nbsp;<code>[Object options]</code><br>)
</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterOutliers', this);">
<td colspan="2"><span parent="clusterOutliers" class="right-caret"></span> clusterOutliers(
<code>[Object options]</code>)
</tr>
<tr class="hidden" parent="clusterOutliers">
<td class="mid">Returns: none</td>
<td>This method will cluster all nodes with 1 edge with their respective connected node.</td> <td>This method will cluster all nodes with 1 edge with their respective connected node.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="clustering">
<td>findNode(<br>
&nbsp;&nbsp;<code>String nodeId</code><br>)
</td>
<td class="mid">Array</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','findNode', this);">
<td colspan="2"><span parent="findNode" class="right-caret"></span> findNode(
<code>String nodeId</code>)
</tr>
<tr class="hidden" parent="findNode">
<td class="mid">Returns: Array</td>
<td>Nodes can be in clusters. Clusters can also be in clusters. This function returns and array of nodeIds <td>Nodes can be in clusters. Clusters can also be in clusters. This function returns and array of nodeIds
showing where the node is. Example: <br>
cluster 'A' contains cluster 'B',<br>
cluster 'B' contains cluster 'C',<br>
cluster 'C' contains node 'fred'.<br>
showing where the node is. <br><br> Example:
cluster 'A' contains cluster 'B',
cluster 'B' contains cluster 'C',
cluster 'C' contains node 'fred'.
<code>network.clustering.findNode('fred')</code> will return <code>['A','B','C','fred']</code>. <code>network.clustering.findNode('fred')</code> will return <code>['A','B','C','fred']</code>.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="clustering">
<td>isCluster(<br>
&nbsp;&nbsp;<code>String nodeId</code><br>)
</td>
<td class="mid">Boolean</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','isCluster', this);">
<td colspan="2"><span parent="isCluster" class="right-caret"></span> isCluster(
<code>String nodeId</code>)
</tr>
<tr class="hidden" parent="isCluster">
<td class="mid">Returns: Boolean</td>
<td>Returns true if the node whose ID has been supplied is a cluster.</td> <td>Returns true if the node whose ID has been supplied is a cluster.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="clustering">
<td>openCluster(<br>&nbsp;&nbsp;
<code>String nodeId</code><br>)
</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','openCluster', this);">
<td colspan="2"><span parent="openCluster" class="right-caret"></span> openCluster(
<code>String nodeId</code>)
</tr>
<tr class="hidden" parent="openCluster">
<td class="mid">Returns: none</td>
<td>Opens the cluster, releases the contained nodes and edges, removing the cluster node and cluster <td>Opens the cluster, releases the contained nodes and edges, removing the cluster node and cluster
edges. edges.
</td> </td>
</tr> </tr>
<tr class="subHeader oddRow">
<td colspan="3">Layout</td>
<tr class="subHeader">
<td colspan="2">Layout</td>
</tr> </tr>
<tr class="oddRow">
<td>getSeed()</td>
<td class="mid">Number</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getSeed', this);">
<td colspan="2"><span parent="getSeed" class="right-caret"></span> getSeed()</td>
</tr>
<tr class="hidden" parent="clusterByHubsize">
</tr>
<tr class="hidden" parent="getSeed">
<td class="mid">Returns: Number</td>
<td>If you like the layout of your network and would like it to start in the same way next time, ask for the <td>If you like the layout of your network and would like it to start in the same way next time, ask for the
seed using this method and put it in the <code>randomSeed</code> option.
seed using this method and put it in the <code>layout.randomSeed</code> option.
</td> </td>
</tr> </tr>
<tr class="subHeader evenRow toggle collapsible" onclick="toggleTable('moduleTable','manipulation', this);">
<td colspan="3"><span parent="color" class="right-caret"></span> Manipulation methods to use the
manipulation system without GUI.
</td>
<tr class="subHeader">
<td colspan="2">Manipulation methods to use the manipulation system without GUI.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="manipulation">
<td>enableEditMode()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','enableEditMode', this);">
<td colspan="2"><span parent="enableEditMode" class="right-caret"></span> enableEditMode()</td>
</tr>
<tr class="hidden" parent="enableEditMode">
<td class="mid">Returns: none</td>
<td>Programatically enable the edit mode. Similar effect to pressing the edit button.</td> <td>Programatically enable the edit mode. Similar effect to pressing the edit button.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="manipulation">
<td>disableEditMode()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','disableEditMode', this);">
<td colspan="2"><span parent="disableEditMode" class="right-caret"></span> disableEditMode()</td>
</tr>
<tr class="hidden" parent="disableEditMode">
<td class="mid">Returns: none</td>
<td>Programatically disable the edit mode. Similar effect to pressing the close icon (small cross in the <td>Programatically disable the edit mode. Similar effect to pressing the close icon (small cross in the
corner of the toolbar). corner of the toolbar).
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="manipulation">
<td>addNodeMode()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','addNodeMode', this);">
<td colspan="2"><span parent="addNodeMode" class="right-caret"></span> addNodeMode()</td>
</tr>
<tr class="hidden" parent="addNodeMode">
<td class="mid">Returns: none</td>
<td>Go into addNode mode. Having edit mode or manipulation enabled is not required. To get out of this mode, <td>Go into addNode mode. Having edit mode or manipulation enabled is not required. To get out of this mode,
call <code>disableEditMode()</code>. The callback functions defined in <code>handlerFunctions</code> call <code>disableEditMode()</code>. The callback functions defined in <code>handlerFunctions</code>
still apply. To use these methods without having the manipulation GUI, make sure you set still apply. To use these methods without having the manipulation GUI, make sure you set
<code>enabled</code> to false. <code>enabled</code> to false.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="manipulation">
<td>editNodeMode()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','editNodeMode', this);">
<td colspan="2"><span parent="editNodeMode" class="right-caret"></span> editNodeMode()</td>
</tr>
<tr class="hidden" parent="editNodeMode">
<td class="mid">Returns: none</td>
<td>Go into editNode mode. The explaination from <code>addNodeMode</code> applies here as well.</td> <td>Go into editNode mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="manipulation">
<td>addEdgeMode()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','addEdgeMode', this);">
<td colspan="2"><span parent="addEdgeMode" class="right-caret"></span> addEdgeMode()</td>
</tr>
<tr class="hidden" parent="addEdgeMode">
<td class="mid">Returns: none</td>
<td>Go into addEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td> <td>Go into addEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="manipulation">
<td>editEdgeMode()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','editEdgeMode', this);">
<td colspan="2"><span parent="editEdgeMode" class="right-caret"></span> editEdgeMode()</td>
</tr>
<tr class="hidden" parent="editEdgeMode">
<td class="mid">Returns: none</td>
<td>Go into editEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td> <td>Go into editEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="manipulation">
<td>deleteSelected()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','deleteSelected', this);">
<td colspan="2"><span parent="deleteSelected" class="right-caret"></span> deleteSelected()</td>
</tr>
<tr class="hidden" parent="deleteSelected">
<td class="mid">Returns: none</td>
<td>Delete selected. Having edit mode or manipulation enabled is not required.</td> <td>Delete selected. Having edit mode or manipulation enabled is not required.</td>
</tr> </tr>
<tr class="subHeader oddRow toggle collapsible" onclick="toggleTable('moduleTable','nodes', this);">
<td colspan="3"><span parent="color" class="right-caret"></span> Methods to get information on nodes.</td>
<tr class="subHeader">
<td colspan="2">Methods to get information on nodes.</td>
</tr> </tr>
<tr class="oddRow hidden" parent="nodes">
<td>getPositions(<br>&nbsp;&nbsp;&nbsp;<code><i>[Array of nodeIds]</i></code><br>)</td>
<td class="mid">Object</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getPositions', this);">
<td colspan="2"><span parent="getPositions" class="right-caret"></span> getPositions(<code><i>[Array of
nodeIds]</i></code>)
</td>
</tr>
<tr class="hidden" parent="getPositions">
<td class="mid">Returns: Object</td>
<td>Returns the x y positions in canvas space of the nodes with the supplied nodeIds as an object: <td>Returns the x y positions in canvas space of the nodes with the supplied nodeIds as an object:
<pre class="code"> <pre class="code">
{ {
@ -464,16 +516,19 @@ network.setOptions(options);
are returned. are returned.
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="nodes">
<td>storePositions()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','storePositions', this);">
<td colspan="2"><span parent="storePositions" class="right-caret"></span> storePositions()</td>
</tr>
<tr class="hidden" parent="storePositions">
<td class="mid">Returns: none</td>
<td>When using the vis.DataSet to load your nodes into the network, this method will put the X and Y <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. <br><br> If you're loading your nodes from a database and have
positions of all nodes into that dataset. If you're loading your nodes from a database and have
this dynamically coupled with this dynamically coupled with
the DataSet, you can the DataSet, you can
use this to stablize your network once, then save the positions in that database through the DataSet so use this to stablize your network once, then save the positions in that database through the DataSet so
the next the next
time you load the nodes, stabilization will be near instantaneous.<br><br>
time you load the nodes, stabilization will be near instantaneous.
<br><br>
If the nodes are still moving and you're using dynamic smooth edges (which is on by default), you can If the nodes are still moving and you're using dynamic smooth edges (which is on by default), you can
use the option <code>stabilization.onlyDynamicEdges</code> in the <a href="physics.html">physics use the option <code>stabilization.onlyDynamicEdges</code> in the <a href="physics.html">physics
module</a> module</a>
@ -486,9 +541,13 @@ network.setOptions(options);
</tr> </tr>
<tr class="oddRow hidden" parent="nodes">
<td>getBoundingBox(<br>&nbsp;&nbsp;&nbsp;<code><i>String nodeId</i></code><br>)</td>
<td class="mid">Object</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getBoundingBox', this);">
<td colspan="2"><span parent="getBoundingBox" class="right-caret"></span> getBoundingBox(<code><i>String
nodeId</i></code>)
</td>
</tr>
<tr class="hidden" parent="getBoundingBox">
<td class="mid">Returns: Object</td>
<td> Returns a bounding box for the node including label in the format: <td> Returns a bounding box for the node including label in the format:
<pre class="code"> <pre class="code">
{ {
@ -501,50 +560,64 @@ network.setOptions(options);
These values are in canvas space. These values are in canvas space.
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="nodes">
<td>getConnectedNodes(<br>&nbsp;&nbsp;&nbsp;<code><i>String nodeId</i></code><br>)</td>
<td class="mid">Array</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedNodes', this);">
<td colspan="2"><span parent="getConnectedNodes" class="right-caret"></span> getConnectedNodes(<code><i>String
nodeId</i></code>)
</td>
</tr>
<tr class="hidden" parent="getConnectedNodes">
<td class="mid">Returns: Array</td>
<td>Returns an array of nodeIds of the all the nodes that are directly connected to this node.</td> <td>Returns an array of nodeIds of the all the nodes that are directly connected to this node.</td>
</tr> </tr>
<tr class="oddRow hidden" parent="nodes">
<td>getEdges(<br>&nbsp;&nbsp;&nbsp;<code><i>String nodeId</i></code><br>)</td>
<td class="mid">Array</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getEdges', this);">
<td colspan="2"><span parent="getEdges" class="right-caret"></span> getEdges(<code><i>String
nodeId</i></code>)
</td>
</tr>
<tr class="hidden" parent="getEdges">
<td class="mid">Returns: Array</td>
<td>Returns an array of edgeIds of the edges connected to this node.</td> <td>Returns an array of edgeIds of the edges connected to this node.</td>
</tr> </tr>
<tr class="subHeader evenRow toggle collapsible" onclick="toggleTable('moduleTable','physics', this);">
<td colspan="3"><span parent="color" class="right-caret"></span> Physics methods to control when the
simulation should run.
</td>
<tr class="subHeader">
<td colspan="2">Physics methods to control when the simulation should run.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="physics">
<td>startSimulation()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','startSimulation', this);">
<td colspan="2"><span parent="startSimulation" class="right-caret"></span> startSimulation()</td>
</tr>
<tr class="hidden" parent="startSimulation">
<td class="mid">Returns: none</td>
<td>Start the physics simulation. This is normally done whenever needed and is only really useful if you <td>Start the physics simulation. This is normally done whenever needed and is only really useful if you
stop the simulation yourself and wish to continue it afterwards. stop the simulation yourself and wish to continue it afterwards.
</td> </td>
.</td></tr> .</td></tr>
<tr class="evenRow hidden" parent="physics">
<td>stopSimulation()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','stopSimulation', this);">
<td colspan="2"><span parent="stopSimulation" class="right-caret"></span> stopSimulation()</td>
</tr>
<tr class="hidden" parent="stopSimulation">
<td class="mid">Returns: none</td>
<td>This stops the physics simulation and triggers a <code>stabilized</code> event. It can be restarted by <td>This stops the physics simulation and triggers a <code>stabilized</code> event. It can be restarted by
dragging a node, altering the dataset or calling <code>startSimulation()</code>. dragging a node, altering the dataset or calling <code>startSimulation()</code>.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="physics">
<td>stabilize()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','stabilize', this);">
<td colspan="2"><span parent="stabilize" class="right-caret"></span> stabilize()</td>
</tr>
<tr class="hidden" parent="stabilize">
<td class="mid">Returns: none</td>
<td>You can manually call stabilize at any time. All the stabilization options above are used.</td> <td>You can manually call stabilize at any time. All the stabilization options above are used.</td>
</tr> </tr>
<tr class="subHeader oddRow toggle collapsible" onclick="toggleTable('moduleTable','selection', this);">
<td colspan="3"><span parent="color" class="right-caret"></span> Selection methods for nodes and edges.</td>
<tr class="subHeader">
<td colspan="2">Selection methods for nodes and edges.</td>
</tr> </tr>
<tr class="oddRow hidden" parent="selection">
<td>getSelection()</td>
<td class="mid">Object</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelection', this);">
<td colspan="2"><span parent="getSelection" class="right-caret"></span> getSelection()</td>
</tr>
<tr class="hidden" parent="getSelection">
<td class="mid">Returns: Object</td>
<td>Returns an object with selected nodes and edges ids like this: <td>Returns an object with selected nodes and edges ids like this:
<pre class="code"> <pre class="code">
{ {
@ -554,77 +627,102 @@ network.setOptions(options);
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="selection">
<td>getSelectedNodes()</td>
<td class="mid">Array</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedNodes', this);">
<td colspan="2"><span parent="getSelectedNodes" class="right-caret"></span> getSelectedNodes()</td>
</tr>
<tr class="hidden" parent="getSelectedNodes">
<td class="mid">Returns: Array</td>
<td>Returns an array of selected node ids like so: <td>Returns an array of selected node ids like so:
<code>[nodeId1, nodeId2, ..]</code>. <code>[nodeId1, nodeId2, ..]</code>.
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="selection">
<td>getSelectedEdges()</td>
<td class="mid">Array</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedEdges', this);">
<td colspan="2"><span parent="getSelectedEdges" class="right-caret"></span> getSelectedEdges()</td>
</tr>
<tr class="hidden" parent="getSelectedEdges">
<td class="mid">Returns: Array</td>
<td>Returns an array of selected edge ids like so: <code>[edgeId1, edgeId2, ..]</code>.</td> <td>Returns an array of selected edge ids like so: <code>[edgeId1, edgeId2, ..]</code>.</td>
</tr> </tr>
<tr class="oddRow hidden" parent="selection">
<td>getNodeAt(<br>&nbsp;&nbsp;&nbsp;<code><i>{x: xPosition DOM,<br>&nbsp;&nbsp; y: yPosition DOM}</i></code><br>)
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getNodeAt', this);">
<td colspan="2"><span parent="getNodeAt" class="right-caret"></span> getNodeAt(<code><i>{x: xPosition
DOM, y: yPosition DOM}</i></code>)
</td> </td>
<td class="mid">String</td>
</tr>
<tr class="hidden" parent="getNodeAt">
<td class="mid">Returns: String</td>
<td>Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left corner <td>Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left corner
of the canvas. of the canvas.
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="selection">
<td>getEdgeAt(<br>&nbsp;&nbsp;&nbsp;<code><i>{x: xPosition DOM,<br>&nbsp;&nbsp; y: yPosition DOM}</i></code><br>)
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getEdgeAt', this);">
<td colspan="2"><span parent="getEdgeAt" class="right-caret"></span> getEdgeAt(<code><i>{x: xPosition
DOM, y: yPosition DOM}</i></code>)
</td> </td>
<td class="mid">String</code></td>
</tr>
<tr class="hidden" parent="getEdgeAt">
<td class="mid">Returns: String</code></td>
<td>Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left corner <td>Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left corner
of the canvas.. of the canvas..
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="selection">
<td>selectNodes(<br>&nbsp;&nbsp;&nbsp;<code><i>Array with nodeIds</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>[Boolean
highlightEdges]</i></code><br>)
<tr class="collapsible toggle" onclick="toggleTable('methodTable','selectNodes', this);">
<td colspan="2"><span parent="selectNodes" class="right-caret"></span> selectNodes(<code><i>Array with
nodeIds</i></code>,<code><i>[Boolean
highlightEdges]</i></code>)
</td> </td>
<td class="mid">none</td>
</tr>
<tr class="hidden" parent="selectNodes">
<td class="mid">Returns: none</td>
<td>Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or undefined, <td>Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or undefined,
the neighbouring edges will also be selected. This method unselects all other objects before selecting the neighbouring edges will also be selected. This method unselects all other objects before selecting
its own objects. <i>Does not fire events</i>. its own objects. <i>Does not fire events</i>.
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="selection">
<td>selectEdges(<br>&nbsp;&nbsp;&nbsp;<code><i>Array with edgeIds</i></code><br>)</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','selectEdges', this);">
<td colspan="2"><span parent="selectEdges" class="right-caret"></span> selectEdges(<code><i>Array with
edgeIds</i></code>)
</td>
</tr>
<tr class="hidden" parent="selectEdges">
<td class="mid">Returns: none</td>
<td>Selects the edges corresponding to the id's in the input array. This method unselects all other objects <td>Selects the edges corresponding to the id's in the input array. This method unselects all other objects
before selecting its own objects. <i>Does not fire events</i>. before selecting its own objects. <i>Does not fire events</i>.
</td> </td>
</tr> </tr>
<tr class="oddRow hidden" parent="selection">
<td>unselectAll()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','unselectAll', this);">
<td colspan="2"><span parent="unselectAll" class="right-caret"></span> unselectAll()</td>
</tr>
<tr class="hidden" parent="unselectAll">
<td class="mid">Returns: none</td>
<td>Unselect all objects. <i>Does not fire events</i>.</td> <td>Unselect all objects. <i>Does not fire events</i>.</td>
</tr> </tr>
<tr class="subHeader evenRow toggle collapsible" onclick="toggleTable('moduleTable','view', this);">
<td colspan="3"><span parent="color" class="right-caret"></span> Methods to control the viewport for zoom
and animation.
</td>
<tr class="subHeader">
<td colspan="2">Methods to control the viewport for zoom and animation.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="view">
<td>getScale()</td>
<td class="mid">Number</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','getScale', this);">
<td colspan="2"><span parent="getScale" class="right-caret"></span> getScale()</td>
</tr>
<tr class="hidden" parent="getScale">
<td class="mid">Returns: Number</td>
<td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.</td> <td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="view">
<td>getPosition()</td>
<td class="mid">Number</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
<td colspan="2"><span parent="clusterByHubsize" class="right-caret"></span> getPosition()</td>
</tr>
<tr class="hidden" parent="clusterByHubsize">
<td class="mid">Returns: Number</td>
<td>Returns the current central focus point of the camera.</td> <td>Returns the current central focus point of the camera.</td>
</tr> </tr>
<tr class="evenRow hidden" parent="view">
<td>fit(<code>[Object options]</code>)</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','fit', this);">
<td colspan="2"><span parent="fit" class="right-caret"></span> fit(<code>[Object
options]</code>)
</td>
</tr>
<tr class="hidden" parent="fit">
<td class="mid">Returns: none</td>
<td>Zooms out so all nodes fit on the canvas. You can supply options to customize this: <td>Zooms out so all nodes fit on the canvas. You can supply options to customize this:
<pre class="code"> <pre class="code">
{ {
@ -640,12 +738,14 @@ network.setOptions(options);
All options are optional for the fit method. All options are optional for the fit method.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="view">
<td>focus(<br>
&nbsp;&nbsp;&nbsp;<code>String nodeId</code>,<br>
&nbsp;&nbsp;&nbsp;<code>[Object options]</code><br>)
<tr class="collapsible toggle" onclick="toggleTable('methodTable','focus', this);">
<td colspan="2"><span parent="focus" class="right-caret"></span> focus(
<code>String nodeId</code>,
<code>[Object options]</code>)
</td> </td>
<td class="mid">none</td>
</tr>
<tr class="hidden" parent="focus">
<td class="mid">Returns: none</td>
<td>You can focus on a node with this function. What that means is the view will lock onto that node, if it <td>You can focus on a node with this function. What that means is the view will lock onto that node, if it
is moving, the view will also move accordingly. If the view is dragged by the user, the focus is broken. is moving, the view will also move accordingly. If the view is dragged by the user, the focus is broken.
You can supply options to customize the effect: You can supply options to customize the effect:
@ -665,9 +765,13 @@ network.setOptions(options);
Default value is true. The options object is optional in the focus method. Default value is true. The options object is optional in the focus method.
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="view">
<td>moveTo(<code>Object options</code>)</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','moveTo', this);">
<td colspan="2"><span parent="moveTo" class="right-caret"></span> moveTo(<code>Object
options</code>)
</td>
</tr>
<tr class="hidden" parent="moveTo">
<td class="mid">Returns: none</td>
<td>You can animate or move the camera using the moveTo method. Options are: <td>You can animate or move the camera using the moveTo method. Options are:
<pre class="code"> <pre class="code">
{ {
@ -680,23 +784,25 @@ network.setOptions(options);
} }
} }
</pre> </pre>
The position (in canvas units!) is the position of the central focus point of the camera. <br><br>
The scale is the target zoomlevel. Default value is 1.0. <br><br>
The position (in canvas units!) is the position of the central focus point of the camera.
The scale is the target zoomlevel. Default value is 1.0.
The offset (in DOM units) is how many pixels from the center the view is focussed. Default value is The offset (in DOM units) is how many pixels from the center the view is focussed. Default value is
{x:0,y:0}.<br><br>
{x:0,y:0}.
For animation you can either use a Boolean to use it with the default options or disable it or you can For animation you can either use a Boolean to use it with the default options or disable it or you can
define the duration (in milliseconds) and easing function manually. Available are: define the duration (in milliseconds) and easing function manually. Available are:
<code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint</code>. easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint</code>.
<br><br>
<i>You will have to define at least a scale or a position. Otherwise, there is nothing to move to.</i> <i>You will have to define at least a scale or a position. Otherwise, there is nothing to move to.</i>
</td> </td>
</tr> </tr>
<tr class="evenRow hidden" parent="view">
<td>releaseNode()</td>
<td class="mid">none</td>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','releaseNode', this);">
<td colspan="2"><span parent="releaseNode" class="right-caret"></span> releaseNode()</td>
</tr>
<tr class="hidden" parent="releaseNode">
<td class="mid">Returns: none</td>
<td>Programatically release the focussed node.</td> <td>Programatically release the focussed node.</td>
</tr> </tr>
@ -792,29 +898,6 @@ var options = {
</table> </table>
<h4 id="locales">Locales</h4>
<p>The locales object has the following format:</p>
<pre class="prettyprint lang-js">
var locales = {
en: {
edit: 'Edit',
del: 'Delete selected',
back: 'Back',
addNode: 'Add Node',
addEdge: 'Add Edge',
editNode: 'Edit Node',
editEdge: 'Edit Edge',
addDescription: 'Click in an empty space to place a new node.',
edgeDescription: 'Click on a node and drag the edge to another node to connect them.',
editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
createEdgeError: 'Cannot link edges to a cluster.',
deleteClusterError: 'Clusters cannot be deleted.',
editClusterError: 'Clusters cannot be edited.'
}
}</pre>
<p>If you want to define your own locale, you can change the key ('en' here) and change all the string. You can then
use your new key in the locale option.</p>
<br> <br>
<br> <br>

+ 14
- 56
lib/timeline/DataStep.js View File

@ -24,7 +24,7 @@
* @param {Date} [end] The end date * @param {Date} [end] The end date
* @param {Number} [minimumStep] Optional. Minimum step size in milliseconds * @param {Number} [minimumStep] Optional. Minimum step size in milliseconds
*/ */
function DataStep(start, end, minimumStep, containerHeight, customRange, alignZeros) {
function DataStep(start, end, minimumStep, containerHeight, customRange, formattingFunction, alignZeros) {
// variables // variables
this.current = 0; this.current = 0;
@ -32,6 +32,7 @@ function DataStep(start, end, minimumStep, containerHeight, customRange, alignZe
this.stepIndex = 0; this.stepIndex = 0;
this.step = 1; this.step = 1;
this.scale = 1; this.scale = 1;
this.formattingFunction = formattingFunction;
this.marginStart; this.marginStart;
this.marginEnd; this.marginEnd;
@ -186,67 +187,24 @@ DataStep.prototype.previous = function() {
* Get the current datetime * Get the current datetime
* @return {String} current The current date * @return {String} current The current date
*/ */
DataStep.prototype.getCurrent = function(decimals) {
DataStep.prototype.getCurrent = function() {
// prevent round-off errors when close to zero // prevent round-off errors when close to zero
var current = (Math.abs(this.current) < this.step / 2) ? 0 : this.current; var current = (Math.abs(this.current) < this.step / 2) ? 0 : this.current;
var toPrecision = '' + Number(current).toPrecision(5);
// If decimals is specified, then limit or extend the string as required
if(decimals !== undefined && !isNaN(Number(decimals))) {
// If string includes exponent, then we need to add it to the end
var exp = "";
var index = toPrecision.indexOf("e");
if(index != -1) {
// Get the exponent
exp = toPrecision.slice(index);
// Remove the exponent in case we need to zero-extend
toPrecision = toPrecision.slice(0, index);
}
index = Math.max(toPrecision.indexOf(","), toPrecision.indexOf("."));
if(index === -1) {
// No decimal found - if we want decimals, then we need to add it
if(decimals !== 0) {
toPrecision += '.';
}
// Calculate how long the string should be
index = toPrecision.length + decimals;
}
else if(decimals !== 0) {
// Calculate how long the string should be - accounting for the decimal place
index += decimals + 1;
}
if(index > toPrecision.length) {
// We need to add zeros!
for(var cnt = index - toPrecision.length; cnt > 0; cnt--) {
toPrecision += '0';
}
}
else {
// we need to remove characters
toPrecision = toPrecision.slice(0, index);
}
// Add the exponent if there is one
toPrecision += exp;
var returnValue = current.toPrecision(5);
if (typeof this.formattingFunction === 'function') {
returnValue = this.formattingFunction(current);
}
if (typeof returnValue === 'number') {
return '' + returnValue;
}
else if (typeof returnValue === 'string') {
return returnValue;
} }
else { else {
if (toPrecision.indexOf(",") != -1 || toPrecision.indexOf(".") != -1) {
// If no decimal is specified, and there are decimal places, remove trailing zeros
for (var i = toPrecision.length - 1; i > 0; i--) {
if (toPrecision[i] === "0") {
toPrecision = toPrecision.slice(0, i);
}
else if (toPrecision[i] === "." || toPrecision[i] === ",") {
toPrecision = toPrecision.slice(0, i);
break;
}
else {
break;
}
}
}
return current.toPrecision(5);
} }
return toPrecision;
}; };
/** /**

+ 5
- 9
lib/timeline/component/DataAxis.js View File

@ -30,12 +30,12 @@ function DataAxis (body, options, svg, linegraphOptions) {
alignZeros: true, alignZeros: true,
left:{ left:{
range: {min:undefined,max:undefined}, range: {min:undefined,max:undefined},
format: {decimals:undefined},
format: function (value) {return '' + value.toPrecision(5);},
title: {text:undefined,style:undefined} title: {text:undefined,style:undefined}
}, },
right:{ right:{
range: {min:undefined,max:undefined}, range: {min:undefined,max:undefined},
format: {decimals:undefined},
format: function (value) {return '' + value.toPrecision(5);},
title: {text:undefined,style:undefined} title: {text:undefined,style:undefined}
} }
}; };
@ -385,6 +385,7 @@ DataAxis.prototype._redrawLabels = function () {
minimumStep, minimumStep,
this.dom.frame.offsetHeight, this.dom.frame.offsetHeight,
this.options[this.options.orientation].range, this.options[this.options.orientation].range,
this.options[this.options.orientation].format,
this.master === false && this.options.alignZeros // does the step have to align zeros? only if not master and the options is on this.master === false && this.options.alignZeros // does the step have to align zeros? only if not master and the options is on
); );
@ -406,11 +407,6 @@ DataAxis.prototype._redrawLabels = function () {
// value at the bottom of the SVG // value at the bottom of the SVG
this.valueAtBottom = step.marginEnd; this.valueAtBottom = step.marginEnd;
// Get the number of decimal places
var decimals;
if(this.options[orientation].format !== undefined) {
decimals = this.options[orientation].format.decimals;
}
this.maxLabelSize = 0; this.maxLabelSize = 0;
var y = 0; // init value var y = 0; // init value
@ -422,13 +418,13 @@ DataAxis.prototype._redrawLabels = function () {
if (stepIndex > 0 && stepIndex !== this.amountOfSteps) { if (stepIndex > 0 && stepIndex !== this.amountOfSteps) {
if (this.options['showMinorLabels'] && isMajor === false || this.master === false && this.options['showMinorLabels'] === true) { if (this.options['showMinorLabels'] && isMajor === false || this.master === false && this.options['showMinorLabels'] === true) {
this._redrawLabel(y - 2, step.getCurrent(decimals), orientation, 'vis-y-axis vis-minor', this.props.minorCharHeight);
this._redrawLabel(y - 2, step.getCurrent(), orientation, 'vis-y-axis vis-minor', this.props.minorCharHeight);
} }
if (isMajor && this.options['showMajorLabels'] && this.master === true || if (isMajor && this.options['showMajorLabels'] && this.master === true ||
this.options['showMinorLabels'] === false && this.master === false && isMajor === true) { this.options['showMinorLabels'] === false && this.master === false && isMajor === true) {
if (y >= 0) { if (y >= 0) {
this._redrawLabel(y - 2, step.getCurrent(decimals), orientation, 'vis-y-axis vis-major', this.props.majorCharHeight);
this._redrawLabel(y - 2, step.getCurrent(), orientation, 'vis-y-axis vis-major', this.props.majorCharHeight);
} }
this._redrawLine(y, orientation, 'vis-grid vis-horizontal vis-major', this.options.majorLinesOffset, this.props.majorLineWidth); this._redrawLine(y, orientation, 'vis-grid vis-horizontal vis-major', this.options.majorLinesOffset, this.props.majorLineWidth);
} }

+ 30
- 0
test/networkTest.html View File

@ -0,0 +1,30 @@
<!doctype html>
<html>
<head>
<title>Network | Basic usage</title>
<script type="text/javascript" src="http://www.visjs.org/dist/vis.js"></script>
<link href="http://www.visjs.org/dist/vis.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#div_graph {
width: 1400px;
height: 1000px;
border: 1px solid lightgray;
}
</style>
</head>
<body>
<p>
Create a simple network with some nodes and edges.
</p>
<div id="div_graph"></div>
<script type="text/javascript">
</script>
</body>
</html>

Loading…
Cancel
Save