vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1527 lines
69 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <meta name="description" content="">
  9. <meta name="author" content="">
  10. <title>vis.js - A dynamic, browser based visualization library.</title>
  11. <!-- Bootstrap core CSS -->
  12. <link href="../css/bootstrap.css" rel="stylesheet">
  13. <link href="../css/style.css" rel="stylesheet">
  14. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  15. <!--[if lt IE 9]>
  16. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  17. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  18. <![endif]-->
  19. <link href="../css/prettify.css" type="text/css" rel="stylesheet"/>
  20. <script type="text/javascript" src="../js/googleAnalytics.js"></script>
  21. <script type="text/javascript" src="../js/prettify/prettify.js"></script>
  22. <script src="../js/smooth-scroll.min.js"></script>
  23. <script language="JavaScript">
  24. smoothScroll.init();
  25. </script>
  26. <style>
  27. tr.subHeader {
  28. font-weight: bold;
  29. font-style: italic;
  30. }
  31. tr.subHeader td {
  32. padding-top: 30px;
  33. }
  34. td.midMethods {
  35. width: 150px;
  36. background-color: #ffffff;
  37. border: 1px solid #dddddd;
  38. }
  39. tr.visible td {
  40. padding: 10px;
  41. }
  42. </style>
  43. <script>
  44. function toggleGettingStarted(aThis) {
  45. var gettingStartedDiv = document.getElementById('gettingStarted');
  46. if (aThis.innerHTML.indexOf("Show") !== -1) {
  47. gettingStartedDiv.className = '';
  48. aThis.innerHTML = 'Hide the getting started again.';
  49. }
  50. else {
  51. gettingStartedDiv.className = 'hidden';
  52. aThis.innerHTML = 'Show the getting started!';
  53. }
  54. }
  55. </script>
  56. <script type="text/javascript" src="../js/toggleTable.js"></script>
  57. </head>
  58. <body onload="prettyPrint();">
  59. <!-- NAVBAR
  60. ================================================== -->
  61. <div class="navbar-wrapper">
  62. <div class="container">
  63. <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  64. <div class="container">
  65. <div class="navbar-header">
  66. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
  67. aria-expanded="false" aria-controls="navbar">
  68. <span class="sr-only">Toggle navigation</span>
  69. <span class="icon-bar"></span>
  70. <span class="icon-bar"></span>
  71. <span class="icon-bar"></span>
  72. </button>
  73. <a class="navbar-brand hidden-sm" href="http://www.visjs.org/index.html">vis.js</a>
  74. </div>
  75. <div id="navbar" class="navbar-collapse collapse">
  76. <ul class="nav navbar-nav">
  77. <li><a href="http://www.visjs.org/index.html#modules">Modules</a></li>
  78. <li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon"
  79. src="../img/external-link-icons/external-link-icon-white.png"></a>
  80. </li>
  81. <li><a href="http://www.visjs.org/blog.html">Blog</a></li>
  82. <li><a href="http://www.visjs.org/index.html#download_install">Download</a></li>
  83. <li><a href="http://www.visjs.org/showcase/index.html">Showcase</a></li>
  84. <li><a href="http://www.visjs.org/index.html#contribute">Contribute</a></li>
  85. <li><a href="http://www.visjs.org/featureRequests.html">Feature requests</a></li>
  86. <li><a href="http://www.visjs.org/index.html#licenses">License</a></li>
  87. </ul>
  88. </div>
  89. </div>
  90. </nav>
  91. </div>
  92. </div>
  93. <a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img
  94. style="position: absolute; top: 0; right: 0; border: 0;"
  95. src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
  96. alt="Fork me on GitHub"
  97. data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
  98. <div class="container full">
  99. <h1>Network</h1>
  100. <p>Network is a visualization to display networks and networks consisting of nodes and edges. The visualization
  101. is easy to use and supports custom shapes, styles, colors, sizes, images, and more.
  102. The network visualization works smooth on any modern browser for up to a few thousand nodes and edges. To
  103. handle a larger amount of nodes, Network has clustering support. Network uses HTML canvas for rendering.</p>
  104. <p>As of 4.0, the network consists of individual modules which handle specific parts of the network. These modules
  105. have their own docs, options, methods and events which you can access
  106. by clicking on the modules in the list below.</p>
  107. <a class="btn btn-primary" role="button" onclick="toggleGettingStarted(this)">Show the getting started!</a>
  108. <div id="gettingStarted" class="hidden">
  109. <h3>Creating a Network</h3>
  110. <p>
  111. Creating a vis network is easy. <a href="http://visjs.org/#download_install" target="_blank">It requires you to
  112. include the vis.js and css files which you can get here</a>. If you have these
  113. added to your application, you will need to specify your nodes and edges. You can use DOT language or export
  114. nodes and edges from Gephi if you'd like but we will do it without these for now.
  115. For more information on this click the tabs below. You can also use the vis.DataSets for dynamic data binding,
  116. for instance, changing the color, label or any option after you have initialized the network.
  117. <br><br>
  118. Once you have the data, all you need is a container div to tell vis where to put your network. Additionally you
  119. can use an options object to customize many aspects of the network. In code this
  120. looks like this:</p>
  121. <pre class="prettyprint lang-html options">
  122. &lt;html&gt;
  123. &lt;head&gt;
  124. &lt;script type="text/javascript" src="../../dist/vis.js"&gt;&lt;/script&gt;
  125. &lt;link href="../../dist/vis.css" rel="stylesheet" type="text/css" /&gt;
  126. &lt;style type="text/css"&gt;
  127. #mynetwork {
  128. width: 600px;
  129. height: 400px;
  130. border: 1px solid lightgray;
  131. }
  132. &lt;/style&gt;
  133. &lt;/head&gt;
  134. &lt;body&gt;
  135. &lt;div id="mynetwork"&gt;&lt;/div&gt;
  136. &lt;script type="text/javascript"&gt;
  137. // create an array with nodes
  138. var nodes = new vis.DataSet([
  139. {id: 1, label: 'Node 1'},
  140. {id: 2, label: 'Node 2'},
  141. {id: 3, label: 'Node 3'},
  142. {id: 4, label: 'Node 4'},
  143. {id: 5, label: 'Node 5'}
  144. ]);
  145. // create an array with edges
  146. var edges = new vis.DataSet([
  147. {from: 1, to: 3},
  148. {from: 1, to: 2},
  149. {from: 2, to: 4},
  150. {from: 2, to: 5}
  151. ]);
  152. // create a network
  153. var container = document.getElementById('mynetwork');
  154. // provide the data in the vis format
  155. var data = {
  156. nodes: nodes,
  157. edges: edges
  158. };
  159. var options = {};
  160. // initialize your network!
  161. var network = new vis.Network(container, data, options);
  162. &lt;/script&gt;
  163. &lt;/body&gt;
  164. &lt;/html&gt;
  165. </pre>
  166. <p><a href="http://visjs.org/examples/network/01_basic_usage.html" target="_blank">The result of the code above will be the basic example which is shown here.</a></p>
  167. <br>
  168. </div>
  169. <h3>Modules</h3>
  170. <table class="modules">
  171. <tr>
  172. <td width="120px"><a href="./configure.html">configure</a></td>
  173. <td>Generates an interactive option editor with filtering.</td>
  174. </tr>
  175. <tr>
  176. <td><a href="./edges.html">edges</a></td>
  177. <td>Handles the creation and deletion of edges and contains the global edge options and styles.</td>
  178. </tr>
  179. <tr>
  180. <td><a href="./groups.html">groups</a></td>
  181. <td>Contains the groups and some options on how to handle nodes with non-existing groups.</td>
  182. </tr>
  183. <tr>
  184. <td><a href="./interaction.html">interaction</a></td>
  185. <td>Used for all user interaction with the network. Handles mouse and touch events and selection as well as
  186. the navigation buttons and the popups.
  187. </td>
  188. </tr>
  189. <tr>
  190. <td><a href="./layout.html">layout</a></td>
  191. <td>Governs the initial and hierarchical positioning.</td>
  192. </tr>
  193. <tr>
  194. <td><a href="./manipulation.html">manipulation</a></td>
  195. <td>Supplies an API and optional GUI to alter the data in the network.</td>
  196. </tr>
  197. <tr>
  198. <td><a href="./nodes.html">nodes</a></td>
  199. <td>Handles the creation and deletion of nodes and contains the global node options and styles.</td>
  200. </tr>
  201. <tr>
  202. <td><a href="./physics.html">physics</a></td>
  203. <td>Does all the simulation moving the nodes and edges to their final positions, also governs
  204. stabilization.
  205. </td>
  206. </tr>
  207. </table>
  208. <br>
  209. <br>
  210. <ul class="nav nav-tabs">
  211. <li role="presentation" class="active"
  212. onclick="toggleTab(this);"
  213. targetNode="optionsDiv"><a>Options</a></li>
  214. <li role="presentation"
  215. onclick="toggleTab(this);"
  216. targetNode="methodsDiv"><a>Methods</a></li>
  217. <li role="presentation" onclick="toggleTab(this);"
  218. targetNode="eventsDiv"><a>Events</a></li>
  219. <li role="presentation"
  220. onclick="toggleTab(this);"
  221. targetNode="dotParserDiv"><a>DOT language</a></li>
  222. <li role="presentation"
  223. onclick="toggleTab(this);"
  224. targetNode="gephiDiv"><a>Importing from Gephi</a></li>
  225. </ul>
  226. <br>
  227. <div id="optionsDiv">
  228. <pre class="prettyprint lang-js options">
  229. var options = {
  230. autoResize: true,
  231. height: '100%',
  232. width: '100%'
  233. locale: 'en',
  234. locales: locales,
  235. clickToUse: false,
  236. configure: {...}, // defined in the configure module.
  237. edges: {...}, // defined in the edges module.
  238. nodes: {...}, // defined in the nodes module.
  239. groups: {...}, // defined in the groups module.
  240. layout: {...}, // defined in the layout module.
  241. interaction: {...}, // defined in the interaction module.
  242. manipulation: {...}, // defined in the manipulation module.
  243. physics: {...}, // defined in the physics module.
  244. }
  245. network.setOptions(options);
  246. </pre>
  247. <p>The individual options are explained below. The ones referring to modules are explained in the corresponding
  248. module.</p>
  249. <table class="options">
  250. <tr>
  251. <th>Name</th>
  252. <th>Type</th>
  253. <th>Default</th>
  254. <th>Description</th>
  255. </tr>
  256. <tr>
  257. <td>autoResize</td>
  258. <td>Boolean</td>
  259. <td><code>true</code></td>
  260. <td>If true, the Network will automatically detect when its container is resized, and redraw itself
  261. accordingly. If false, the Network can be forced to repaint after its container has been resized
  262. using the function redraw() and setSize().
  263. </td>
  264. </tr>
  265. <tr>
  266. <td>width</td>
  267. <td>String</td>
  268. <td><code>'100%'</code></td>
  269. <td>the width of the canvas. Can be in percentages or pixels (ie. <code>'400px'</code>).</td>
  270. </tr>
  271. <tr>
  272. <td>height</td>
  273. <td>String</td>
  274. <td><code>'100%'</code></td>
  275. <td>the height of the canvas. Can be in percentages or pixels (ie. <code>'400px'</code>).</td>
  276. </tr>
  277. <tr>
  278. <td>locale</td>
  279. <td>String</td>
  280. <td><code>'en'</code></td>
  281. <td>Select the locale. By default, the language is English. If you want to use another language, you
  282. will
  283. need to define your own locale and refer to it here.
  284. </td>
  285. </tr>
  286. <tr>
  287. <td>locales</td>
  288. <td>Object</td>
  289. <td>defaultLocales</td>
  290. <td>Locales object. By default only <code>'en'</code> and <code>'nl'</code> are supported. Take a look
  291. at
  292. the <a href="#locales" data-scroll=""
  293. data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }">locales
  294. section below</a> for more explaination on how to customize this.
  295. </td>
  296. </tr>
  297. <tr>
  298. <td>clickToUse</td>
  299. <td>Boolean</td>
  300. <td>false</td>
  301. <td>Locales object. By default only <code>'en'</code> and <code>'nl'</code> are supported. Take a look
  302. at
  303. the <a href="#locales" data-scroll=""
  304. data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }">locales
  305. section below</a> for more explaination on how to customize this.
  306. </td>
  307. </tr>
  308. <tr>
  309. <td>configure</td>
  310. <td>Object</td>
  311. <td>Object</td>
  312. <td><a href="./configure.html">All options in this object are explained in the configure module.</a>
  313. </td>
  314. </tr>
  315. <tr>
  316. <td>edges</td>
  317. <td>Object</td>
  318. <td>Object</td>
  319. <td><a href="./edges.html">All options in this object are explained in the edges module.</a>
  320. </td>
  321. </tr>
  322. <tr>
  323. <td>nodes</td>
  324. <td>Object</td>
  325. <td>Object</td>
  326. <td><a href="./nodes.html">All options in this object are explained in the nodes module.</a>
  327. </td>
  328. </tr>
  329. <tr>
  330. <td>groups</td>
  331. <td>Object</td>
  332. <td>Object</td>
  333. <td><a href="./groups.html">All options in this object are explained in the groups module.</a>
  334. </td>
  335. </tr>
  336. <tr>
  337. <td>layout</td>
  338. <td>Object</td>
  339. <td>Object</td>
  340. <td><a href="./layout.html">All options in this object are explained in the layout module.</a>
  341. </td>
  342. </tr>
  343. <tr>
  344. <td>interaction</td>
  345. <td>Object</td>
  346. <td>Object</td>
  347. <td><a href="./interaction.html">All options in this object are explained in the interaction module.</a>
  348. </td>
  349. </tr>
  350. <tr>
  351. <td>manipulation</td>
  352. <td>Object</td>
  353. <td>Object</td>
  354. <td><a href="./manipulation.html">All options in this object are explained in the manipulation module.</a>
  355. </td>
  356. </tr>
  357. <tr>
  358. <td>physics</td>
  359. <td>Object</td>
  360. <td>Object</td>
  361. <td><a href="./physics.html">All options in this object are explained in the physics module.</a>
  362. </td>
  363. </tr>
  364. </table>
  365. <br>
  366. <br>
  367. <h4 id="locales">Custom locales</h4>
  368. <p>The locales object has the following format:</p>
  369. <pre class="prettyprint lang-js">
  370. var locales = {
  371. en: {
  372. edit: 'Edit',
  373. del: 'Delete selected',
  374. back: 'Back',
  375. addNode: 'Add Node',
  376. addEdge: 'Add Edge',
  377. editNode: 'Edit Node',
  378. editEdge: 'Edit Edge',
  379. addDescription: 'Click in an empty space to place a new node.',
  380. edgeDescription: 'Click on a node and drag the edge to another node to connect them.',
  381. editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
  382. createEdgeError: 'Cannot link edges to a cluster.',
  383. deleteClusterError: 'Clusters cannot be deleted.',
  384. editClusterError: 'Clusters cannot be edited.'
  385. }
  386. }</pre>
  387. <p>If you want to define your own locale, you can change the key ('en' here) and change all the strings. You can
  388. then use your new key in the locale option.</p>
  389. </div>
  390. <div id="methodsDiv" class=" hidden">
  391. <h3>All Methods</h3>
  392. <p>This is a list of all the methods in the public API. They have been grouped by category, which correspond to
  393. the
  394. modules listed above.</p>
  395. <table class="methods-collapsable" id="methodTable">
  396. <tr class="subHeader">
  397. <td colspan="2">Global methods for the network.</td>
  398. </tr>
  399. <tr class="collapsible toggle" onclick="toggleTable('methodTable','destroy', this);">
  400. <td colspan="2"><span parent="destroy" class="right-caret"></span> destroy()</td>
  401. </tr>
  402. <tr class="hidden" parent="destroy">
  403. <td class="midMethods">Returns: none</td>
  404. <td>Remove the network from the DOM and remove all Hammer bindings and references.</td>
  405. </tr>
  406. <tr class="collapsible toggle" onclick="toggleTable('methodTable','setData', this);">
  407. <td colspan="2"><span parent="setData" class="right-caret"></span> setData({<code><i>nodes: vis
  408. DataSet/Array</i></code>,<code><i>edges: vis
  409. DataSet/Array</i></code>})
  410. </td>
  411. </tr>
  412. <tr class="hidden" parent="setData">
  413. <td class="midMethods">Returns: none</td>
  414. <td>Override all the data in the network. If stabilization is enabled in the <a href="physics.html">physics
  415. module</a>, the network will stabilize again. This method is also performed when first initializing
  416. the
  417. network.
  418. </td>
  419. </tr>
  420. <tr class="collapsible toggle" onclick="toggleTable('methodTable','setOptions', this);">
  421. <td colspan="2"><span parent="setOptions" class="right-caret"></span> setOptions(<code>Object
  422. options</code>)
  423. </td>
  424. </tr>
  425. <tr class="hidden" parent="setOptions">
  426. <td class="midMethods">Returns: none</td>
  427. <td>Set the options. All available options can be found in the modules above. Each module requires it's
  428. own
  429. container with the module name to contain its options.
  430. </td>
  431. </tr>
  432. <tr class="collapsible toggle" onclick="toggleTable('methodTable','onEvent', this);">
  433. <td colspan="2"><span parent="onEvent" class="right-caret"></span> on(<code>String event name, Function callback</code>)
  434. </td>
  435. </tr>
  436. <tr class="hidden" parent="onEvent">
  437. <td class="midMethods">Returns: none</td>
  438. <td>Set an event listener. Depending on the type of event you get different parameters for the callback function. Look at the event section of the documentation for more information.
  439. </td>
  440. </tr>
  441. <tr class="collapsible toggle" onclick="toggleTable('methodTable','offEvent', this);">
  442. <td colspan="2"><span parent="offEvent" class="right-caret"></span> off(<code>String event name, Function callback</code>)
  443. </td>
  444. </tr>
  445. <tr class="hidden" parent="offEvent">
  446. <td class="midMethods">Returns: none</td>
  447. <td>Remove an event listener. The function you supply has to be the exact same as the one you used in the on function. If no function is supplied, all listeners will be removed. Look at the event section of the documentation for more information.
  448. </td>
  449. </tr>
  450. <tr class="collapsible toggle" onclick="toggleTable('methodTable','onceEvent', this);">
  451. <td colspan="2"><span parent="onceEvent" class="right-caret"></span> once(<code>String event name, Function callback</code>)
  452. </td>
  453. </tr>
  454. <tr class="hidden" parent="onceEvent">
  455. <td class="midMethods">Returns: none</td>
  456. <td>Set an event listener only once. After it has taken place, the event listener will be removed. Depending on the type of event you get different parameters for the callback function. Look at the event section of the documentation for more information.
  457. </td>
  458. </tr>
  459. <tr class="subHeader">
  460. <td colspan="2">Methods related to the canvas.</td>
  461. </tr>
  462. <tr class="collapsible toggle" onclick="toggleTable('methodTable','canvasToDOM', this);">
  463. <td colspan="2"><span parent="canvasToDOM" class="right-caret"></span> canvasToDOM({<code><i>x:
  464. Number</i></code>,<code><i>y:
  465. Number</i></code>})
  466. </td>
  467. </tr>
  468. <tr class="hidden" parent="canvasToDOM">
  469. <td class="midMethods">Returns: Object</td>
  470. <td>This function converts canvas coordinates to coordinates on the DOM. Input and output are in the
  471. form of
  472. <code>{x:Number,y:Number}</code>. The DOM values are relative to the network container.
  473. </td>
  474. </tr>
  475. <tr class="collapsible toggle" onclick="toggleTable('methodTable','DOMtoCanvas', this);">
  476. <td colspan="2"><span parent="DOMtoCanvas" class="right-caret"></span> DOMtoCanvas({<code><i>x:
  477. Number</i></code>,<code><i>y:
  478. Number</i></code>})
  479. </td>
  480. </tr>
  481. <tr class="hidden" parent="DOMtoCanvas">
  482. <td class="midMethods">Returns: Object</td>
  483. <td>This function converts DOM coordinates to coordinates on the canvas. Input and output are in the
  484. form of
  485. <code>{x:Number,y:Number}</code>. The DOM values are relative to the network container.
  486. </td>
  487. </tr>
  488. <tr class="collapsible toggle" onclick="toggleTable('methodTable','redraw', this);">
  489. <td colspan="2"><span parent="redraw" class="right-caret"></span> redraw()</td>
  490. </tr>
  491. <tr class="hidden" parent="redraw">
  492. <td class="midMethods">Returns: none</td>
  493. <td>Redraw the network.</td>
  494. </tr>
  495. <tr class="collapsible toggle" onclick="toggleTable('methodTable','setSize', this);">
  496. <td colspan="2"><span parent="setSize" class="right-caret"></span> setSize(<code><i>String
  497. width</i></code>,<code><i>String
  498. height</i></code>)
  499. </td>
  500. </tr>
  501. <tr class="hidden" parent="setSize">
  502. <td class="midMethods">Returns: none</td>
  503. <td>Set the size of the canvas. This is automatically done on a window resize.</td>
  504. </tr>
  505. <tr class="subHeader">
  506. <td colspan="2">Clustering</td>
  507. </tr>
  508. <tr class="collapsible toggle" onclick="toggleTable('methodTable','cluster', this);">
  509. <td colspan="2"><span parent="cluster" class="right-caret"></span> cluster(
  510. <code>Object options</code>)
  511. </td>
  512. </tr>
  513. <tr class="hidden" parent="cluster">
  514. <td class="midMethods">Returns: none</td>
  515. <td>The options object is explained in full <a data-scroll=""
  516. data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }"
  517. href="#optionsObject">below</a>. The joinCondition
  518. function
  519. is presented with all nodes.
  520. </td>
  521. </tr>
  522. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByConnection', this);">
  523. <td colspan="2"><span parent="clusterByConnection" class="right-caret"></span> clusterByConnection(
  524. <code>String nodeId</code>,
  525. <code>[Object options]</code>
  526. )
  527. </td>
  528. </tr>
  529. <tr class="hidden" parent="clusterByConnection">
  530. <td class="midMethods">Returns: none</td>
  531. <td>This method looks at the provided node and makes a cluster of it and all it's connected nodes. The
  532. behaviour can be customized by proving the options object. All options of this object are explained
  533. <a
  534. data-scroll="" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }"
  535. href="#optionsObject">below</a>. The joinCondition is only presented with the connected
  536. nodes.
  537. </td>
  538. </tr>
  539. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
  540. <td colspan="2"><span parent="clusterByHubsize" class="right-caret"></span> clusterByHubsize(
  541. <code>[Number hubsize]</code>,
  542. <code>[Object options]</code>)
  543. </td>
  544. </tr>
  545. <tr class="hidden" parent="clusterByHubsize">
  546. <td class="midMethods">Returns: none</td>
  547. <td>This method checks all nodes in the network and those with a equal or higher amount of edges than
  548. specified with the <code>hubsize</code> qualify. If a hubsize is not defined, the hubsize will be determined as the average
  549. value plus two standard deviations. <br><br>
  550. For all qualifying nodes, clusterByConnection is performed on each of them.
  551. The options object is described for <code>clusterByConnection</code> and does the same here.
  552. </td>
  553. </tr>
  554. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterOutliers', this);">
  555. <td colspan="2"><span parent="clusterOutliers" class="right-caret"></span> clusterOutliers(
  556. <code>[Object options]</code>)
  557. </tr>
  558. <tr class="hidden" parent="clusterOutliers">
  559. <td class="midMethods">Returns: none</td>
  560. <td>This method will cluster all nodes with 1 edge with their respective connected node.
  561. The options object is explained in full <a data-scroll="" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }" href="#optionsObject">below</a>.
  562. </td>
  563. </tr>
  564. <tr class="collapsible toggle" onclick="toggleTable('methodTable','findNode', this);">
  565. <td colspan="2"><span parent="findNode" class="right-caret"></span> findNode(
  566. <code>String nodeId</code>)
  567. </tr>
  568. <tr class="hidden" parent="findNode">
  569. <td class="midMethods">Returns: Array</td>
  570. <td>Nodes can be in clusters. Clusters can also be in clusters. This function returns and array of
  571. nodeIds
  572. showing where the node is. <br><br> Example:
  573. cluster 'A' contains cluster 'B',
  574. cluster 'B' contains cluster 'C',
  575. cluster 'C' contains node 'fred'.
  576. <code>network.clustering.findNode('fred')</code> will return <code>['A','B','C','fred']</code>.
  577. </td>
  578. </tr>
  579. <tr class="collapsible toggle" onclick="toggleTable('methodTable','isCluster', this);">
  580. <td colspan="2"><span parent="isCluster" class="right-caret"></span> isCluster(
  581. <code>String nodeId</code>)
  582. </tr>
  583. <tr class="hidden" parent="isCluster">
  584. <td class="midMethods">Returns: Boolean</td>
  585. <td>Returns true if the node whose ID has been supplied is a cluster.</td>
  586. </tr>
  587. <tr class="collapsible toggle" onclick="toggleTable('methodTable','openCluster', this);">
  588. <td colspan="2"><span parent="openCluster" class="right-caret"></span> openCluster(
  589. <code>String nodeId</code>)
  590. </tr>
  591. <tr class="hidden" parent="openCluster">
  592. <td class="midMethods">Returns: none</td>
  593. <td>Opens the cluster, releases the contained nodes and edges, removing the cluster node and cluster
  594. edges.
  595. </td>
  596. </tr>
  597. <tr class="subHeader">
  598. <td colspan="2">Layout</td>
  599. </tr>
  600. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSeed', this);">
  601. <td colspan="2"><span parent="getSeed" class="right-caret"></span> getSeed()</td>
  602. </tr>
  603. <tr class="hidden" parent="clusterByHubsize">
  604. </tr>
  605. <tr class="hidden" parent="getSeed">
  606. <td class="midMethods">Returns: Number</td>
  607. <td>If you like the layout of your network and would like it to start in the same way next time, ask for
  608. the
  609. seed using this method and put it in the <code>layout.randomSeed</code> option.
  610. </td>
  611. </tr>
  612. <tr class="subHeader">
  613. <td colspan="2">Manipulation methods to use the manipulation system without GUI.</td>
  614. </tr>
  615. <tr class="collapsible toggle" onclick="toggleTable('methodTable','enableEditMode', this);">
  616. <td colspan="2"><span parent="enableEditMode" class="right-caret"></span> enableEditMode()</td>
  617. </tr>
  618. <tr class="hidden" parent="enableEditMode">
  619. <td class="midMethods">Returns: none</td>
  620. <td>Programatically enable the edit mode. Similar effect to pressing the edit button.</td>
  621. </tr>
  622. <tr class="collapsible toggle" onclick="toggleTable('methodTable','disableEditMode', this);">
  623. <td colspan="2"><span parent="disableEditMode" class="right-caret"></span> disableEditMode()</td>
  624. </tr>
  625. <tr class="hidden" parent="disableEditMode">
  626. <td class="midMethods">Returns: none</td>
  627. <td>Programatically disable the edit mode. Similar effect to pressing the close icon (small cross in the
  628. corner of the toolbar).
  629. </td>
  630. </tr>
  631. <tr class="collapsible toggle" onclick="toggleTable('methodTable','addNodeMode', this);">
  632. <td colspan="2"><span parent="addNodeMode" class="right-caret"></span> addNodeMode()</td>
  633. </tr>
  634. <tr class="hidden" parent="addNodeMode">
  635. <td class="midMethods">Returns: none</td>
  636. <td>Go into addNode mode. Having edit mode or manipulation enabled is not required. To get out of this
  637. mode,
  638. call <code>disableEditMode()</code>. The callback functions defined in <code>handlerFunctions</code>
  639. still apply. To use these methods without having the manipulation GUI, make sure you set
  640. <code>enabled</code> to false.
  641. </td>
  642. </tr>
  643. <tr class="collapsible toggle" onclick="toggleTable('methodTable','editNodeMode', this);">
  644. <td colspan="2"><span parent="editNodeMode" class="right-caret"></span> editNodeMode()</td>
  645. </tr>
  646. <tr class="hidden" parent="editNodeMode">
  647. <td class="midMethods">Returns: none</td>
  648. <td>Go into editNode mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
  649. </tr>
  650. <tr class="collapsible toggle" onclick="toggleTable('methodTable','addEdgeMode', this);">
  651. <td colspan="2"><span parent="addEdgeMode" class="right-caret"></span> addEdgeMode()</td>
  652. </tr>
  653. <tr class="hidden" parent="addEdgeMode">
  654. <td class="midMethods">Returns: none</td>
  655. <td>Go into addEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
  656. </tr>
  657. <tr class="collapsible toggle" onclick="toggleTable('methodTable','editEdgeMode', this);">
  658. <td colspan="2"><span parent="editEdgeMode" class="right-caret"></span> editEdgeMode()</td>
  659. </tr>
  660. <tr class="hidden" parent="editEdgeMode">
  661. <td class="midMethods">Returns: none</td>
  662. <td>Go into editEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
  663. </tr>
  664. <tr class="collapsible toggle" onclick="toggleTable('methodTable','deleteSelected', this);">
  665. <td colspan="2"><span parent="deleteSelected" class="right-caret"></span> deleteSelected()</td>
  666. </tr>
  667. <tr class="hidden" parent="deleteSelected">
  668. <td class="midMethods">Returns: none</td>
  669. <td>Delete selected. Having edit mode or manipulation enabled is not required.</td>
  670. </tr>
  671. <tr class="subHeader">
  672. <td colspan="2">Methods to get information on nodes and edges.</td>
  673. </tr>
  674. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getPositions', this);">
  675. <td colspan="2"><span parent="getPositions" class="right-caret"></span> getPositions(<code><i>[Array of
  676. nodeIds]</i></code>)
  677. </td>
  678. </tr>
  679. <tr class="hidden" parent="getPositions">
  680. <td class="midMethods">Returns: Object</td>
  681. <td>Returns the x y positions in canvas space of the nodes with the supplied nodeIds as an object:
  682. <pre class="code">
  683. {
  684. nodeId1: {x: xValue, y:yValue},
  685. nodeId2: {x: xValue, y:yValue},
  686. ...
  687. }
  688. </pre>
  689. Alternative inputs are a String containing a nodeId or nothing. When a String is supplied, the
  690. position
  691. of the node corresponding to the ID is returned. When nothing is supplied, the positions of all
  692. nodes
  693. are returned.
  694. </td>
  695. </tr>
  696. <tr class="collapsible toggle" onclick="toggleTable('methodTable','storePositions', this);">
  697. <td colspan="2"><span parent="storePositions" class="right-caret"></span> storePositions()</td>
  698. </tr>
  699. <tr class="hidden" parent="storePositions">
  700. <td class="midMethods">Returns: none</td>
  701. <td>When using the vis.DataSet to load your nodes into the network, this method will put the X and Y
  702. positions of all nodes into that dataset. If you're loading your nodes from a database and have
  703. this dynamically coupled with
  704. the DataSet, you can
  705. use this to stablize your network once, then save the positions in that database through the DataSet
  706. so
  707. the next
  708. time you load the nodes, stabilization will be near instantaneous.
  709. <br><br>
  710. If the nodes are still moving and you're using dynamic smooth edges (which is on by default), you
  711. can
  712. use the option <code>stabilization.onlyDynamicEdges</code> in the <a href="physics.html">physics
  713. module</a>
  714. to improve initialization time.
  715. <br><br>
  716. <b>This method does not support clustering. At the moment it is not possible to cache
  717. positions when using clusters since they cannot be correctly initialized from just the
  718. positions.</b>
  719. </td>
  720. </tr>
  721. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getBoundingBox', this);">
  722. <td colspan="2"><span parent="getBoundingBox" class="right-caret"></span> getBoundingBox(<code><i>String
  723. nodeId</i></code>)
  724. </td>
  725. </tr>
  726. <tr class="hidden" parent="getBoundingBox">
  727. <td class="midMethods">Returns: Object</td>
  728. <td> Returns a bounding box for the node including label in the format:
  729. <pre class="code">
  730. {
  731. top: Number,
  732. left: Number,
  733. right: Number,
  734. bottom: Number
  735. }
  736. </pre>
  737. These values are in canvas space.
  738. </td>
  739. </tr>
  740. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedNodes', this);">
  741. <td colspan="2"><span parent="getConnectedNodes" class="right-caret"></span> getConnectedNodes(<code><i>String
  742. nodeId or edgeId</i></code>)
  743. </td>
  744. </tr>
  745. <tr class="hidden" parent="getConnectedNodes">
  746. <td class="midMethods">Returns: Array</td>
  747. <td>Returns an array of nodeIds of the all the nodes that are directly connected to this node. If you supply an edgeId,
  748. vis will first match the id to nodes. If no match is found, it will search in the edgelist and return an array: <code>[fromId, toId]</code>.</td>
  749. </tr>
  750. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedEdges', this);">
  751. <td colspan="2"><span parent="getConnectedEdges" class="right-caret"></span> getConnectedEdges(<code><i>String
  752. nodeId</i></code>)
  753. </td>
  754. </tr>
  755. <tr class="hidden" parent="getConnectedEdges">
  756. <td class="midMethods">Returns: Array</td>
  757. <td>Returns an array of edgeIds of the edges connected to this node.</td>
  758. </tr>
  759. <tr class="subHeader">
  760. <td colspan="2">Physics methods to control when the simulation should run.</td>
  761. </tr>
  762. <tr class="collapsible toggle" onclick="toggleTable('methodTable','startSimulation', this);">
  763. <td colspan="2"><span parent="startSimulation" class="right-caret"></span> startSimulation()</td>
  764. </tr>
  765. <tr class="hidden" parent="startSimulation">
  766. <td class="midMethods">Returns: none</td>
  767. <td>Start the physics simulation. This is normally done whenever needed and is only really useful if you
  768. stop the simulation yourself and wish to continue it afterwards.
  769. </td>
  770. .</td></tr>
  771. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stopSimulation', this);">
  772. <td colspan="2"><span parent="stopSimulation" class="right-caret"></span> stopSimulation()</td>
  773. </tr>
  774. <tr class="hidden" parent="stopSimulation">
  775. <td class="midMethods">Returns: none</td>
  776. <td>This stops the physics simulation and triggers a <code>stabilized</code> event. It can be restarted
  777. by
  778. dragging a node, altering the dataset or calling <code>startSimulation()</code>.
  779. </td>
  780. </tr>
  781. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stabilize', this);">
  782. <td colspan="2"><span parent="stabilize" class="right-caret"></span> stabilize([iterations])</td>
  783. </tr>
  784. <tr class="hidden" parent="stabilize">
  785. <td class="midMethods">Returns: none</td>
  786. <td>You can manually call stabilize at any time. All the stabilization options above are used. You can optionally supply the number of iterations it should do.</td>
  787. </tr>
  788. <tr class="subHeader">
  789. <td colspan="2">Selection methods for nodes and edges.</td>
  790. </tr>
  791. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelection', this);">
  792. <td colspan="2"><span parent="getSelection" class="right-caret"></span> getSelection()</td>
  793. </tr>
  794. <tr class="hidden" parent="getSelection">
  795. <td class="midMethods">Returns: Object</td>
  796. <td>Returns an object with selected nodes and edges ids like this:
  797. <pre class="code">
  798. {
  799. nodes: [Array of selected nodeIds],
  800. edges: [Array of selected edgeIds]
  801. }</pre>
  802. </td>
  803. </tr>
  804. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedNodes', this);">
  805. <td colspan="2"><span parent="getSelectedNodes" class="right-caret"></span> getSelectedNodes()</td>
  806. </tr>
  807. <tr class="hidden" parent="getSelectedNodes">
  808. <td class="midMethods">Returns: Array</td>
  809. <td>Returns an array of selected node ids like so:
  810. <code>[nodeId1, nodeId2, ..]</code>.
  811. </td>
  812. </tr>
  813. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedEdges', this);">
  814. <td colspan="2"><span parent="getSelectedEdges" class="right-caret"></span> getSelectedEdges()</td>
  815. </tr>
  816. <tr class="hidden" parent="getSelectedEdges">
  817. <td class="midMethods">Returns: Array</td>
  818. <td>Returns an array of selected edge ids like so: <code>[edgeId1, edgeId2, ..]</code>.</td>
  819. </tr>
  820. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getNodeAt', this);">
  821. <td colspan="2"><span parent="getNodeAt" class="right-caret"></span> getNodeAt(<code><i>{x: xPosition
  822. DOM, y: yPosition DOM}</i></code>)
  823. </td>
  824. </tr>
  825. <tr class="hidden" parent="getNodeAt">
  826. <td class="midMethods">Returns: String</td>
  827. <td>Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left
  828. corner
  829. of the canvas.
  830. </td>
  831. </tr>
  832. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getEdgeAt', this);">
  833. <td colspan="2"><span parent="getEdgeAt" class="right-caret"></span> getEdgeAt(<code><i>{x: xPosition
  834. DOM, y: yPosition DOM}</i></code>)
  835. </td>
  836. </tr>
  837. <tr class="hidden" parent="getEdgeAt">
  838. <td class="midMethods">Returns: String</code></td>
  839. <td>Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left
  840. corner
  841. of the canvas..
  842. </td>
  843. </tr>
  844. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectNodes', this);">
  845. <td colspan="2"><span parent="selectNodes" class="right-caret"></span> selectNodes(<code><i>Array with
  846. nodeIds</i></code>,<code><i>[Boolean
  847. highlightEdges]</i></code>)
  848. </td>
  849. </tr>
  850. <tr class="hidden" parent="selectNodes">
  851. <td class="midMethods">Returns: none</td>
  852. <td>Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or
  853. undefined,
  854. the neighbouring edges will also be selected. This method unselects all other objects before
  855. selecting
  856. its own objects. <i>Does not fire events</i>.
  857. </td>
  858. </tr>
  859. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectEdges', this);">
  860. <td colspan="2"><span parent="selectEdges" class="right-caret"></span> selectEdges(<code><i>Array with
  861. edgeIds</i></code>)
  862. </td>
  863. </tr>
  864. <tr class="hidden" parent="selectEdges">
  865. <td class="midMethods">Returns: none</td>
  866. <td>Selects the edges corresponding to the id's in the input array. This method unselects all other
  867. objects
  868. before selecting its own objects. <i>Does not fire events</i>.
  869. </td>
  870. </tr>
  871. <tr class="collapsible toggle" onclick="toggleTable('methodTable','unselectAll', this);">
  872. <td colspan="2"><span parent="unselectAll" class="right-caret"></span> unselectAll()</td>
  873. </tr>
  874. <tr class="hidden" parent="unselectAll">
  875. <td class="midMethods">Returns: none</td>
  876. <td>Unselect all objects. <i>Does not fire events</i>.</td>
  877. </tr>
  878. <tr class="subHeader">
  879. <td colspan="2">Methods to control the viewport for zoom and animation.</td>
  880. </tr>
  881. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getScale', this);">
  882. <td colspan="2"><span parent="getScale" class="right-caret"></span> getScale()</td>
  883. </tr>
  884. <tr class="hidden" parent="getScale">
  885. <td class="midMethods">Returns: Number</td>
  886. <td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.
  887. </td>
  888. </tr>
  889. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
  890. <td colspan="2"><span parent="clusterByHubsize" class="right-caret"></span> getViewPosition()</td>
  891. </tr>
  892. <tr class="hidden" parent="clusterByHubsize">
  893. <td class="midMethods">Returns: Number</td>
  894. <td>Returns the current central focus point of the view.</td>
  895. </tr>
  896. <tr class="collapsible toggle" onclick="toggleTable('methodTable','fit', this);">
  897. <td colspan="2"><span parent="fit" class="right-caret"></span> fit(<code>[Object
  898. options]</code>)
  899. </td>
  900. </tr>
  901. <tr class="hidden" parent="fit">
  902. <td class="midMethods">Returns: none</td>
  903. <td>Zooms out so all nodes fit on the canvas. You can supply options to customize this:
  904. <pre class="code">
  905. {
  906. nodes:[Array of nodeIds],
  907. animation: { // -------------------> can be a boolean too!
  908. duration: Number
  909. easingFunction: String
  910. }
  911. }
  912. </pre>
  913. The nodes can be used to zoom to fit only specific nodes in the view. <br/><br/>
  914. The other options are explained in the <code>moveTo()</code> description below.
  915. All options are optional for the fit method.
  916. </td>
  917. </tr>
  918. <tr class="collapsible toggle" onclick="toggleTable('methodTable','focus', this);">
  919. <td colspan="2"><span parent="focus" class="right-caret"></span> focus(
  920. <code>String nodeId</code>,
  921. <code>[Object options]</code>)
  922. </td>
  923. </tr>
  924. <tr class="hidden" parent="focus">
  925. <td class="midMethods">Returns: none</td>
  926. <td>You can focus on a node with this function. What that means is the view will lock onto that node, if
  927. it
  928. is moving, the view will also move accordingly. If the view is dragged by the user, the focus is
  929. broken.
  930. You can supply options to customize the effect:
  931. <pre class="code">
  932. {
  933. scale: Number,
  934. offset: {x:Number, y:Number}
  935. locked: boolean
  936. animation: { // -------------------> can be a boolean too!
  937. duration: Number
  938. easingFunction: String
  939. }
  940. }
  941. </pre>
  942. All options except for locked are explained in the <code>moveTo()</code> description below. Locked
  943. denotes whether or not the view remains locked to the node once the zoom-in animation is finished.
  944. Default value is true. The options object is optional in the focus method.
  945. </td>
  946. </tr>
  947. <tr class="collapsible toggle" onclick="toggleTable('methodTable','moveTo', this);">
  948. <td colspan="2"><span parent="moveTo" class="right-caret"></span> moveTo(<code>Object
  949. options</code>)
  950. </td>
  951. </tr>
  952. <tr class="hidden" parent="moveTo">
  953. <td class="midMethods">Returns: none</td>
  954. <td>You can animate or move the camera using the moveTo method. Options are:
  955. <pre class="code">
  956. {
  957. position: {x:Number, y:Number},
  958. scale: Number,
  959. offset: {x:Number, y:Number}
  960. animation: { // -------------------> can be a boolean too!
  961. duration: Number
  962. easingFunction: String
  963. }
  964. }
  965. </pre>
  966. The position (in canvas units!) is the position of the central focus point of the camera.
  967. The scale is the target zoomlevel. Default value is 1.0.
  968. The offset (in DOM units) is how many pixels from the center the view is focussed. Default value is
  969. {x:0,y:0}.
  970. For animation you can either use a Boolean to use it with the default options or disable it or you
  971. can
  972. define the duration (in milliseconds) and easing function manually. Available are:
  973. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  974. easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint</code>.
  975. <i>You will have to define at least a scale or a position. Otherwise, there is nothing to move
  976. to.</i>
  977. </td>
  978. </tr>
  979. <tr class="collapsible toggle" onclick="toggleTable('methodTable','releaseNode', this);">
  980. <td colspan="2"><span parent="releaseNode" class="right-caret"></span> releaseNode()</td>
  981. </tr>
  982. <tr class="hidden" parent="releaseNode">
  983. <td class="midMethods">Returns: none</td>
  984. <td>Programatically release the focussed node.</td>
  985. </tr>
  986. </table>
  987. <br>
  988. <br>
  989. <h4 id="optionsObject">Cluster methods options object</h4>
  990. <p>The options object supplied to the cluster functions can contain these properties:</p>
  991. <table class="methods">
  992. <tr>
  993. <th>Name</th>
  994. <th>Type</th>
  995. <th>Description</th>
  996. </tr>
  997. <tr>
  998. <td>joinCondition(<br>&nbsp;&nbsp;<code>nodeOptions:&nbsp;Object</code><br>)</td>
  999. <td>Function</td>
  1000. <td><i>Optional for all but the cluster method. </i> The cluster module loops over all nodes that are
  1001. selected to be in the cluster and calls this function with their data as argument.
  1002. If this function returns true, this node will be added to the cluster. You have access to all
  1003. options
  1004. (including the default)
  1005. as well as any custom fields you may have added to the node to determine whether or not to include
  1006. it in
  1007. the cluster. Example:
  1008. <pre class="prettyprint lang-js">
  1009. var nodes = [
  1010. {id: 4, label: 'Node 4'},
  1011. {id: 5, label: 'Node 5'},
  1012. {id: 6, label: 'Node 6', cid:1},
  1013. {id: 7, label: 'Node 7', cid:1}
  1014. ]
  1015. var options = {
  1016. joinCondition:function(nodeOptions) {
  1017. return nodeOptions.cid === 1;
  1018. }
  1019. }
  1020. network.clustering.cluster(options);
  1021. </pre>
  1022. </td>
  1023. </tr>
  1024. <tr>
  1025. <td>processProperties(<br>&nbsp;&nbsp;<code>clusterOptions:&nbsp;Object</code>,<br>
  1026. &nbsp;&nbsp;<code>childNodesOptions:&nbsp;Array</code>,<br>
  1027. &nbsp;&nbsp;<code>childEdgesOptions:&nbsp;Array</code><br>)</td>
  1028. <td>Function</td>
  1029. <td><i>Optional. </i> Before creating the new cluster node, this (optional) function will be called with
  1030. the
  1031. properties supplied by you (<code>clusterNodeProperties</code>), all contained nodes and all
  1032. contained
  1033. edges. You can use this to update the
  1034. properties of the cluster based on which items it contains. The function should return the
  1035. properties to
  1036. create the cluster node. In the example below, we ensure preservation of mass and value when forming
  1037. the
  1038. cluster:
  1039. <pre class="prettyprint lang-js">
  1040. var options = {
  1041. processProperties: function (clusterOptions,
  1042. childNodes, childEdges) {
  1043. var totalMass = 0;
  1044. var totalValue = 0;
  1045. for (var i = 0; i < childNodes.length; i++) {
  1046. totalMass += childNodes[i].mass;
  1047. totalValue = childNodes[i].value
  1048. ? totalValue + childNodes[i].value
  1049. : totalValue;
  1050. }
  1051. clusterOptions.mass = totalMass;
  1052. if (totalValue > 0) {
  1053. clusterOptions.value = totalValue;
  1054. }
  1055. return clusterOptions;
  1056. },
  1057. }
  1058. </pre>
  1059. </td>
  1060. </tr>
  1061. <tr>
  1062. <td>clusterNodeProperties</td>
  1063. <td>Object</td>
  1064. <td><i>Optional. </i> This is an object containing the options for the cluster node. All options
  1065. described
  1066. in the <a href="./nodes.html">nodes module</a> are allowed. This allows you to style your cluster
  1067. node
  1068. any way you want. This is also the style object that is provided in the processProperties function
  1069. for
  1070. fine tuning. If undefined, default node options will be used.
  1071. </td>
  1072. </tr>
  1073. <tr>
  1074. <td>clusterEdgeProperties</td>
  1075. <td>Object</td>
  1076. <td><i>Optional. </i> This is an object containing the options for the edges connected to the cluster.
  1077. All
  1078. options described in the <a href="./edges.html">edges module</a> are allowed. Using this, you can
  1079. style
  1080. the edges connecting to the cluster any way you want. If none are provided, the optoins from the
  1081. edges
  1082. that are replaced are used. If undefined, default edge options will be used.
  1083. </td>
  1084. </tr>
  1085. </table>
  1086. </div>
  1087. <div id="eventsDiv" class=" hidden">
  1088. <h3>All Events</h3>
  1089. <p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
  1090. <p>These events are fired by the interaction module. They are related to user input.</p>
  1091. <table class="events">
  1092. <tr>
  1093. <th>Name</th>
  1094. <th>Properties</th>
  1095. <th>Description</th>
  1096. </tr>
  1097. <tr class="subHeader">
  1098. <td colspan="3">Events triggered by human interaction, selection, dragging etc.</td>
  1099. </tr>
  1100. <tr class="">
  1101. <td>click</td>
  1102. <td>
  1103. <pre class="code">
  1104. {
  1105. nodes: [Array of selected nodeIds],
  1106. edges: [Array of selected edgeIds],
  1107. event: [Object] original click event,
  1108. pointer: {
  1109. DOM: {x:pointer_x, y:pointer_y},
  1110. canvas: {x:canvas_x, y:canvas_y}
  1111. }
  1112. }
  1113. </pre>
  1114. </td>
  1115. <td>Fired when the user clicks the mouse or taps on a touchscreen device.</td>
  1116. </tr>
  1117. <tr class="">
  1118. <td>doubleClick</td>
  1119. <td>same as <code>click</code>.</td>
  1120. <td>Fired when the user double clicks the mouse or double taps on a touchscreen device. Since a double
  1121. click
  1122. is in fact 2 clicks, 2 click events are fired, followed by a double click event. If you do not want
  1123. to
  1124. use the click events if a double click event is fired, just check the time between click events
  1125. before
  1126. processing them.
  1127. </td>
  1128. </tr>
  1129. <tr class="">
  1130. <td>oncontext</td>
  1131. <td>same as <code>click</code>.</td>
  1132. <td>Fired when the user click on the canvas with the right mouse button. The right mouse button does not
  1133. select by default. You can use <a href="./selection.html">getNodeAt</a> to select the node if you
  1134. want.
  1135. </td>
  1136. </tr>
  1137. <tr class="">
  1138. <td>hold</td>
  1139. <td>same as <code>click</code>.</td>
  1140. <td>Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device. A click
  1141. event
  1142. is also fired in this case.
  1143. </td>
  1144. </tr>
  1145. <tr class="">
  1146. <td>release</td>
  1147. <td>same as <code>click</code>.</td>
  1148. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1149. </td>
  1150. </tr>
  1151. <tr class="">
  1152. <td>select</td>
  1153. <td>same as <code>click</code>.</td>
  1154. <td>Fired when the selection has changed by user action. This means a node or edge has been selected,
  1155. added
  1156. to the selection or deselected. <b>All select events are only triggered on click and hold</b>.
  1157. </td>
  1158. </tr>
  1159. <tr class="">
  1160. <td>selectNode</td>
  1161. <td>same as <code>click</code>.</td>
  1162. <td>Fired when a node has been selected by the user.</td>
  1163. </tr>
  1164. <tr class="">
  1165. <td>selectEdge</td>
  1166. <td>same as <code>click</code>.</td>
  1167. <td>Fired when a edge has been selected by the user.</td>
  1168. </tr>
  1169. <tr class="">
  1170. <td>deselectNode</td>
  1171. <td><pre class="code">
  1172. {
  1173. nodes: [Array of selected nodeIds],
  1174. edges: [Array of selected edgeIds],
  1175. event: [Object] original click event,
  1176. pointer: {
  1177. DOM: {x:pointer_x, y:pointer_y},
  1178. canvas: {x:canvas_x, y:canvas_y}
  1179. }
  1180. },
  1181. previousSelection: {
  1182. nodes: [Array of previously selected nodeIds],
  1183. edges: [Array of previously selected edgeIds]
  1184. }
  1185. }
  1186. </pre>
  1187. </td>
  1188. <td>Fired when a node (or nodes) has (or have) been deselected by the user. The previous selection is
  1189. the
  1190. list of nodes and edges that were selected before the last user event.
  1191. </td>
  1192. </tr>
  1193. <tr class="">
  1194. <td>deselectEdge</td>
  1195. <td>same as <code>deselectNode</code>.</td>
  1196. <td>Fired when a edge (or edges) has (or have) been deselected by the user. The previous selection is
  1197. the
  1198. list of nodes and edges that were selected before the last user event.
  1199. </td>
  1200. </tr>
  1201. <tr class="">
  1202. <td>dragStart</td>
  1203. <td>same as <code>click</code>.</td>
  1204. <td>Fired when starting a drag.</td>
  1205. </tr>
  1206. <tr class="">
  1207. <td>dragging</td>
  1208. <td>same as <code>click</code>.</td>
  1209. <td>Fired when dragging node(s) or the view.</td>
  1210. </tr>
  1211. <tr class="">
  1212. <td>dragEnd</td>
  1213. <td>same as <code>click</code>.</td>
  1214. <td>Fired when the drag has finished.</td>
  1215. </tr>
  1216. <tr class="">
  1217. <td>zoom</td>
  1218. <td><code>{direction:'+'/'-', scale: Number}</code></td>
  1219. <td>Fired when the user zooms in or out. The properties tell you which direction the zoom is in. The scale is a number greater than 0, which is the same that you get with network.getScale().</td>
  1220. </tr>
  1221. <tr class="">
  1222. <td>showPopup</td>
  1223. <td><code>id of item corresponding to popup</code></td>
  1224. <td>Fired when the popup (tooltip) is shown.</td>
  1225. </tr>
  1226. <tr class="">
  1227. <td>hidePopup</td>
  1228. <td>none</td>
  1229. <td>Fired when the popup (tooltip) is hidden.</td>
  1230. </tr>
  1231. <tr class="subHeader ">
  1232. <td colspan="3">Events triggered the physics simulation. Can be used to trigger GUI updates.</td>
  1233. </tr>
  1234. <tr class="">
  1235. <td>startStabilizing</td>
  1236. <td>none</td>
  1237. <td>Fired when stabilization starts. This is also the case when you drag a node and the physics
  1238. simulation
  1239. restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.
  1240. </td>
  1241. <tr class="">
  1242. <td>stabilizationProgress</td>
  1243. <td>
  1244. <pre class="code">
  1245. {
  1246. iterations: Number // iterations so far,
  1247. total: Number // total iterations in options
  1248. }
  1249. </pre>
  1250. </td>
  1251. <td>Fired when a multiple of the <code>updateInterval</code> number of iterations is reached. This only
  1252. occurs in the 'hidden' stabilization.
  1253. </td>
  1254. </tr>
  1255. <tr class="">
  1256. <td>stabilizationIterationsDone</td>
  1257. <td>none</td>
  1258. <td>Fired when the 'hidden' stabilization finishes. This does not necessarily mean the network is
  1259. stabilized; it could also mean that the amount of iterations defined in the options has been
  1260. reached.
  1261. </td>
  1262. <tr class="">
  1263. <td>stabilized</td>
  1264. <td>
  1265. <pre class="code">
  1266. {
  1267. iterations: Number // iterations it took
  1268. }
  1269. </pre>
  1270. </td>
  1271. <td>Fired when the network has stabilized or when the <code>stopSimulation()</code> has been called. The
  1272. amount of iterations it took could be used to tweak the maximum amount of iterations needed to
  1273. stabilize
  1274. the network.
  1275. </td>
  1276. <tr class="subHeader">
  1277. <td colspan="3">Event triggered by the canvas.</td>
  1278. </tr>
  1279. <tr class="">
  1280. <td>resize</td>
  1281. <td>
  1282. <pre class="code">
  1283. {
  1284. width: Number // the new width of the canvas
  1285. height: Number // the new height of the canvas
  1286. oldWidth: Number // the old width of the canvas
  1287. oldHeight: Number // the old height of the canvas
  1288. }
  1289. </pre>
  1290. <ul>
  1291. </ul>
  1292. </td>
  1293. <td>Fired when the size of the canvas has been resized, either by a redraw call when the container div
  1294. has
  1295. changed in size, a setSize() call with new values or a setOptions() with new width and/or height
  1296. values.
  1297. </td>
  1298. </tr>
  1299. <tr class="subHeader ">
  1300. <td colspan="3">Events triggered by the rendering module. Can be used to draw custom elements on the
  1301. canvas.
  1302. </td>
  1303. </tr>
  1304. <tr class="">
  1305. <td>initRedraw</td>
  1306. <td>none</td>
  1307. <td>Fired before the redrawing begins. The simulation step has completed at this point. Can be used to
  1308. move
  1309. custom elements before starting drawing the new frame.
  1310. </td>
  1311. <tr class="">
  1312. <td>beforeDrawing</td>
  1313. <td><code>canvas context</code></td>
  1314. <td>Fired after the canvas has been cleared, scaled and translated to the viewing position but before
  1315. all
  1316. edges and nodes are drawn. Can be used to draw behind the network.
  1317. </td>
  1318. <tr class="">
  1319. <td>afterDrawing</td>
  1320. <td><code>canvas context</code></td>
  1321. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1322. </td>
  1323. </tr>
  1324. <tr class="subHeader">
  1325. <td colspan="3">Event triggered by the view module.</td>
  1326. </tr>
  1327. <tr class="">
  1328. <td>animationFinished</td>
  1329. <td>none</td>
  1330. <td>Fired when an animation is finished.</td>
  1331. </table>
  1332. </div>
  1333. <div id="dotParserDiv" class=" hidden">
  1334. <p>
  1335. Network supports data in the
  1336. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  1337. To use data in the DOT language, you can use the vis.network.convertDot converter to transform the DOT
  1338. language
  1339. into a vis.Network compatible nodes, edges and options objects. You can extend the options object with other
  1340. options if you'd like.
  1341. </p>
  1342. <p>
  1343. Example usage:
  1344. </p>
  1345. <pre class="prettyprint lang-js">
  1346. // provide data in the DOT language
  1347. var DOTstring = 'dinetwork {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }';
  1348. var parsedData = vis.network.convertDot(DOTstring);
  1349. var data = {
  1350. nodes: parsedData.nodes,
  1351. edges: parsedData.edges
  1352. }
  1353. var options = parsedData.options;
  1354. // you can extend the options like a normal JSON variable:
  1355. options.nodes = {
  1356. color: 'red'
  1357. }
  1358. // create a network
  1359. var network = new vis.Network(container, data, options);
  1360. </pre>
  1361. </div>
  1362. <div id="gephiDiv" class=" hidden">
  1363. <p>
  1364. Network can import data straight from an exported json file from gephi. You can get the JSON exporter here:
  1365. <a href="https://marketplace.gephi.org/plugin/json-exporter/" target="_blank">https://marketplace.gephi.org/plugin/json-exporter/</a>.
  1366. An example exists showing how to get a JSON file into Vis: <a
  1367. href="../examples/network/30_importing_from_gephi.html">30_importing_from_gephi</a>.
  1368. </p>
  1369. <p>
  1370. Example usage:
  1371. </p>
  1372. <pre class="prettyprint lang-js">
  1373. // load the JSON file containing the Gephi network.
  1374. var gephiJSON = loadJSON("./data/WorldCup2014.json"); // code in example 30
  1375. // you can customize the result like with these options. These are explained below.
  1376. // These are the default options.
  1377. var parserOptions = {
  1378. edges: {
  1379. inheritColors: false
  1380. },
  1381. nodes: {
  1382. fixed: true,
  1383. parseColor: false
  1384. }
  1385. }
  1386. // parse the gephi file to receive an object
  1387. // containing nodes and edges in vis format.
  1388. var parsed = vis.network.convertGephi(gephiJSON, parserOptions);
  1389. // provide data in the normal fashion
  1390. var data = {
  1391. nodes: parsed.nodes,
  1392. edged: parsed.edges
  1393. };
  1394. // create a network
  1395. var network = new vis.Network(container, data);
  1396. </pre>
  1397. <br>
  1398. <h4>Gephi parser options</h4>
  1399. There are a few options you can use to tell Vis what to do with the data from Gephi.
  1400. <table class="options">
  1401. <tr>
  1402. <th>Name</th>
  1403. <th>Type</th>
  1404. <th>Default</th>
  1405. <th>Description</th>
  1406. </tr>
  1407. <tr>
  1408. <td>nodes.fixed</td>
  1409. <td>Boolean</td>
  1410. <td><code>true</code></td>
  1411. <td>When false, the nodes will move according to the physics model after import. If true, the nodes do
  1412. not move at all. If set to true, the node positions have to be defined to avoid infinite recursion
  1413. errors in the physics.
  1414. </td>
  1415. </tr>
  1416. <tr>
  1417. <td>nodes.parseColor</td>
  1418. <td>Boolean</td>
  1419. <td><code>false</code></td>
  1420. <td>If true, the color will be parsed by the vis parser, generating extra colors for the borders,
  1421. highlighs and hover. If false, the node will be the supplied color.
  1422. </td>
  1423. </tr>
  1424. <tr>
  1425. <td>edges.inheritColor</td>
  1426. <td>Boolean</td>
  1427. <td><code>false</code></td>
  1428. <td>When true, the color supplied by gephi is ignored and the inherit color mode is used with the global
  1429. setting.
  1430. </td>
  1431. </tr>
  1432. </table>
  1433. </div>
  1434. </div>
  1435. <!-- Bootstrap core JavaScript
  1436. ================================================== -->
  1437. <!-- Placed at the end of the document so the pages load faster -->
  1438. <script src="../js/jquery.min.js"></script>
  1439. <script src="../js/bootstrap.min.js"></script>
  1440. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  1441. <script src="../js/ie10-viewport-bug-workaround.js"></script>