Browse Source

finalized all methods and adde3d more docs

flowchartTest
Alex de Mulder 9 years ago
parent
commit
d4d928d250
17 changed files with 12434 additions and 11770 deletions
  1. +11485
    -11446
      dist/vis.js
  2. +4
    -0
      docs/css/newdocs.css
  3. +105
    -26
      docs/network/canvas.html
  4. +132
    -30
      docs/network/new_network.html
  5. +519
    -79
      docs/network/nodes.html
  6. +1
    -1
      docs/network/physics.html
  7. +4
    -7
      docs/network/selection.html
  8. +15
    -18
      docs/network/view.html
  9. +1
    -5
      examples/network/01_basic_usage.html
  10. +3
    -119
      lib/network/Network.js
  11. +3
    -0
      lib/network/modules/ManipulationSystem.js
  12. +135
    -22
      lib/network/modules/NodesHandler.js
  13. +4
    -4
      lib/network/modules/PhysicsEngine.js
  14. +14
    -4
      lib/network/modules/SelectionHandler.js
  15. +3
    -3
      lib/network/modules/View.js
  16. +5
    -5
      lib/network/modules/components/NavigationHandler.js
  17. +1
    -1
      lib/network/modules/components/Node.js

+ 11485
- 11446
dist/vis.js
File diff suppressed because it is too large
View File


+ 4
- 0
docs/css/newdocs.css View File

@ -177,4 +177,8 @@ td.default {
td.eventProperties { td.eventProperties {
width:350px; width:350px;
}
td.methodName {
width:250px;
} }

+ 105
- 26
docs/network/canvas.html View File

@ -1,5 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<html lang="en">
<head>
<script>(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o), m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-61231638-1', 'auto');
ga('send', 'pageview');</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -35,7 +49,8 @@
<nav class="navbar navbar-inverse navbar-static-top" role="navigation"> <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
@ -46,7 +61,9 @@
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="../index.html#modules">Modules</a></li> <li><a href="../index.html#modules">Modules</a></li>
<li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon" src="../img/external-link-icons/external-link-icon-white.png"></a></li>
<li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon"
src="../img/external-link-icons/external-link-icon-white.png"></a>
</li>
<li><a href="../blog.html">Blog</a></li> <li><a href="../blog.html">Blog</a></li>
<li><a href="../index.html#download_install">Download</a></li> <li><a href="../index.html#download_install">Download</a></li>
<li><a href="../showcase/index.html">Showcase</a></li> <li><a href="../showcase/index.html">Showcase</a></li>
@ -61,53 +78,115 @@
</div> </div>
</div> </div>
<a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img
style="position: absolute; top: 0; right: 0; border: 0;"
src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<div class="container full"> <div class="container full">
<h1>Network - canvas</h1> <h1>Network - canvas</h1>
<p>Handles the HTML part of the canvas.</p> <p>Handles the HTML part of the canvas.</p>
<h3>Options</h3> <h3>Options</h3>
<p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p> <p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p>
<table class="moduleTable"> <table class="moduleTable">
<tr class="header"><td class="name">name</td><td class="type">type</td><td class="default">default</td><td class="description">description</td></tr>
<tr><td>width</td><td class="mid">String</td><td class="mid"><code>'100%'</code></td><td>the width of the canvas. Can be in percentages or pixels (ie. <code>'400px'</code>).</td></tr>
<tr><td>height</td><td class="mid">String</td><td class="mid"><code>'100%'</code></td><td>the height of the canvas. Can be in percentages or pixels (ie. <code>'400px'</code>).</td></tr>
<tr class="header">
<td class="name">name</td>
<td class="type">type</td>
<td class="default">default</td>
<td class="description">description</td>
</tr>
<tr>
<td>width</td>
<td class="mid">String</td>
<td class="mid"><code>'100%'</code></td>
<td>the width of the canvas. Can be in percentages or pixels (ie. <code>'400px'</code>).</td>
</tr>
<tr>
<td>height</td>
<td class="mid">String</td>
<td class="mid"><code>'100%'</code></td>
<td>the height of the canvas. Can be in percentages or pixels (ie. <code>'400px'</code>).</td>
</tr>
</table> </table>
<h3>Methods</h3> <h3>Methods</h3>
<p>This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.</p>
<p>This is a list of all the methods in the public API. Options can be set directly to the module or you can use the
setOptions method of the network itself and use the module name as an object name.</p>
<table class="moduleTable"> <table class="moduleTable">
<tr class="header"><td class="methodName">name</td><td>returns</td><td>description</td></tr>
<tr><td>setSize(String, String)</td><td class="mid">none</td><td>Set the size of the canvas. This is automatically done on a window resize.</td></tr>
<tr><td>canvasToDOM(Object)</td> <td class="mid">Object</td><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.</td></tr>
<tr><td>DOMtoCanvas(Object)</td> <td class="mid">Object</td><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.</td></tr>
<tr class="header">
<td class="methodName">name</td>
<td>returns</td>
<td>description</td>
</tr>
<tr>
<td>setSize(<br>&nbsp;&nbsp;&nbsp;<code><i>String width</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>String
height</i></code><br>)
</td>
<td class="mid">none</td>
<td>Set the size of the canvas. This is automatically done on a window resize.</td>
</tr>
<tr>
<td>canvasToDOM({<br>&nbsp;&nbsp;&nbsp;<code><i>x: Number</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>y:
Number</i></code><br>})
</td>
<td class="mid">Object</td>
<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.
</td>
</tr>
<tr>
<td>DOMtoCanvas({<br>&nbsp;&nbsp;&nbsp;<code><i>x: Number</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>y:
Number</i></code><br>})
</td>
<td class="mid">Object</td>
<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.
</td>
</tr>
</table> </table>
<h3>Events</h3> <h3>Events</h3>
<p>This is a list of all the events in the public API. They are collected here from all individual modules.</p> <p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
<table class="moduleTable"> <table class="moduleTable">
<tr class="header"><td class="eventName">name</td><td class="eventProperties">properties</td><td>description</td></tr>
<tr><td>resize</td><td class="mid">
<tr class="header">
<td class="eventName">name</td>
<td class="eventProperties">properties</td>
<td>description</td>
</tr>
<tr>
<td>resize</td>
<td class="mid">
<pre class="code"> <pre class="code">
{ {
width: Number // the new width of the canvas
height: Number // the new height of the canvas
oldWidth: Number // the old width of the canvas
width: Number // the new width of the canvas
height: Number // the new height of the canvas
oldWidth: Number // the old width of the canvas
oldHeight: Number // the old height of the canvas oldHeight: Number // the old height of the canvas
} }
</pre><ul>
</ul></td><td>Fired when the size of the canvas has been resized, either by a redraw call when the container div has changed in size, a setSize() call with new values or a setOptions() with new width and/or height values.</td>
</pre>
<ul>
</ul>
</td>
<td>Fired when the size of the canvas has been resized, either by a redraw call when the container div has
changed in size, a setSize() call with new values or a setOptions() with new width and/or height values.
</td>
</tr> </tr>
</table> </table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</div> </div>
<!-- Bootstrap core JavaScript <!-- Bootstrap core JavaScript

+ 132
- 30
docs/network/new_network.html View File

@ -1,5 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<html lang="en">
<head>
<script>(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o), m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-61231638-1', 'auto');
ga('send', 'pageview');</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -36,7 +50,8 @@
<nav class="navbar navbar-inverse navbar-static-top" role="navigation"> <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
@ -47,7 +62,9 @@
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="../index.html#modules">Modules</a></li> <li><a href="../index.html#modules">Modules</a></li>
<li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon" src="../img/external-link-icons/external-link-icon-white.png"></a></li>
<li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon"
src="../img/external-link-icons/external-link-icon-white.png"></a>
</li>
<li><a href="../blog.html">Blog</a></li> <li><a href="../blog.html">Blog</a></li>
<li><a href="../index.html#download_install">Download</a></li> <li><a href="../index.html#download_install">Download</a></li>
<li><a href="../showcase/index.html">Showcase</a></li> <li><a href="../showcase/index.html">Showcase</a></li>
@ -62,46 +79,131 @@
</div> </div>
</div> </div>
<a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img
style="position: absolute; top: 0; right: 0; border: 0;"
src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<div class="container full"> <div class="container full">
<h1>Network</h1> <h1>Network</h1>
<p>As of 4.0, the network consists of individual modules which handle specific parts of the network. These modules have their own docs, options, methods and events which you can access
by clicking on the modules in the list below.</p>
<p>As of 4.0, the network consists of individual modules which handle specific parts of the network. These modules
have their own docs, options, methods and events which you can access
by clicking on the modules in the list below.</p>
<h3>Modules</h3> <h3>Modules</h3>
<table class="moduleTable"> <table class="moduleTable">
<tr><td width="120px" class="gren"><a href="./canvas.html">canvas</a></td> <td>Handles the HTML part of the network.</td></tr>
<tr><td><a href="./clustering.html">clustering</a></td> <td>Provides the clustering api, giving users full control over the formed clusters.</td></tr>
<tr><td><a href="./configure.html">configure</a></td> <td>Generates an interactive option editor with filtering.</td></tr>
<tr><td><a href="./edges.html">edges</a></td> <td>Handles the creation and deletion of edges and contains the global edge options and styles.</td></tr>
<tr><td><a href="./groups.html">groups</a></td> <td>Contains the groups and some options on how to handle nodes with non-existing groups.</td></tr>
<tr><td><a href="./interaction.html">interaction</a></td> <td>Used for all user interaction with the network. Handles mouse and touch events as well as the navigation buttons and the popups.</td></tr>
<tr><td><a href="./layout.html">layout</a></td> <td>Governs the initial and hierarchical positioning.</td></tr>
<tr><td><a href="./manipulation.html">manipulation</a></td> <td>Supplies an API and optional GUI to alter the data in the network.</td></tr>
<tr><td><a href="./nodes.html">nodes</a></td> <td>Handles the creation and deletion of nodes and contains the global node options and styles.</td></tr>
<tr><td><a href="./physics.html">physics</a></td> <td>Does all the simulation moving the nodes and edges to their final positions, also governs stabilization.</td></tr>
<tr><td><a href="./rendering.html">rendering</a></td> <td>Handles the rendering aspect of vis. It governs the render loop, it draws the nodes and edges and provides events to allow users to hook into the drawing.</td></tr>
<tr><td><a href="./view.html">view</a></td> <td>Acts as the camera that looks on the canvas. Does the animation, zooming and focusing.</td></tr>
<tr><td><a href="./selection.html">selection</a></td> <td>Handles the selection of nodes and edges.</td></tr>
</table>
<h3>All Methods</h3>
<p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p>
<h3>All Events</h3>
<p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
<tr>
<td width="120px" class="gren"><a href="./canvas.html">canvas</a></td>
<td>Handles the HTML part of the network.</td>
</tr>
<tr>
<td><a href="./clustering.html">clustering</a></td>
<td>Provides the clustering api, giving users full control over the formed clusters.</td>
</tr>
<tr>
<td><a href="./configure.html">configure</a></td>
<td>Generates an interactive option editor with filtering.</td>
</tr>
<tr>
<td><a href="./edges.html">edges</a></td>
<td>Handles the creation and deletion of edges and contains the global edge options and styles.</td>
</tr>
<tr>
<td><a href="./groups.html">groups</a></td>
<td>Contains the groups and some options on how to handle nodes with non-existing groups.</td>
</tr>
<tr>
<td><a href="./interaction.html">interaction</a></td>
<td>Used for all user interaction with the network. Handles mouse and touch events as well as the navigation
buttons and the popups.
</td>
</tr>
<tr>
<td><a href="./layout.html">layout</a></td>
<td>Governs the initial and hierarchical positioning.</td>
</tr>
<tr>
<td><a href="./manipulation.html">manipulation</a></td>
<td>Supplies an API and optional GUI to alter the data in the network.</td>
</tr>
<tr>
<td><a href="./nodes.html">nodes</a></td>
<td>Handles the creation and deletion of nodes and contains the global node options and styles.</td>
</tr>
<tr>
<td><a href="./physics.html">physics</a></td>
<td>Does all the simulation moving the nodes and edges to their final positions, also governs
stabilization.
</td>
</tr>
<tr>
<td><a href="./rendering.html">rendering</a></td>
<td>Handles the rendering aspect of vis. It governs the render loop, it draws the nodes and edges and
provides events to allow users to hook into the drawing.
</td>
</tr>
<tr>
<td><a href="./selection.html">selection</a></td>
<td>Handles the selection of nodes and edges.</td>
</tr>
<tr>
<td><a href="./view.html">view</a></td>
<td>Acts as the camera that looks on the canvas. Does the animation, zooming and focusing.</td>
</tr>
</table>
<h3>All Methods</h3>
<p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p>
<table class="moduleTable">
<tr class="header">
<td class="methodName">name</td>
<td>returns</td>
<td>description</td>
</tr>
<tr>
<td>destroy()</td>
<td class="mid">none</td>
<td>Remove the network from the DOM and remove all Hammer bindings and references.</td>
</tr>
<tr>
<td>setData({<br><code><i>nodes: vis DataSet/Array</i></code>,<br><code><i>edges: vis
DataSet/Arary</i></code><br>})
</td>
<td class="mid">none</td>
<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
network.
</td>
</tr>
<tr>
<td>setOptions(<code>Object options</code>)</td>
<td class="mid">none</td>
<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.
</td>
</tr>
</table>
<h3>All Events</h3>
<p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div> </div>
<!-- Bootstrap core JavaScript <!-- Bootstrap core JavaScript

+ 519
- 79
docs/network/nodes.html View File

@ -1,5 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<html lang="en">
<head>
<script>(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o), m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-61231638-1', 'auto');
ga('send', 'pageview');</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -35,7 +49,8 @@
<nav class="navbar navbar-inverse navbar-static-top" role="navigation"> <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
@ -46,7 +61,9 @@
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="../index.html#modules">Modules</a></li> <li><a href="../index.html#modules">Modules</a></li>
<li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon" src="../img/external-link-icons/external-link-icon-white.png"></a></li>
<li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon"
src="../img/external-link-icons/external-link-icon-white.png"></a>
</li>
<li><a href="../blog.html">Blog</a></li> <li><a href="../blog.html">Blog</a></li>
<li><a href="../index.html#download_install">Download</a></li> <li><a href="../index.html#download_install">Download</a></li>
<li><a href="../showcase/index.html">Showcase</a></li> <li><a href="../showcase/index.html">Showcase</a></li>
@ -61,12 +78,19 @@
</div> </div>
</div> </div>
<a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img
style="position: absolute; top: 0; right: 0; border: 0;"
src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<div class="container full"> <div class="container full">
<h1>Network - nodes</h1> <h1>Network - nodes</h1>
<p>Handles the creation and deletion of nodes and contains the global node options and styles.</p> <p>Handles the creation and deletion of nodes and contains the global node options and styles.</p>
<h3>Options</h3> <h3>Options</h3>
<p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p> <p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p>
<table class="moduleTable" id="optionTable"> <table class="moduleTable" id="optionTable">
<tr class="header"> <tr class="header">
@ -75,56 +99,322 @@
<td class="default">default</td> <td class="default">default</td>
<td class="description">description</td> <td class="description">description</td>
</tr> </tr>
<tr><td>borderWidth</td> <td class="mid">Number</td> <td class="mid"><code>1</code></td> <td>The width of the border of the node.</td></tr>
<tr><td>borderWidthSelected</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>The width of the border of the node when it is selected. When undefined, the borderWidth is used</td></tr>
<tr><td>brokenImage</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>When the shape is set to <code>image</code> or <code>circularImage</code>, this option can be an URL to a backup image in case the URL supplied in the image option cannot be resolved.</td></tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','color', this);"><td><span parent="color" class="right-caret"></span> color</td> <td class="mid">Object or String</td><td class="mid"><code>Object</code></td> <td>The color object contains the color information of the node in every situation. When the node only needs a single color, a color value like <code>'rgba(120,32,14,1)'</code>, <code>'#ffffff'</code> or <code>'red'</code> can be supplied instead of an object.</td></tr>
<tr parent="color" class="hidden"><td class="indent">color.border</td> <td class="mid">String</td> <td class="mid"><code>'#2B7CE9'</code></td> <td>The color of the border of the node when it is not selected or hovered over <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
<tr parent="color" class="hidden"><td class="indent">color.background</td> <td class="mid">String</td> <td class="mid"><code>'#D2E5FF'</code></td> <td>The color of the background of the node when it is not selected or hovered over <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
<tr parent="color" class="hidden"><td class="indent">color.highlight</td> <td class="mid">Object or String</td><td class="mid"><code>Object</code></td> <td>The color the node when it is selected. Alternatively you can just supply a string color value.</td></tr>
<tr parent="color" class="hidden"><td class="indent2">color.highlight.border</td><td class="mid">String</td> <td class="mid"><code>'#2B7CE9'</code></td> <td>The color of the border of the node when it is selected.</td></tr>
<tr parent="color" class="hidden"><td class="indent2">color.highlight.background</td><td class="mid">String</td> <td class="mid"><code>'#D2E5FF'</code></td> <td>The color of the background of the node when it is selected.</td></tr>
<tr parent="color" class="hidden"><td class="indent">color.hover</td> <td class="mid">Object or String</td><td class="mid"><code>Object</code></td> <td>The color the node when the mouse hovers over it <i>(assuming hover is enabled in the interaction module)</i>. Shorthand like above is also supported.</td></tr>
<tr parent="color" class="hidden"><td class="indent2">color.hover.border</td> <td class="mid">String</td> <td class="mid"><code>'#2B7CE9'</code></td> <td>The color of the border of the node when the mouse hovers over it <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
<tr parent="color" class="hidden"><td class="indent2">color.hover.background</td> <td class="mid">String</td> <td class="mid"><code>'#D2E5FF'</code></td> <td>The color of the background of the node when the mouse hovers over it <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','fixed', this);"><td><span parent="fixed" class="right-caret"></span> fixed</td> <td class="mid">Object or Boolean</td><td class="mid"><code>Object</code></td> <td>When true, the node will not move but IS part of the physics simulation. When defined as an object, movement in either X or Y direction can be disabled.</td></tr>
<tr parent="fixed" class="hidden"><td class="indent">fixed.x</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>When true, the node will not move in the X direction.</td></tr>
<tr parent="fixed" class="hidden"><td class="indent">fixed.y</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>When true, the node will not move in the Y direction.</td></tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','font', this);"><td><span parent="font" class="right-caret"></span> font</td> <td class="mid">Object or String</td><td class="mid"><code>false</code></td> <td>This object defines the details of the label. A shorthand is also supported in the form <code>'size face color'</code> for example: <code>'14px arial red'</code>.</td></tr>
<tr parent="font" class="hidden"><td class="indent">font.color</td> <td class="mid">String</td> <td class="mid"><code>'#343434'</code></td> <td>Color of the label text.</td></tr>
<tr parent="font" class="hidden"><td class="indent">font.size</td> <td class="mid">Number</td> <td class="mid"><code>14</code></td> <td>Size of the label text.</td></tr>
<tr parent="font" class="hidden"><td class="indent">font.face</td> <td class="mid">String</td> <td class="mid"><code>'arial'</code></td> <td>Font face (or font family) of the label text.</td></tr>
<tr parent="font" class="hidden"><td class="indent">font.background</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>When not <code>undefined</code> but a <b>color string</b>, a background rectangle will be drawn behind the label in the supplied color.</td></tr>
<tr parent="font" class="hidden"><td class="indent">font.stroke</td> <td class="mid">Number</td> <td class="mid"><code>0</code></td> <td>As an alternative to the background rectangle, a stroke can be drawn around the text. When a value higher than 0 is supplied, the stroke will be drawn.</td></tr>
<tr parent="font" class="hidden"><td class="indent">font.strokeColor</td> <td class="mid">String</td> <td class="mid"><code>'#ffffff'</code></td> <td>This is the color of the stroke <i>assuming the value for stroke is higher than 0</i>.</td></tr>
<tr><td>group</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>When not <code>undefined</code>, the</td></tr>
<tr><td>hidden</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>When true, the node will not be shown. It will still be part of the physics simulation though!</td></tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','icon', this);"><td><span parent="icon" class="right-caret"></span> icon</td> <td class="mid">Object</td> <td class="mid"><code>Object</code></td><td>These options are only used when the shape is set to <code>icon</code>.</td></tr>
<tr parent="icon" class="hidden"><td class="indent">icon.face</td> <td class="mid">String</td> <td class="mid"><code>'FontAwesome'</code></td><td>These options are only used when the shape is set to <code>icon</code>. The possible options for the face are: <code>'FontAwesome'</code> and <code>'Ionicons'</code>.</td></tr>
<tr parent="icon" class="hidden"><td class="indent">icon.code</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>This is the code of the icon, for example <code>'\uf007'</code>.</td></tr>
<tr parent="icon" class="hidden"><td class="indent">icon.size</td> <td class="mid">Number</td> <td class="mid"><code>50</code></td> <td>The size of the icon.</td></tr>
<tr parent="icon" class="hidden"><td class="indent">icon.color</td> <td class="mid">String</td> <td class="mid"><code>'#2B7CE9'</code></td> <td>The color of the icon.</td></tr>
<tr><td>image</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>When the shape is set to <code>image</code> or <code>circularImage</code>, this option should be the URL to an image. If the image cannot be found, the brokenImage option can be used.</td></tr>
<tr><td>label</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>The label is the piece of text shown in or under the node, depending on the shape.</td></tr>
<tr><td>level</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>When using the hierarchical layout, the level determines where the node is going to be positioned.</td></tr>
<tr><td>mass</td> <td class="mid">Number</td> <td class="mid"><code>1</code></td> <td>The barnesHut physics model (which is enabled by default) is based on an inverted gravity model. By increasing the mass of a node, you increase it's repulsion. Values lower than 1 are not recommended.</td></tr>
<tr><td>physics</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>When false, the node is not part of the physics simulation. It will not move except for from manual dragging.</td></tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','scaling', this);"><td><span parent="scaling" class="right-caret"></span> scaling</td> <td class="mid">Object</td> <td class="mid"><code>Object</code></td> <td>If the <code>value</code> option is specified, the size of the nodes will be scaled according to the properties in this object. All node shapes can be scaled, but some only when label scaling is enabled as their size is based on the size of the label.
Only scalable when label scaling is enabled are:
<code>ellipse</code>, <code>circle</code>, <code>database</code>, <code>box</code>, <code>text</code>.
Always scalable are:
<code>image</code>, <code>circularImage</code>, <code>diamond</code>, <code>dot</code>,
<code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and <code>icon</code>. Keep in mind that when using scaling, the <code>size</code> option is neglected.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent">scaling.min</td> <td class="mid">Number</td> <td class="mid"><code>10</code></td> <td>If nodes have a value, their sizes are determined by the value, the scaling function and the min max values. The min value is the minimum allowed value.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent">scaling.max</td> <td class="mid">Number</td> <td class="mid"><code>30</code></td> <td>This is the maximum allowed size when the nodes are scaled using the value option.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent">scaling.label</td> <td class="mid">Object or Boolean</td><td class="mid"><code>Object</code></td><td>This can be false if the label is not allowed to scale with the node. If true it will scale using default settigns. For further customization, you can supply an object.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent2">scaling.label.enabled</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>Toggle the scaling of the label on or off. If this option is not defined, it is set to true if any of the properties in this object are defined.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent2">scaling.label.min</td> <td class="mid">Number</td> <td class="mid"><code>14</code></td> <td>The minimum font-size used for labels when scaling.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent2">scaling.label.max</td> <td class="mid">Number</td> <td class="mid"><code>30</code></td> <td>The maximum font-size used for labels when scaling.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent2">scaling.label.maxVisible</td><td class="mid">Number</td> <td class="mid"><code>30</code></td> <td>When zooming in, the font is drawn larger as well. You can limit the perceived font size using this option. If set to 30, the font will never look larger than size 30 zoomed at 100%.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent2">scaling.label.drawThreshold</td><td class="mid">Number</td> <td class="mid"><code>3</code></td> <td>When zooming out, the font will be drawn smaller. This defines a lower limit for when the font is drawn. When using font scaling, you can use this together with the maxVisible to first show labels of important nodes when zoomed out and only show the rest when zooming in.</td></tr>
<tr parent="scaling" class="hidden"><td class="indent">scaling.customScalingFunction</td> <td class="mid">Function</td> <td class="mid">in description</td> <td>If nodes have <code>value</code> fields, this function determines how the size of the nodes are scaled based on their values. The default function is:
<tr>
<td>borderWidth</td>
<td class="mid">Number</td>
<td class="mid"><code>1</code></td>
<td>The width of the border of the node.</td>
</tr>
<tr>
<td>borderWidthSelected</td>
<td class="mid">Number</td>
<td class="mid"><code>undefined</code></td>
<td>The width of the border of the node when it is selected. When undefined, the borderWidth is used</td>
</tr>
<tr>
<td>brokenImage</td>
<td class="mid">String</td>
<td class="mid"><code>undefined</code></td>
<td>When the shape is set to <code>image</code> or <code>circularImage</code>, this option can be an URL to
a backup image in case the URL supplied in the image option cannot be resolved.
</td>
</tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','color', this);">
<td><span parent="color" class="right-caret"></span> color</td>
<td class="mid">Object or String</td>
<td class="mid"><code>Object</code></td>
<td>The color object contains the color information of the node in every situation. When the node only needs
a single color, a color value like <code>'rgba(120,32,14,1)'</code>, <code>'#ffffff'</code> or <code>'red'</code>
can be supplied instead of an object.
</td>
</tr>
<tr parent="color" class="hidden">
<td class="indent">color.border</td>
<td class="mid">String</td>
<td class="mid"><code>'#2B7CE9'</code></td>
<td>The color of the border of the node when it is not selected or hovered over <i>(assuming hover is
enabled in the interaction module)</i>.
</td>
</tr>
<tr parent="color" class="hidden">
<td class="indent">color.background</td>
<td class="mid">String</td>
<td class="mid"><code>'#D2E5FF'</code></td>
<td>The color of the background of the node when it is not selected or hovered over <i>(assuming hover is
enabled in the interaction module)</i>.
</td>
</tr>
<tr parent="color" class="hidden">
<td class="indent">color.highlight</td>
<td class="mid">Object or String</td>
<td class="mid"><code>Object</code></td>
<td>The color the node when it is selected. Alternatively you can just supply a string color value.</td>
</tr>
<tr parent="color" class="hidden">
<td class="indent2">color.highlight.border</td>
<td class="mid">String</td>
<td class="mid"><code>'#2B7CE9'</code></td>
<td>The color of the border of the node when it is selected.</td>
</tr>
<tr parent="color" class="hidden">
<td class="indent2">color.highlight.background</td>
<td class="mid">String</td>
<td class="mid"><code>'#D2E5FF'</code></td>
<td>The color of the background of the node when it is selected.</td>
</tr>
<tr parent="color" class="hidden">
<td class="indent">color.hover</td>
<td class="mid">Object or String</td>
<td class="mid"><code>Object</code></td>
<td>The color the node when the mouse hovers over it <i>(assuming hover is enabled in the interaction
module)</i>. Shorthand like above is also supported.
</td>
</tr>
<tr parent="color" class="hidden">
<td class="indent2">color.hover.border</td>
<td class="mid">String</td>
<td class="mid"><code>'#2B7CE9'</code></td>
<td>The color of the border of the node when the mouse hovers over it <i>(assuming hover is enabled in the
interaction module)</i>.
</td>
</tr>
<tr parent="color" class="hidden">
<td class="indent2">color.hover.background</td>
<td class="mid">String</td>
<td class="mid"><code>'#D2E5FF'</code></td>
<td>The color of the background of the node when the mouse hovers over it <i>(assuming hover is enabled in
the interaction module)</i>.
</td>
</tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','fixed', this);">
<td><span parent="fixed" class="right-caret"></span> fixed</td>
<td class="mid">Object or Boolean</td>
<td class="mid"><code>Object</code></td>
<td>When true, the node will not move but IS part of the physics simulation. When defined as an object,
movement in either X or Y direction can be disabled.
</td>
</tr>
<tr parent="fixed" class="hidden">
<td class="indent">fixed.x</td>
<td class="mid">Boolean</td>
<td class="mid"><code>false</code></td>
<td>When true, the node will not move in the X direction.</td>
</tr>
<tr parent="fixed" class="hidden">
<td class="indent">fixed.y</td>
<td class="mid">Boolean</td>
<td class="mid"><code>false</code></td>
<td>When true, the node will not move in the Y direction.</td>
</tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','font', this);">
<td><span parent="font" class="right-caret"></span> font</td>
<td class="mid">Object or String</td>
<td class="mid"><code>false</code></td>
<td>This object defines the details of the label. A shorthand is also supported in the form <code>'size face
color'</code> for example: <code>'14px arial red'</code>.
</td>
</tr>
<tr parent="font" class="hidden">
<td class="indent">font.color</td>
<td class="mid">String</td>
<td class="mid"><code>'#343434'</code></td>
<td>Color of the label text.</td>
</tr>
<tr parent="font" class="hidden">
<td class="indent">font.size</td>
<td class="mid">Number</td>
<td class="mid"><code>14</code></td>
<td>Size of the label text.</td>
</tr>
<tr parent="font" class="hidden">
<td class="indent">font.face</td>
<td class="mid">String</td>
<td class="mid"><code>'arial'</code></td>
<td>Font face (or font family) of the label text.</td>
</tr>
<tr parent="font" class="hidden">
<td class="indent">font.background</td>
<td class="mid">String</td>
<td class="mid"><code>undefined</code></td>
<td>When not <code>undefined</code> but a <b>color string</b>, a background rectangle will be drawn behind
the label in the supplied color.
</td>
</tr>
<tr parent="font" class="hidden">
<td class="indent">font.stroke</td>
<td class="mid">Number</td>
<td class="mid"><code>0</code></td>
<td>As an alternative to the background rectangle, a stroke can be drawn around the text. When a value
higher than 0 is supplied, the stroke will be drawn.
</td>
</tr>
<tr parent="font" class="hidden">
<td class="indent">font.strokeColor</td>
<td class="mid">String</td>
<td class="mid"><code>'#ffffff'</code></td>
<td>This is the color of the stroke <i>assuming the value for stroke is higher than 0</i>.</td>
</tr>
<tr>
<td>group</td>
<td class="mid">String</td>
<td class="mid"><code>undefined</code></td>
<td>When not <code>undefined</code>, the</td>
</tr>
<tr>
<td>hidden</td>
<td class="mid">Boolean</td>
<td class="mid"><code>false</code></td>
<td>When true, the node will not be shown. It will still be part of the physics simulation though!</td>
</tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','icon', this);">
<td><span parent="icon" class="right-caret"></span> icon</td>
<td class="mid">Object</td>
<td class="mid"><code>Object</code></td>
<td>These options are only used when the shape is set to <code>icon</code>.</td>
</tr>
<tr parent="icon" class="hidden">
<td class="indent">icon.face</td>
<td class="mid">String</td>
<td class="mid"><code>'FontAwesome'</code></td>
<td>These options are only used when the shape is set to <code>icon</code>. The possible options for the
face are: <code>'FontAwesome'</code> and <code>'Ionicons'</code>.
</td>
</tr>
<tr parent="icon" class="hidden">
<td class="indent">icon.code</td>
<td class="mid">String</td>
<td class="mid"><code>undefined</code></td>
<td>This is the code of the icon, for example <code>'\uf007'</code>.</td>
</tr>
<tr parent="icon" class="hidden">
<td class="indent">icon.size</td>
<td class="mid">Number</td>
<td class="mid"><code>50</code></td>
<td>The size of the icon.</td>
</tr>
<tr parent="icon" class="hidden">
<td class="indent">icon.color</td>
<td class="mid">String</td>
<td class="mid"><code>'#2B7CE9'</code></td>
<td>The color of the icon.</td>
</tr>
<tr>
<td>image</td>
<td class="mid">String</td>
<td class="mid"><code>undefined</code></td>
<td>When the shape is set to <code>image</code> or <code>circularImage</code>, this option should be the URL
to an image. If the image cannot be found, the brokenImage option can be used.
</td>
</tr>
<tr>
<td>label</td>
<td class="mid">String</td>
<td class="mid"><code>undefined</code></td>
<td>The label is the piece of text shown in or under the node, depending on the shape.</td>
</tr>
<tr>
<td>level</td>
<td class="mid">Number</td>
<td class="mid"><code>undefined</code></td>
<td>When using the hierarchical layout, the level determines where the node is going to be positioned.</td>
</tr>
<tr>
<td>mass</td>
<td class="mid">Number</td>
<td class="mid"><code>1</code></td>
<td>The barnesHut physics model (which is enabled by default) is based on an inverted gravity model. By
increasing the mass of a node, you increase it's repulsion. Values lower than 1 are not recommended.
</td>
</tr>
<tr>
<td>physics</td>
<td class="mid">Boolean</td>
<td class="mid"><code>true</code></td>
<td>When false, the node is not part of the physics simulation. It will not move except for from manual
dragging.
</td>
</tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','scaling', this);">
<td><span parent="scaling" class="right-caret"></span> scaling</td>
<td class="mid">Object</td>
<td class="mid"><code>Object</code></td>
<td>If the <code>value</code> option is specified, the size of the nodes will be scaled according to the
properties in this object. All node shapes can be scaled, but some only when label scaling is enabled as
their size is based on the size of the label.
Only scalable when label scaling is enabled are:
<code>ellipse</code>, <code>circle</code>, <code>database</code>, <code>box</code>, <code>text</code>.
Always scalable are:
<code>image</code>, <code>circularImage</code>, <code>diamond</code>, <code>dot</code>,
<code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and
<code>icon</code>. Keep in mind that when using scaling, the <code>size</code> option is neglected.
</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent">scaling.min</td>
<td class="mid">Number</td>
<td class="mid"><code>10</code></td>
<td>If nodes have a value, their sizes are determined by the value, the scaling function and the min max
values. The min value is the minimum allowed value.
</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent">scaling.max</td>
<td class="mid">Number</td>
<td class="mid"><code>30</code></td>
<td>This is the maximum allowed size when the nodes are scaled using the value option.</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent">scaling.label</td>
<td class="mid">Object or Boolean</td>
<td class="mid"><code>Object</code></td>
<td>This can be false if the label is not allowed to scale with the node. If true it will scale using
default settigns. For further customization, you can supply an object.
</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent2">scaling.label.enabled</td>
<td class="mid">Boolean</td>
<td class="mid"><code>false</code></td>
<td>Toggle the scaling of the label on or off. If this option is not defined, it is set to true if any of
the properties in this object are defined.
</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent2">scaling.label.min</td>
<td class="mid">Number</td>
<td class="mid"><code>14</code></td>
<td>The minimum font-size used for labels when scaling.</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent2">scaling.label.max</td>
<td class="mid">Number</td>
<td class="mid"><code>30</code></td>
<td>The maximum font-size used for labels when scaling.</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent2">scaling.label.maxVisible</td>
<td class="mid">Number</td>
<td class="mid"><code>30</code></td>
<td>When zooming in, the font is drawn larger as well. You can limit the perceived font size using this
option. If set to 30, the font will never look larger than size 30 zoomed at 100%.
</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent2">scaling.label.drawThreshold</td>
<td class="mid">Number</td>
<td class="mid"><code>3</code></td>
<td>When zooming out, the font will be drawn smaller. This defines a lower limit for when the font is drawn.
When using font scaling, you can use this together with the maxVisible to first show labels of important
nodes when zoomed out and only show the rest when zooming in.
</td>
</tr>
<tr parent="scaling" class="hidden">
<td class="indent">scaling.customScalingFunction</td>
<td class="mid">Function</td>
<td class="mid">in description</td>
<td>If nodes have <code>value</code> fields, this function determines how the size of the nodes are scaled
based on their values. The default function is:
<pre> <pre>
function (min,max,total,value) { function (min,max,total,value) {
if (max === min) { if (max === min) {
@ -136,42 +426,192 @@ function (min,max,total,value) {
} }
} }
</pre> </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. <b>It has to return a value between 0 and 1.</b> The nodes and edges then calculate their size as follows:
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. <b>It has to return a value between 0 and 1.</b> The
nodes and edges then calculate their size as follows:
<pre> <pre>
var scale = customScalingFunction(min,max,total,value); var scale = customScalingFunction(min,max,total,value);
var diff = maxSize - minSize; var diff = maxSize - minSize;
mySize = minSize + diff * scale; mySize = minSize + diff * scale;
</pre> </pre>
</td></tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','shadow', this);"><td><span parent="shadow" class="right-caret"></span> shadow</td> <td class="mid">Object or Boolean</td> <td class="mid"><code>Object</code></td><td>When true, the node casts a shadow using the default settings. This can be further refined by supplying an object.</td></tr>
<tr parent="shadow" class="hidden"><td class="indent">shadow.enabled</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>Toggle the casting of shadows. If this option is not defined, it is set to true if any of the properties in this object are defined.</td></tr>
<tr parent="shadow" class="hidden"><td class="indent">shadow.size</td> <td class="mid">Number</td> <td class="mid"><code>10</code></td> <td>The blur size of the shadow.</td></tr>
<tr parent="shadow" class="hidden"><td class="indent">shadow.x</td> <td class="mid">Number</td> <td class="mid"><code>5</code></td> <td>The x offset.</td></tr>
<tr parent="shadow" class="hidden"><td class="indent">shadow.y</td> <td class="mid">Number</td> <td class="mid"><code>5</code></td> <td>The y offset.</td></tr>
<tr><td>shape</td> <td class="mid">String</td> <td class="mid"><code>'ellipse'</code></td> <td>The shape defines what the node looks like. There are two types of nodes. One type has the label inside of it and the other type has the label underneath it. The types with the label inside of it are:
<code>ellipse</code>, <code>circle</code>, <code>database</code>, <code>box</code>, <code>text</code>.
The ones with the label outside of it are: <code>image</code>, <code>circularImage</code>, <code>diamond</code>, <code>dot</code>, <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and <code>icon</code>.</td></tr>
<tr><td>size</td> <td class="mid">Number</td> <td class="mid"><code>25</code></td> <td>The size is used to determine the size of node shapes that do not have the label inside of them. These shapes are: <code>image</code>, <code>circularImage</code>, <code>diamond</code>, <code>dot</code>,
<code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and <code>icon</code></td></tr>
<tr><td>title</td> <td class="mid">String or Element</td> <td class="mid"><code>undefined</code></td> <td>Title to be displayed when the user hovers over the node. The title can be an HTML element or a string containing plain text or HTML.</td></tr>
<tr><td>value</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>When a value is set, the nodes will be scaled using the options in the scaling object defined above.</td></tr>
<tr><td>x</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>This gives a node an initial x position. When using the hierarchical layout, either the x or y position is set by the layout engine depending on the type of view. The other value remains untouched. When using stabilization, the stabilized position may be different from the initial one. To lock the node to that position use the physics or fixed options.</td></tr>
<tr><td>y</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>This gives a node an initial y position. When using the hierarchical layout, either the x or y position is set by the layout engine depending on the type of view. The other value remains untouched. When using stabilization, the stabilized position may be different from the initial one. To lock the node to that position use the physics or fixed options.</td></tr>
</td>
</tr>
<tr class='toggle collapsible' onclick="toggleTable('optionTable','shadow', this);">
<td><span parent="shadow" class="right-caret"></span> shadow</td>
<td class="mid">Object or Boolean</td>
<td class="mid"><code>Object</code></td>
<td>When true, the node casts a shadow using the default settings. This can be further refined by supplying
an object.
</td>
</tr>
<tr parent="shadow" class="hidden">
<td class="indent">shadow.enabled</td>
<td class="mid">Boolean</td>
<td class="mid"><code>false</code></td>
<td>Toggle the casting of shadows. If this option is not defined, it is set to true if any of the properties
in this object are defined.
</td>
</tr>
<tr parent="shadow" class="hidden">
<td class="indent">shadow.size</td>
<td class="mid">Number</td>
<td class="mid"><code>10</code></td>
<td>The blur size of the shadow.</td>
</tr>
<tr parent="shadow" class="hidden">
<td class="indent">shadow.x</td>
<td class="mid">Number</td>
<td class="mid"><code>5</code></td>
<td>The x offset.</td>
</tr>
<tr parent="shadow" class="hidden">
<td class="indent">shadow.y</td>
<td class="mid">Number</td>
<td class="mid"><code>5</code></td>
<td>The y offset.</td>
</tr>
<tr>
<td>shape</td>
<td class="mid">String</td>
<td class="mid"><code>'ellipse'</code></td>
<td>The shape defines what the node looks like. There are two types of nodes. One type has the label inside
of it and the other type has the label underneath it. The types with the label inside of it are:
<code>ellipse</code>, <code>circle</code>, <code>database</code>, <code>box</code>, <code>text</code>.
The ones with the label outside of it are: <code>image</code>, <code>circularImage</code>,
<code>diamond</code>, <code>dot</code>, <code>star</code>, <code>triangle</code>,
<code>triangleDown</code>, <code>square</code> and <code>icon</code>.
</td>
</tr>
<tr>
<td>size</td>
<td class="mid">Number</td>
<td class="mid"><code>25</code></td>
<td>The size is used to determine the size of node shapes that do not have the label inside of them. These
shapes are: <code>image</code>, <code>circularImage</code>, <code>diamond</code>, <code>dot</code>,
<code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and
<code>icon</code></td>
</tr>
<tr>
<td>title</td>
<td class="mid">String or Element</td>
<td class="mid"><code>undefined</code></td>
<td>Title to be displayed when the user hovers over the node. The title can be an HTML element or a string
containing plain text or HTML.
</td>
</tr>
<tr>
<td>value</td>
<td class="mid">Number</td>
<td class="mid"><code>undefined</code></td>
<td>When a value is set, the nodes will be scaled using the options in the scaling object defined above.
</td>
</tr>
<tr>
<td>x</td>
<td class="mid">Number</td>
<td class="mid"><code>undefined</code></td>
<td>This gives a node an initial x position. When using the hierarchical layout, either the x or y position
is set by the layout engine depending on the type of view. The other value remains untouched. When using
stabilization, the stabilized position may be different from the initial one. To lock the node to that
position use the physics or fixed options.
</td>
</tr>
<tr>
<td>y</td>
<td class="mid">Number</td>
<td class="mid"><code>undefined</code></td>
<td>This gives a node an initial y position. When using the hierarchical layout, either the x or y position
is set by the layout engine depending on the type of view. The other value remains untouched. When using
stabilization, the stabilized position may be different from the initial one. To lock the node to that
position use the physics or fixed options.
</td>
</tr>
</table> </table>
<h3>Methods</h3> <h3>Methods</h3>
<p>The nodes module has no methods.</p> <p>The nodes module has no methods.</p>
<table class="moduleTable">
<tr class="header">
<td class="methodName">name</td>
<td>returns</td>
<td>description</td>
</tr>
<tr>
<td>getPositions(<br>&nbsp;&nbsp;&nbsp;<code><i>[Array of nodeIds]</i></code><br>)</td>
<td class="mid">Object</td>
<td>Returns the x y positions in canvas space of the nodes with the supplied nodeIds as an object:
<pre class="code">
{
nodeId1: {x: xValue, y:yValue},
nodeId2: {x: xValue, y:yValue},
...
}
</pre>
Alternative inputs are a String containing a nodeId or nothing. When a String is supplied, the position
of the node corresponding to the ID is returned. When nothing is supplied, the positions of all nodes
are returned.
</td>
</tr>
<tr>
<td>storePositions()</td>
<td class="mid">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. <br><br> 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.<br><br>
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
module</a>
to improve initialization time.
</td>
</tr>
<tr>
<td>getBoundingBox(<br>&nbsp;&nbsp;&nbsp;<code><i>String nodeId</i></code><br>)</td>
<td class="mid">Object</td>
<td> Returns a bounding box for the node including label in the format:
<pre class="code">
{
top: Number,
left: Number,
right: Number,
bottom: Number
}
</pre>
These values are in canvas space.
</td>
</tr>
<tr>
<td>getConnectedNodes(<br>&nbsp;&nbsp;&nbsp;<code><i>String nodeId</i></code><br>)</td>
<td class="mid">Array</td>
<td>Returns an array of nodeIds of the all the nodes that are directly connected to this node.</td>
</tr>
<tr>
<td>getEdges(<br>&nbsp;&nbsp;&nbsp;<code><i>String nodeId</i></code><br>)</td>
<td class="mid">Array</td>
<td>Returns an array of edgeIds of the edges connected to this node.</td>
</tr>
</table>
<h3>Events</h3> <h3>Events</h3>
<p>The nodes module emits no events. Click and select events are emitted from the interaction and selection modules.</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>The nodes module emits no events. Click and select events are emitted from the interaction and selection
modules.</p>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</div> </div>
<!-- Bootstrap core JavaScript <!-- Bootstrap core JavaScript

+ 1
- 1
docs/network/physics.html View File

@ -100,7 +100,7 @@
<tr parent="stabilization" class="hidden"><td class="indent">stabilization.iterations</td> <td class="mid">Number</td> <td class="mid"><code>1000</code></td> <td>The physics module tries to stabilize the network on load up til a maximum number of iterations defined here. If the network stabilized with less, you are finished before the maximum number.</td></tr> <tr parent="stabilization" class="hidden"><td class="indent">stabilization.iterations</td> <td class="mid">Number</td> <td class="mid"><code>1000</code></td> <td>The physics module tries to stabilize the network on load up til a maximum number of iterations defined here. If the network stabilized with less, you are finished before the maximum number.</td></tr>
<tr parent="stabilization" class="hidden"><td class="indent">stabilization.updateInterval</td> <td class="mid">Number</td> <td class="mid"><code>100</code></td> <td>When stabilizing, the DOM can freeze. You can chop the stabilization up into pieces to show a loading bar for instance. The interval determines after how many iterations the <code>stabilizationProgress</code> event is triggered.</td></tr> <tr parent="stabilization" class="hidden"><td class="indent">stabilization.updateInterval</td> <td class="mid">Number</td> <td class="mid"><code>100</code></td> <td>When stabilizing, the DOM can freeze. You can chop the stabilization up into pieces to show a loading bar for instance. The interval determines after how many iterations the <code>stabilizationProgress</code> event is triggered.</td></tr>
<tr parent="stabilization" class="hidden"><td class="indent">stabilization.onlyDynamicEdges</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>If you have predefined the position of all nodes and only want to stabilize the dynamic smooth edges, set this to true. It freezes all nodes except the invisible dynamic smooth curve support nodes. If you want the visible nodes to move and stabilize, do not use this.</td></tr> <tr parent="stabilization" class="hidden"><td class="indent">stabilization.onlyDynamicEdges</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>If you have predefined the position of all nodes and only want to stabilize the dynamic smooth edges, set this to true. It freezes all nodes except the invisible dynamic smooth curve support nodes. If you want the visible nodes to move and stabilize, do not use this.</td></tr>
<tr parent="stabilization" class="hidden"><td class="indent">stabilization.zoomExtent</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle whether or not you want the view to zoom to fit all nodes when the stabilization is finished.</td></tr>
<tr parent="stabilization" class="hidden"><td class="indent">stabilization.fit</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle whether or not you want the view to zoom to fit all nodes when the stabilization is finished.</td></tr>
<tr><td>timestep</td> <td class="mid">Number</td> <td class="mid"><code>0.5</code></td> <td>The physics simulation is discrete. This means we take a step in time, calculate the forces, move the nodes and take another step. If you increase this number the steps will be too large and the network can get unstable. If you see a lot of jittery movement in the network, you may want to reduce this value a little.</td></tr> <tr><td>timestep</td> <td class="mid">Number</td> <td class="mid"><code>0.5</code></td> <td>The physics simulation is discrete. This means we take a step in time, calculate the forces, move the nodes and take another step. If you increase this number the steps will be too large and the network can get unstable. If you see a lot of jittery movement in the network, you may want to reduce this value a little.</td></tr>
</table> </table>

+ 4
- 7
docs/network/selection.html View File

@ -24,11 +24,6 @@
smoothScroll.init(); smoothScroll.init();
</script> </script>
<style>
td.method {
width:250px;
}
</style>
</head> </head>
<!-- NAVBAR <!-- NAVBAR
================================================== --> ================================================== -->
@ -81,7 +76,7 @@
<h3>Methods</h3> <h3>Methods</h3>
<p>This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.</p> <p>This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.</p>
<table class="moduleTable"> <table class="moduleTable">
<tr class="header"><td class="method">name</td><td>returns</td><td>description</td></tr>
<tr class="header"><td class="methodName">name</td><td>returns</td><td>description</td></tr>
<tr><td>getSelection()</td> <td class="mid"> <tr><td>getSelection()</td> <td class="mid">
<pre class="code"> <pre class="code">
{ {
@ -91,13 +86,15 @@
<tr><td>getSelectedNodes()</td> <td class="mid"><code>[nodeId1, nodeId2, ..]</code></td><td>Returns an array of selected node ids.</td></tr> <tr><td>getSelectedNodes()</td> <td class="mid"><code>[nodeId1, nodeId2, ..]</code></td><td>Returns an array of selected node ids.</td></tr>
<tr><td>getSelectedEdges()</td> <td class="mid"><code>[edgeId1, edgeId2, ..]</code></td><td>Returns an array of selected edge ids.</td></tr> <tr><td>getSelectedEdges()</td> <td class="mid"><code>[edgeId1, edgeId2, ..]</code></td><td>Returns an array of selected edge ids.</td></tr>
<tr><td>getNodeAt(<br>&nbsp;&nbsp;&nbsp;<code><i>{x: xPosition DOM,<br>&nbsp;&nbsp; y: yPosition DOM}</i></code><br>)</td> <td class="mid">nodeId</td><td>Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left corner of the canvas.</td></tr>
<tr><td>getEdgeAt(<br>&nbsp;&nbsp;&nbsp;<code><i>{x: xPosition DOM,<br>&nbsp;&nbsp; y: yPosition DOM}</i></code><br>)</td> <td class="mid">edgeId</code></td><td>Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left corner of the canvas..</td></tr>
<tr><td>selectNodes(<br>&nbsp;&nbsp;&nbsp;<code><i>Array with nodeIds</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>[Boolean highlightEdges]</i></code><br>)</td> <td class="mid">none</td><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 its own objects. <i>Does not fire events</i>.</td></tr> <tr><td>selectNodes(<br>&nbsp;&nbsp;&nbsp;<code><i>Array with nodeIds</i></code>,<br>&nbsp;&nbsp;&nbsp;<code><i>[Boolean highlightEdges]</i></code><br>)</td> <td class="mid">none</td><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 its own objects. <i>Does not fire events</i>.</td></tr>
<tr><td>selectEdges(<br>&nbsp;&nbsp;&nbsp;<code><i>Array with edgeIds</i></code><br>)</td> <td class="mid">none</td><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>.</td></tr> <tr><td>selectEdges(<br>&nbsp;&nbsp;&nbsp;<code><i>Array with edgeIds</i></code><br>)</td> <td class="mid">none</td><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>.</td></tr>
<tr><td>unselectAll()</td> <td class="mid">none</td> <td>Unselect all objects. <i>Does not fire events</i>.</td></tr> <tr><td>unselectAll()</td> <td class="mid">none</td> <td>Unselect all objects. <i>Does not fire events</i>.</td></tr>
</table> </table>
<h3>Events</h3> <h3>Events</h3>
<p>The selection handler does not fire events. All related events are fired by the interaction module because they are triggered by user interaction.</p>
<p>The selection handler does not fire events. All related events are fired by the <a href="./interaction.html">interaction module</a> because they are triggered by user interaction.</p>
<br /> <br />
<br /> <br />

+ 15
- 18
docs/network/view.html View File

@ -24,11 +24,7 @@
smoothScroll.init(); smoothScroll.init();
</script> </script>
<style>
td.method {
width:250px;
}
</style>
</head> </head>
<!-- NAVBAR <!-- NAVBAR
================================================== --> ================================================== -->
@ -77,9 +73,21 @@
<h3>Methods</h3> <h3>Methods</h3>
<p>This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.</p> <p>This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.</p>
<table class="moduleTable"> <table class="moduleTable">
<tr class="header"><td class="method">name</td><td>returns</td><td>description</td></tr>
<tr class="header"><td class="methodName">name</td><td>returns</td><td>description</td></tr>
<tr><td>getScale()</td> <td class="mid">Number</td><td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.</td></tr> <tr><td>getScale()</td> <td class="mid">Number</td><td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.</td></tr>
<tr><td>getPosition()</td> <td class="mid">Number</td><td>Returns the current central focus point of the camera.</td></tr> <tr><td>getPosition()</td> <td class="mid">Number</td><td>Returns the current central focus point of the camera.</td></tr>
<tr><td>fit(<code>[Object options]</code>)</td><td class="mid">none</td><td>Zooms out so all nodes fit on the canvas. You can supply options to customize this:
<pre class="code">
{
nodes:[Array of nodeIds],
duration: Number,
easingFunction: String
}
</pre>
The nodes can be used to zoom to fit only specific nodes in the view. <br /><br />
The other options are explained in the <code>moveTo()</code> description above.
All options are optional for zoomExtent.
</td></tr>
<tr><td>moveTo(<code>Object options</code>)</td> <td class="mid">none</td><td>You can animate or move the camera using the moveTo method. Options are: <tr><td>moveTo(<code>Object options</code>)</td> <td class="mid">none</td><td>You can animate or move the camera using the moveTo method. Options are:
<pre class="code"> <pre class="code">
{ {
@ -99,18 +107,7 @@
<code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint</code>. <br><br> <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, 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></tr> </td></tr>
<tr><td>zoomExtent(<code>[Object options]</code>)</td><td class="mid">none</td><td>Zooms out so all nodes fit on the canvas. You can supply options to customize this:
<pre class="code">
{
nodes:[Array of nodeIds],
duration: Number,
easingFunction: String
}
</pre>
The nodes can be used to zoom to fit only specific nodes in the view. <br /><br />
The other options are explained in the <code>moveTo()</code> description above.
All options are optional for zoomExtent.
</td></tr>
<tr><td>focusOnNode(<br> <tr><td>focusOnNode(<br>
&nbsp;&nbsp;&nbsp;<code>String nodeId</code>,<br> &nbsp;&nbsp;&nbsp;<code>String nodeId</code>,<br>

+ 1
- 5
examples/network/01_basic_usage.html View File

@ -44,11 +44,7 @@
edges: edges edges: edges
}; };
var options = { var options = {
// manipulation: {
// handlerFunctions:{
// editEdge: function (data,callback) {console.log("h12ere");setTimeout(function() {callback(null)},1000);}
// }
// },
manipulation: true,
groups:{'bla':{color:{background:'red'}, borderWidth:5}} groups:{'bla':{color:{background:'red'}, borderWidth:5}}
// physics:{stabilization:true} // physics:{stabilization:true}

+ 3
- 119
lib/network/Network.js View File

@ -290,14 +290,15 @@ Network.prototype.setData = function(data) {
*/ */
Network.prototype.destroy = function() { Network.prototype.destroy = function() {
this.body.emitter.emit("destroy"); this.body.emitter.emit("destroy");
// clear events // clear events
this.body.emitter.off(); this.body.emitter.off();
this.off();
// remove the container and everything inside it recursively // remove the container and everything inside it recursively
util.recursiveDOMDelete(this.body.container); util.recursiveDOMDelete(this.body.container);
};
};
/** /**
@ -337,59 +338,6 @@ Network.prototype._updateValueRange = function(obj) {
}; };
/**
* Load the XY positions of the nodes into the dataset.
*/
Network.prototype.storePositions = function() {
// todo: incorporate fixed instead of allowedtomove, add support for clusters and hierarchical.
var dataArray = [];
for (var nodeId in this.body.nodes) {
if (this.body.nodes.hasOwnProperty(nodeId)) {
var node = this.body.nodes[nodeId];
var allowedToMoveX = !this.body.nodes.xFixed;
var allowedToMoveY = !this.body.nodes.yFixed;
if (this.body.data.nodes._data[nodeId].x != Math.round(node.x) || this.body.data.nodes._data[nodeId].y != Math.round(node.y)) {
dataArray.push({id:nodeId,x:Math.round(node.x),y:Math.round(node.y),allowedToMoveX:allowedToMoveX,allowedToMoveY:allowedToMoveY});
}
}
}
this.body.data.nodes.update(dataArray);
};
/**
* Return the positions of the nodes.
*/
Network.prototype.getPositions = function(ids) {
var dataArray = {};
if (ids !== undefined) {
if (Array.isArray(ids) === true) {
for (var i = 0; i < ids.length; i++) {
if (this.body.nodes[ids[i]] !== undefined) {
var node = this.body.nodes[ids[i]];
dataArray[ids[i]] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
else {
if (this.body.nodes[ids] !== undefined) {
var node = this.body.nodes[ids];
dataArray[ids] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
else {
for (var nodeId in this.body.nodes) {
if (this.body.nodes.hasOwnProperty(nodeId)) {
var node = this.body.nodes[nodeId];
dataArray[nodeId] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
return dataArray;
};
/** /**
* Returns true when the Network is active. * Returns true when the Network is active.
* @returns {boolean} * @returns {boolean}
@ -398,68 +346,4 @@ Network.prototype.isActive = function () {
return !this.activator || this.activator.active; return !this.activator || this.activator.active;
}; };
/**
* Check if a node is a cluster.
* @param nodeId
* @returns {*}
*/
Network.prototype.isCluster = function(nodeId) {
if (this.body.nodes[nodeId] !== undefined) {
return this.body.nodes[nodeId].isCluster;
}
else {
console.log("Node does not exist.")
return false;
}
};
Network.prototype.getBoundingBox = function(nodeId) {
if (this.body.nodes[nodeId] !== undefined) {
return this.body.nodes[nodeId].boundingBox;
}
}
Network.prototype.getConnectedNodes = function(nodeId) {
var nodeList = [];
if (this.body.nodes[nodeId] !== undefined) {
var node = this.body.nodes[nodeId];
var nodeObj = {nodeId : true}; // used to quickly check if node already exists
for (var i = 0; i < node.edges.length; i++) {
var edge = node.edges[i];
if (edge.toId === nodeId) {
if (nodeObj[edge.fromId] === undefined) {
nodeList.push(edge.fromId);
nodeObj[edge.fromId] = true;
}
}
else if (edge.fromId === nodeId) {
if (nodeObj[edge.toId] === undefined) {
nodeList.push(edge.toId)
nodeObj[edge.toId] = true;
}
}
}
}
return nodeList;
}
Network.prototype.getEdgesFromNode = function(nodeId) {
var edgesList = [];
if (this.body.nodes[nodeId] !== undefined) {
var node = this.body.nodes[nodeId];
for (var i = 0; i < node.edges.length; i++) {
edgesList.push(node.edges[i].id);
}
}
return edgesList;
}
Network.prototype.generateColorObject = function(color) {
return util.parseColor(color);
}
module.exports = Network; module.exports = Network;

+ 3
- 0
lib/network/modules/ManipulationSystem.js View File

@ -60,6 +60,9 @@ class ManipulationSystem {
} }
} }
util.extend(this.options, this.defaultOptions); util.extend(this.options, this.defaultOptions);
this.body.emitter.on("destroy", () => {this._clean()});
this.body.emitter.on("_resetData", () => {this._clean()});
} }

+ 135
- 22
lib/network/modules/NodesHandler.js View File

@ -1,6 +1,6 @@
var util = require("../../util");
var DataSet = require('../../DataSet');
var DataView = require('../../DataView');
let util = require("../../util");
let DataSet = require('../../DataSet');
let DataView = require('../../DataView');
import Node from "./components/Node"; import Node from "./components/Node";
import Label from "./components/shared/Label"; import Label from "./components/shared/Label";
@ -80,7 +80,7 @@ class NodesHandler {
return 0.5; return 0.5;
} }
else { else {
var scale = 1 / (max - min);
let scale = 1 / (max - min);
return Math.max(0,(value - min)*scale); return Math.max(0,(value - min)*scale);
} }
} }
@ -135,7 +135,7 @@ class NodesHandler {
} }
} }
// update the state of the variables if needed
// update the state of the letiables if needed
if (options.hidden !== undefined || options.physics !== undefined) { if (options.hidden !== undefined || options.physics !== undefined) {
this.body.emitter.emit('_dataChanged'); this.body.emitter.emit('_dataChanged');
} }
@ -148,7 +148,7 @@ class NodesHandler {
* @private * @private
*/ */
setData(nodes, doNotEmit = false) { setData(nodes, doNotEmit = false) {
var oldNodesData = this.body.data.nodes;
let oldNodesData = this.body.data.nodes;
if (nodes instanceof DataSet || nodes instanceof DataView) { if (nodes instanceof DataSet || nodes instanceof DataView) {
this.body.data.nodes = nodes; this.body.data.nodes = nodes;
@ -176,13 +176,13 @@ class NodesHandler {
if (this.body.data.nodes) { if (this.body.data.nodes) {
// subscribe to new dataset // subscribe to new dataset
var me = this;
let me = this;
util.forEach(this.nodesListeners, function (callback, event) { util.forEach(this.nodesListeners, function (callback, event) {
me.body.data.nodes.on(event, callback); me.body.data.nodes.on(event, callback);
}); });
// draw all new nodes // draw all new nodes
var ids = this.body.data.nodes.getIds();
let ids = this.body.data.nodes.getIds();
this.add(ids, true); this.add(ids, true);
} }
@ -198,12 +198,12 @@ class NodesHandler {
* @private * @private
*/ */
add(ids, doNotEmit = false) { add(ids, doNotEmit = false) {
var id;
var newNodes = [];
for (var i = 0; i < ids.length; i++) {
let id;
let newNodes = [];
for (let i = 0; i < ids.length; i++) {
id = ids[i]; id = ids[i];
var properties = this.body.data.nodes.get(id);
var node = this.create(properties);;
let properties = this.body.data.nodes.get(id);
let node = this.create(properties);;
newNodes.push(node); newNodes.push(node);
this.body.nodes[id] = node; // note: this may replace an existing node this.body.nodes[id] = node; // note: this may replace an existing node
} }
@ -221,12 +221,12 @@ class NodesHandler {
* @private * @private
*/ */
update(ids, changedData) { update(ids, changedData) {
var nodes = this.body.nodes;
var dataChanged = false;
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
var node = nodes[id];
var data = changedData[i];
let nodes = this.body.nodes;
let dataChanged = false;
for (let i = 0; i < ids.length; i++) {
let id = ids[i];
let node = nodes[id];
let data = changedData[i];
if (node !== undefined) { if (node !== undefined) {
// update node // update node
node.setOptions(data, this.constants); node.setOptions(data, this.constants);
@ -253,10 +253,10 @@ class NodesHandler {
* @private * @private
*/ */
remove(ids) { remove(ids) {
var nodes = this.body.nodes;
let nodes = this.body.nodes;
for (let i = 0; i < ids.length; i++) { for (let i = 0; i < ids.length; i++) {
var id = ids[i];
let id = ids[i];
delete nodes[id]; delete nodes[id];
} }
@ -264,12 +264,125 @@ class NodesHandler {
} }
/**
* create a node
* @param properties
* @param constructorClass
*/
create(properties, constructorClass = Node) { create(properties, constructorClass = Node) {
return new constructorClass(properties, this.body, this.images, this.groups, this.options) return new constructorClass(properties, this.body, this.images, this.groups, this.options)
} }
/**
* Returns the positions of the nodes.
* @param ids --> optional, can be array of nodeIds, can be string
* @returns {{}}
*/
getPositions(ids) {
let dataArray = {};
if (ids !== undefined) {
if (Array.isArray(ids) === true) {
for (let i = 0; i < ids.length; i++) {
if (this.body.nodes[ids[i]] !== undefined) {
let node = this.body.nodes[ids[i]];
dataArray[ids[i]] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
else {
if (this.body.nodes[ids] !== undefined) {
let node = this.body.nodes[ids];
dataArray[ids] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
else {
for (let nodeId in this.body.nodes) {
if (this.body.nodes.hasOwnProperty(nodeId)) {
let node = this.body.nodes[nodeId];
dataArray[nodeId] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
return dataArray;
}
/**
* Load the XY positions of the nodes into the dataset.
*/
storePositions() {
// todo: add support for clusters and hierarchical.
let dataArray = [];
for (let nodeId in this.body.nodes) {
if (this.body.nodes.hasOwnProperty(nodeId)) {
let node = this.body.nodes[nodeId];
if (this.body.data.nodes._data[nodeId].x != Math.round(node.x) || this.body.data.nodes._data[nodeId].y != Math.round(node.y)) {
dataArray.push({id:nodeId,x:Math.round(node.x),y:Math.round(node.y)});
}
}
}
this.body.data.nodes.update(dataArray);
}
/**
* get the bounding box of a node.
* @param nodeId
* @returns {j|*}
*/
getBoundingBox(nodeId) {
if (this.body.nodes[nodeId] !== undefined) {
return this.body.nodes[nodeId].shape.boundingBox;
}
}
/**
* Get the Ids of nodes connected to this node.
* @param nodeId
* @returns {Array}
*/
getConnectedNodes(nodeId) {
let nodeList = [];
if (this.body.nodes[nodeId] !== undefined) {
let node = this.body.nodes[nodeId];
let nodeObj = {}; // used to quickly check if node already exists
for (let i = 0; i < node.edges.length; i++) {
let edge = node.edges[i];
if (edge.toId === nodeId) {
if (nodeObj[edge.fromId] === undefined) {
nodeList.push(edge.fromId);
nodeObj[edge.fromId] = true;
}
}
else if (edge.fromId === nodeId) {
if (nodeObj[edge.toId] === undefined) {
nodeList.push(edge.toId)
nodeObj[edge.toId] = true;
}
}
}
}
return nodeList;
}
/**
* Get the ids of the edges connected to this node.
* @param nodeId
* @returns {*}
*/
getEdges(nodeId) {
let edgeList = [];
if (this.body.nodes[nodeId] !== undefined) {
let node = this.body.nodes[nodeId];
for (let i = 0; i < node.edges.length; i++) {
edgeList.push(node.edges[i].id)
}
}
return nodeList;
}
} }
export default NodesHandler; export default NodesHandler;

+ 4
- 4
lib/network/modules/PhysicsEngine.js View File

@ -57,7 +57,7 @@ class PhysicsEngine {
iterations: 1000, // maximum number of iteration to stabilize iterations: 1000, // maximum number of iteration to stabilize
updateInterval: 100, updateInterval: 100,
onlyDynamicEdges: false, onlyDynamicEdges: false,
zoomExtent: true
fit: true
}, },
timestep: 0.5 timestep: 0.5
} }
@ -126,7 +126,7 @@ class PhysicsEngine {
else { else {
this.stabilized = false; this.stabilized = false;
this.ready = true; this.ready = true;
this.body.emitter.emit('zoomExtent', {duration: 0}, true)
this.body.emitter.emit('fit', {duration: 0}, true)
this.startSimulation(); this.startSimulation();
} }
} }
@ -481,8 +481,8 @@ class PhysicsEngine {
_finalizeStabilization() { _finalizeStabilization() {
this.body.emitter.emit('_allowRedrawRequests'); this.body.emitter.emit('_allowRedrawRequests');
if (this.options.stabilization.zoomExtent === true) {
this.body.emitter.emit('zoomExtent', {duration:0});
if (this.options.stabilization.fit === true) {
this.body.emitter.emit('fit', {duration:0});
} }
if (this.options.stabilization.onlyDynamicEdges === true) { if (this.options.stabilization.onlyDynamicEdges === true) {

+ 14
- 4
lib/network/modules/SelectionHandler.js View File

@ -146,14 +146,19 @@ class SelectionHandler {
* @return {Node | undefined} node * @return {Node | undefined} node
* @private * @private
*/ */
getNodeAt(pointer) {
getNodeAt(pointer, returnNode = true) {
// we first check if this is an navigation controls element // we first check if this is an navigation controls element
let positionObject = this._pointerToPositionObject(pointer); let positionObject = this._pointerToPositionObject(pointer);
let overlappingNodes = this._getAllNodesOverlappingWith(positionObject); let overlappingNodes = this._getAllNodesOverlappingWith(positionObject);
// if there are overlapping nodes, select the last one, this is the // if there are overlapping nodes, select the last one, this is the
// one which is drawn on top of the others // one which is drawn on top of the others
if (overlappingNodes.length > 0) { if (overlappingNodes.length > 0) {
return this.body.nodes[overlappingNodes[overlappingNodes.length - 1]];
if (returnNode === true) {
return this.body.nodes[overlappingNodes[overlappingNodes.length - 1]];
}
else {
return overlappingNodes[overlappingNodes.length - 1];
}
} }
else { else {
return undefined; return undefined;
@ -199,12 +204,17 @@ class SelectionHandler {
* @returns {undefined} * @returns {undefined}
* @private * @private
*/ */
getEdgeAt(pointer) {
getEdgeAt(pointer, returnEdge = true) {
let positionObject = this._pointerToPositionObject(pointer); let positionObject = this._pointerToPositionObject(pointer);
let overlappingEdges = this._getAllEdgesOverlappingWith(positionObject); let overlappingEdges = this._getAllEdgesOverlappingWith(positionObject);
if (overlappingEdges.length > 0) { if (overlappingEdges.length > 0) {
return this.body.edges[overlappingEdges[overlappingEdges.length - 1]];
if (returnEdge === true) {
return this.body.edges[overlappingEdges[overlappingEdges.length - 1]];
}
else {
return overlappingEdges[overlappingEdges.length - 1];
}
} }
else { else {
return undefined; return undefined;

+ 3
- 3
lib/network/modules/View.js View File

@ -18,7 +18,7 @@ class View {
this.viewFunction = undefined; this.viewFunction = undefined;
this.body.emitter.on("zoomExtent", this.zoomExtent.bind(this));
this.body.emitter.on("fit", this.fit.bind(this));
this.body.emitter.on("animationFinished", () => {this.body.emitter.emit("_stopRendering");}); this.body.emitter.on("animationFinished", () => {this.body.emitter.emit("_stopRendering");});
this.body.emitter.on("unlockNode", this.releaseNode.bind(this)); this.body.emitter.on("unlockNode", this.releaseNode.bind(this));
} }
@ -95,7 +95,7 @@ class View {
* @param {Object} Options * @param {Object} Options
* @param {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false; * @param {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false;
*/ */
zoomExtent(options = {nodes:[]}, initialZoom = false) {
fit(options = {nodes:[]}, initialZoom = false) {
var range; var range;
var zoomLevel; var zoomLevel;
@ -111,7 +111,7 @@ class View {
} }
} }
if (positionDefined > 0.5 * this.body.nodeIndices.length) { if (positionDefined > 0.5 * this.body.nodeIndices.length) {
this.zoomExtent(options,false);
this.fit(options,false);
return; return;
} }

+ 5
- 5
lib/network/modules/components/NavigationHandler.js View File

@ -75,7 +75,7 @@ class NavigationHandler {
this.navigationDOM = {}; this.navigationDOM = {};
var navigationDivs = ['up','down','left','right','zoomIn','zoomOut','zoomExtends']; var navigationDivs = ['up','down','left','right','zoomIn','zoomOut','zoomExtends'];
var navigationDivActions = ['_moveUp','_moveDown','_moveLeft','_moveRight','_zoomIn','_zoomOut','_zoomExtent'];
var navigationDivActions = ['_moveUp','_moveDown','_moveLeft','_moveRight','_zoomIn','_zoomOut','_fit'];
this.navigationDOM['wrapper'] = document.createElement('div'); this.navigationDOM['wrapper'] = document.createElement('div');
this.navigationDOM['wrapper'].className = 'vis-navigation'; this.navigationDOM['wrapper'].className = 'vis-navigation';
@ -87,8 +87,8 @@ class NavigationHandler {
this.navigationDOM['wrapper'].appendChild(this.navigationDOM[navigationDivs[i]]); this.navigationDOM['wrapper'].appendChild(this.navigationDOM[navigationDivs[i]]);
var hammer = new Hammer(this.navigationDOM[navigationDivs[i]]); var hammer = new Hammer(this.navigationDOM[navigationDivs[i]]);
if (navigationDivActions[i] === "_zoomExtent") {
hammerUtil.onTouch(hammer, this._zoomExtent.bind(this));
if (navigationDivActions[i] === "_fit") {
hammerUtil.onTouch(hammer, this._fit.bind(this));
} }
else { else {
hammerUtil.onTouch(hammer, this.bindToRedraw.bind(this,navigationDivActions[i])); hammerUtil.onTouch(hammer, this.bindToRedraw.bind(this,navigationDivActions[i]));
@ -121,9 +121,9 @@ class NavigationHandler {
* *
* @private * @private
*/ */
_zoomExtent() {
_fit() {
if (new Date().valueOf() - this.touchTime > 700) { // TODO: fix ugly hack to avoid hammer's double fireing of event (because we use release?) if (new Date().valueOf() - this.touchTime > 700) { // TODO: fix ugly hack to avoid hammer's double fireing of event (because we use release?)
this.body.emitter.emit("zoomExtent", {duration: 700});
this.body.emitter.emit("fit", {duration: 700});
this.touchTime = new Date().valueOf(); this.touchTime = new Date().valueOf();
} }
} }

+ 1
- 1
lib/network/modules/components/Node.js View File

@ -59,7 +59,7 @@ class Node {
this.y = undefined; this.y = undefined;
this.baseSize = this.options.size; this.baseSize = this.options.size;
this.baseFontSize = this.options.font.size; this.baseFontSize = this.options.font.size;
this.predefinedPosition = false; // used to check if initial zoomExtent should just take the range or approximate
this.predefinedPosition = false; // used to check if initial fit should just take the range or approximate
this.selected = false; this.selected = false;
this.hover = false; this.hover = false;

Loading…
Cancel
Save