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.

1526 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.</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</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.</td>
  748. </tr>
  749. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getEdges', this);">
  750. <td colspan="2"><span parent="getEdges" class="right-caret"></span> getEdges(<code><i>String
  751. nodeId</i></code>)
  752. </td>
  753. </tr>
  754. <tr class="hidden" parent="getEdges">
  755. <td class="midMethods">Returns: Array</td>
  756. <td>Returns an array of edgeIds of the edges connected to this node.</td>
  757. </tr>
  758. <tr class="subHeader">
  759. <td colspan="2">Physics methods to control when the simulation should run.</td>
  760. </tr>
  761. <tr class="collapsible toggle" onclick="toggleTable('methodTable','startSimulation', this);">
  762. <td colspan="2"><span parent="startSimulation" class="right-caret"></span> startSimulation()</td>
  763. </tr>
  764. <tr class="hidden" parent="startSimulation">
  765. <td class="midMethods">Returns: none</td>
  766. <td>Start the physics simulation. This is normally done whenever needed and is only really useful if you
  767. stop the simulation yourself and wish to continue it afterwards.
  768. </td>
  769. .</td></tr>
  770. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stopSimulation', this);">
  771. <td colspan="2"><span parent="stopSimulation" class="right-caret"></span> stopSimulation()</td>
  772. </tr>
  773. <tr class="hidden" parent="stopSimulation">
  774. <td class="midMethods">Returns: none</td>
  775. <td>This stops the physics simulation and triggers a <code>stabilized</code> event. It can be restarted
  776. by
  777. dragging a node, altering the dataset or calling <code>startSimulation()</code>.
  778. </td>
  779. </tr>
  780. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stabilize', this);">
  781. <td colspan="2"><span parent="stabilize" class="right-caret"></span> stabilize([iterations])</td>
  782. </tr>
  783. <tr class="hidden" parent="stabilize">
  784. <td class="midMethods">Returns: none</td>
  785. <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>
  786. </tr>
  787. <tr class="subHeader">
  788. <td colspan="2">Selection methods for nodes and edges.</td>
  789. </tr>
  790. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelection', this);">
  791. <td colspan="2"><span parent="getSelection" class="right-caret"></span> getSelection()</td>
  792. </tr>
  793. <tr class="hidden" parent="getSelection">
  794. <td class="midMethods">Returns: Object</td>
  795. <td>Returns an object with selected nodes and edges ids like this:
  796. <pre class="code">
  797. {
  798. nodes: [Array of selected nodeIds],
  799. edges: [Array of selected edgeIds]
  800. }</pre>
  801. </td>
  802. </tr>
  803. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedNodes', this);">
  804. <td colspan="2"><span parent="getSelectedNodes" class="right-caret"></span> getSelectedNodes()</td>
  805. </tr>
  806. <tr class="hidden" parent="getSelectedNodes">
  807. <td class="midMethods">Returns: Array</td>
  808. <td>Returns an array of selected node ids like so:
  809. <code>[nodeId1, nodeId2, ..]</code>.
  810. </td>
  811. </tr>
  812. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedEdges', this);">
  813. <td colspan="2"><span parent="getSelectedEdges" class="right-caret"></span> getSelectedEdges()</td>
  814. </tr>
  815. <tr class="hidden" parent="getSelectedEdges">
  816. <td class="midMethods">Returns: Array</td>
  817. <td>Returns an array of selected edge ids like so: <code>[edgeId1, edgeId2, ..]</code>.</td>
  818. </tr>
  819. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getNodeAt', this);">
  820. <td colspan="2"><span parent="getNodeAt" class="right-caret"></span> getNodeAt(<code><i>{x: xPosition
  821. DOM, y: yPosition DOM}</i></code>)
  822. </td>
  823. </tr>
  824. <tr class="hidden" parent="getNodeAt">
  825. <td class="midMethods">Returns: String</td>
  826. <td>Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left
  827. corner
  828. of the canvas.
  829. </td>
  830. </tr>
  831. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getEdgeAt', this);">
  832. <td colspan="2"><span parent="getEdgeAt" class="right-caret"></span> getEdgeAt(<code><i>{x: xPosition
  833. DOM, y: yPosition DOM}</i></code>)
  834. </td>
  835. </tr>
  836. <tr class="hidden" parent="getEdgeAt">
  837. <td class="midMethods">Returns: String</code></td>
  838. <td>Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left
  839. corner
  840. of the canvas..
  841. </td>
  842. </tr>
  843. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectNodes', this);">
  844. <td colspan="2"><span parent="selectNodes" class="right-caret"></span> selectNodes(<code><i>Array with
  845. nodeIds</i></code>,<code><i>[Boolean
  846. highlightEdges]</i></code>)
  847. </td>
  848. </tr>
  849. <tr class="hidden" parent="selectNodes">
  850. <td class="midMethods">Returns: none</td>
  851. <td>Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or
  852. undefined,
  853. the neighbouring edges will also be selected. This method unselects all other objects before
  854. selecting
  855. its own objects. <i>Does not fire events</i>.
  856. </td>
  857. </tr>
  858. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectEdges', this);">
  859. <td colspan="2"><span parent="selectEdges" class="right-caret"></span> selectEdges(<code><i>Array with
  860. edgeIds</i></code>)
  861. </td>
  862. </tr>
  863. <tr class="hidden" parent="selectEdges">
  864. <td class="midMethods">Returns: none</td>
  865. <td>Selects the edges corresponding to the id's in the input array. This method unselects all other
  866. objects
  867. before selecting its own objects. <i>Does not fire events</i>.
  868. </td>
  869. </tr>
  870. <tr class="collapsible toggle" onclick="toggleTable('methodTable','unselectAll', this);">
  871. <td colspan="2"><span parent="unselectAll" class="right-caret"></span> unselectAll()</td>
  872. </tr>
  873. <tr class="hidden" parent="unselectAll">
  874. <td class="midMethods">Returns: none</td>
  875. <td>Unselect all objects. <i>Does not fire events</i>.</td>
  876. </tr>
  877. <tr class="subHeader">
  878. <td colspan="2">Methods to control the viewport for zoom and animation.</td>
  879. </tr>
  880. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getScale', this);">
  881. <td colspan="2"><span parent="getScale" class="right-caret"></span> getScale()</td>
  882. </tr>
  883. <tr class="hidden" parent="getScale">
  884. <td class="midMethods">Returns: Number</td>
  885. <td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.
  886. </td>
  887. </tr>
  888. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
  889. <td colspan="2"><span parent="clusterByHubsize" class="right-caret"></span> getViewPosition()</td>
  890. </tr>
  891. <tr class="hidden" parent="clusterByHubsize">
  892. <td class="midMethods">Returns: Number</td>
  893. <td>Returns the current central focus point of the view.</td>
  894. </tr>
  895. <tr class="collapsible toggle" onclick="toggleTable('methodTable','fit', this);">
  896. <td colspan="2"><span parent="fit" class="right-caret"></span> fit(<code>[Object
  897. options]</code>)
  898. </td>
  899. </tr>
  900. <tr class="hidden" parent="fit">
  901. <td class="midMethods">Returns: none</td>
  902. <td>Zooms out so all nodes fit on the canvas. You can supply options to customize this:
  903. <pre class="code">
  904. {
  905. nodes:[Array of nodeIds],
  906. animation: { // -------------------> can be a boolean too!
  907. duration: Number
  908. easingFunction: String
  909. }
  910. }
  911. </pre>
  912. The nodes can be used to zoom to fit only specific nodes in the view. <br/><br/>
  913. The other options are explained in the <code>moveTo()</code> description below.
  914. All options are optional for the fit method.
  915. </td>
  916. </tr>
  917. <tr class="collapsible toggle" onclick="toggleTable('methodTable','focus', this);">
  918. <td colspan="2"><span parent="focus" class="right-caret"></span> focus(
  919. <code>String nodeId</code>,
  920. <code>[Object options]</code>)
  921. </td>
  922. </tr>
  923. <tr class="hidden" parent="focus">
  924. <td class="midMethods">Returns: none</td>
  925. <td>You can focus on a node with this function. What that means is the view will lock onto that node, if
  926. it
  927. is moving, the view will also move accordingly. If the view is dragged by the user, the focus is
  928. broken.
  929. You can supply options to customize the effect:
  930. <pre class="code">
  931. {
  932. scale: Number,
  933. offset: {x:Number, y:Number}
  934. locked: boolean
  935. animation: { // -------------------> can be a boolean too!
  936. duration: Number
  937. easingFunction: String
  938. }
  939. }
  940. </pre>
  941. All options except for locked are explained in the <code>moveTo()</code> description below. Locked
  942. denotes whether or not the view remains locked to the node once the zoom-in animation is finished.
  943. Default value is true. The options object is optional in the focus method.
  944. </td>
  945. </tr>
  946. <tr class="collapsible toggle" onclick="toggleTable('methodTable','moveTo', this);">
  947. <td colspan="2"><span parent="moveTo" class="right-caret"></span> moveTo(<code>Object
  948. options</code>)
  949. </td>
  950. </tr>
  951. <tr class="hidden" parent="moveTo">
  952. <td class="midMethods">Returns: none</td>
  953. <td>You can animate or move the camera using the moveTo method. Options are:
  954. <pre class="code">
  955. {
  956. position: {x:Number, y:Number},
  957. scale: Number,
  958. offset: {x:Number, y:Number}
  959. animation: { // -------------------> can be a boolean too!
  960. duration: Number
  961. easingFunction: String
  962. }
  963. }
  964. </pre>
  965. The position (in canvas units!) is the position of the central focus point of the camera.
  966. The scale is the target zoomlevel. Default value is 1.0.
  967. The offset (in DOM units) is how many pixels from the center the view is focussed. Default value is
  968. {x:0,y:0}.
  969. For animation you can either use a Boolean to use it with the default options or disable it or you
  970. can
  971. define the duration (in milliseconds) and easing function manually. Available are:
  972. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  973. easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint</code>.
  974. <i>You will have to define at least a scale or a position. Otherwise, there is nothing to move
  975. to.</i>
  976. </td>
  977. </tr>
  978. <tr class="collapsible toggle" onclick="toggleTable('methodTable','releaseNode', this);">
  979. <td colspan="2"><span parent="releaseNode" class="right-caret"></span> releaseNode()</td>
  980. </tr>
  981. <tr class="hidden" parent="releaseNode">
  982. <td class="midMethods">Returns: none</td>
  983. <td>Programatically release the focussed node.</td>
  984. </tr>
  985. </table>
  986. <br>
  987. <br>
  988. <h4 id="optionsObject">Cluster methods options object</h4>
  989. <p>The options object supplied to the cluster functions can contain these properties:</p>
  990. <table class="methods">
  991. <tr>
  992. <th>Name</th>
  993. <th>Type</th>
  994. <th>Description</th>
  995. </tr>
  996. <tr>
  997. <td>joinCondition(<br>&nbsp;&nbsp;<code>nodeOptions:&nbsp;Object</code><br>)</td>
  998. <td>Function</td>
  999. <td><i>Optional for all but the cluster method. </i> The cluster module loops over all nodes that are
  1000. selected to be in the cluster and calls this function with their data as argument.
  1001. If this function returns true, this node will be added to the cluster. You have access to all
  1002. options
  1003. (including the default)
  1004. as well as any custom fields you may have added to the node to determine whether or not to include
  1005. it in
  1006. the cluster. Example:
  1007. <pre class="prettyprint lang-js">
  1008. var nodes = [
  1009. {id: 4, label: 'Node 4'},
  1010. {id: 5, label: 'Node 5'},
  1011. {id: 6, label: 'Node 6', cid:1},
  1012. {id: 7, label: 'Node 7', cid:1}
  1013. ]
  1014. var options = {
  1015. joinCondition:function(nodeOptions) {
  1016. return nodeOptions.cid === 1;
  1017. }
  1018. }
  1019. network.clustering.cluster(options);
  1020. </pre>
  1021. </td>
  1022. </tr>
  1023. <tr>
  1024. <td>processProperties(<br>&nbsp;&nbsp;<code>clusterOptions:&nbsp;Object</code>,<br>
  1025. &nbsp;&nbsp;<code>childNodesOptions:&nbsp;Array</code>,<br>
  1026. &nbsp;&nbsp;<code>childEdgesOptions:&nbsp;Array</code><br>)</td>
  1027. <td>Function</td>
  1028. <td><i>Optional. </i> Before creating the new cluster node, this (optional) function will be called with
  1029. the
  1030. properties supplied by you (<code>clusterNodeProperties</code>), all contained nodes and all
  1031. contained
  1032. edges. You can use this to update the
  1033. properties of the cluster based on which items it contains. The function should return the
  1034. properties to
  1035. create the cluster node. In the example below, we ensure preservation of mass and value when forming
  1036. the
  1037. cluster:
  1038. <pre class="prettyprint lang-js">
  1039. var options = {
  1040. processProperties: function (clusterOptions,
  1041. childNodes, childEdges) {
  1042. var totalMass = 0;
  1043. var totalValue = 0;
  1044. for (var i = 0; i < childNodes.length; i++) {
  1045. totalMass += childNodes[i].mass;
  1046. totalValue = childNodes[i].value
  1047. ? totalValue + childNodes[i].value
  1048. : totalValue;
  1049. }
  1050. clusterOptions.mass = totalMass;
  1051. if (totalValue > 0) {
  1052. clusterOptions.value = totalValue;
  1053. }
  1054. return clusterOptions;
  1055. },
  1056. }
  1057. </pre>
  1058. </td>
  1059. </tr>
  1060. <tr>
  1061. <td>clusterNodeProperties</td>
  1062. <td>Object</td>
  1063. <td><i>Optional. </i> This is an object containing the options for the cluster node. All options
  1064. described
  1065. in the <a href="./nodes.html">nodes module</a> are allowed. This allows you to style your cluster
  1066. node
  1067. any way you want. This is also the style object that is provided in the processProperties function
  1068. for
  1069. fine tuning. If undefined, default node options will be used.
  1070. </td>
  1071. </tr>
  1072. <tr>
  1073. <td>clusterEdgeProperties</td>
  1074. <td>Object</td>
  1075. <td><i>Optional. </i> This is an object containing the options for the edges connected to the cluster.
  1076. All
  1077. options described in the <a href="./edges.html">edges module</a> are allowed. Using this, you can
  1078. style
  1079. the edges connecting to the cluster any way you want. If none are provided, the optoins from the
  1080. edges
  1081. that are replaced are used. If undefined, default edge options will be used.
  1082. </td>
  1083. </tr>
  1084. </table>
  1085. </div>
  1086. <div id="eventsDiv" class=" hidden">
  1087. <h3>All Events</h3>
  1088. <p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
  1089. <p>These events are fired by the interaction module. They are related to user input.</p>
  1090. <table class="events">
  1091. <tr>
  1092. <th>Name</th>
  1093. <th>Properties</th>
  1094. <th>Description</th>
  1095. </tr>
  1096. <tr class="subHeader">
  1097. <td colspan="3">Events triggered by human interaction, selection, dragging etc.</td>
  1098. </tr>
  1099. <tr class="">
  1100. <td>click</td>
  1101. <td>
  1102. <pre class="code">
  1103. {
  1104. nodes: [Array of selected nodeIds],
  1105. edges: [Array of selected edgeIds],
  1106. event: [Object] original click event,
  1107. pointer: {
  1108. DOM: {x:pointer_x, y:pointer_y},
  1109. canvas: {x:canvas_x, y:canvas_y}
  1110. }
  1111. }
  1112. </pre>
  1113. </td>
  1114. <td>Fired when the user clicks the mouse or taps on a touchscreen device.</td>
  1115. </tr>
  1116. <tr class="">
  1117. <td>doubleClick</td>
  1118. <td>same as <code>click</code>.</td>
  1119. <td>Fired when the user double clicks the mouse or double taps on a touchscreen device. Since a double
  1120. click
  1121. is in fact 2 clicks, 2 click events are fired, followed by a double click event. If you do not want
  1122. to
  1123. use the click events if a double click event is fired, just check the time between click events
  1124. before
  1125. processing them.
  1126. </td>
  1127. </tr>
  1128. <tr class="">
  1129. <td>oncontext</td>
  1130. <td>same as <code>click</code>.</td>
  1131. <td>Fired when the user click on the canvas with the right mouse button. The right mouse button does not
  1132. select by default. You can use <a href="./selection.html">getNodeAt</a> to select the node if you
  1133. want.
  1134. </td>
  1135. </tr>
  1136. <tr class="">
  1137. <td>hold</td>
  1138. <td>same as <code>click</code>.</td>
  1139. <td>Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device. A click
  1140. event
  1141. is also fired in this case.
  1142. </td>
  1143. </tr>
  1144. <tr class="">
  1145. <td>release</td>
  1146. <td>same as <code>click</code>.</td>
  1147. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1148. </td>
  1149. </tr>
  1150. <tr class="">
  1151. <td>select</td>
  1152. <td>same as <code>click</code>.</td>
  1153. <td>Fired when the selection has changed by user action. This means a node or edge has been selected,
  1154. added
  1155. to the selection or deselected. <b>All select events are only triggered on click and hold</b>.
  1156. </td>
  1157. </tr>
  1158. <tr class="">
  1159. <td>selectNode</td>
  1160. <td>same as <code>click</code>.</td>
  1161. <td>Fired when a node has been selected by the user.</td>
  1162. </tr>
  1163. <tr class="">
  1164. <td>selectEdge</td>
  1165. <td>same as <code>click</code>.</td>
  1166. <td>Fired when a edge has been selected by the user.</td>
  1167. </tr>
  1168. <tr class="">
  1169. <td>deselectNode</td>
  1170. <td><pre class="code">
  1171. {
  1172. nodes: [Array of selected nodeIds],
  1173. edges: [Array of selected edgeIds],
  1174. event: [Object] original click event,
  1175. pointer: {
  1176. DOM: {x:pointer_x, y:pointer_y},
  1177. canvas: {x:canvas_x, y:canvas_y}
  1178. }
  1179. },
  1180. previousSelection: {
  1181. nodes: [Array of previously selected nodeIds],
  1182. edges: [Array of previously selected edgeIds]
  1183. }
  1184. }
  1185. </pre>
  1186. </td>
  1187. <td>Fired when a node (or nodes) has (or have) been deselected by the user. The previous selection is
  1188. the
  1189. list of nodes and edges that were selected before the last user event.
  1190. </td>
  1191. </tr>
  1192. <tr class="">
  1193. <td>deselectEdge</td>
  1194. <td>same as <code>deselectNode</code>.</td>
  1195. <td>Fired when a edge (or edges) has (or have) been deselected by the user. The previous selection is
  1196. the
  1197. list of nodes and edges that were selected before the last user event.
  1198. </td>
  1199. </tr>
  1200. <tr class="">
  1201. <td>dragStart</td>
  1202. <td>same as <code>click</code>.</td>
  1203. <td>Fired when starting a drag.</td>
  1204. </tr>
  1205. <tr class="">
  1206. <td>dragging</td>
  1207. <td>same as <code>click</code>.</td>
  1208. <td>Fired when dragging node(s) or the view.</td>
  1209. </tr>
  1210. <tr class="">
  1211. <td>dragEnd</td>
  1212. <td>same as <code>click</code>.</td>
  1213. <td>Fired when the drag has finished.</td>
  1214. </tr>
  1215. <tr class="">
  1216. <td>zoom</td>
  1217. <td><code>{direction:'+'/'-', scale: Number}</code></td>
  1218. <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>
  1219. </tr>
  1220. <tr class="">
  1221. <td>showPopup</td>
  1222. <td><code>id of item corresponding to popup</code></td>
  1223. <td>Fired when the popup (tooltip) is shown.</td>
  1224. </tr>
  1225. <tr class="">
  1226. <td>hidePopup</td>
  1227. <td>none</td>
  1228. <td>Fired when the popup (tooltip) is hidden.</td>
  1229. </tr>
  1230. <tr class="subHeader ">
  1231. <td colspan="3">Events triggered the physics simulation. Can be used to trigger GUI updates.</td>
  1232. </tr>
  1233. <tr class="">
  1234. <td>startStabilizing</td>
  1235. <td>none</td>
  1236. <td>Fired when stabilization starts. This is also the case when you drag a node and the physics
  1237. simulation
  1238. restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.
  1239. </td>
  1240. <tr class="">
  1241. <td>stabilizationProgress</td>
  1242. <td>
  1243. <pre class="code">
  1244. {
  1245. iterations: Number // iterations so far,
  1246. total: Number // total iterations in options
  1247. }
  1248. </pre>
  1249. </td>
  1250. <td>Fired when a multiple of the <code>updateInterval</code> number of iterations is reached. This only
  1251. occurs in the 'hidden' stabilization.
  1252. </td>
  1253. </tr>
  1254. <tr class="">
  1255. <td>stabilizationIterationsDone</td>
  1256. <td>none</td>
  1257. <td>Fired when the 'hidden' stabilization finishes. This does not necessarily mean the network is
  1258. stabilized; it could also mean that the amount of iterations defined in the options has been
  1259. reached.
  1260. </td>
  1261. <tr class="">
  1262. <td>stabilized</td>
  1263. <td>
  1264. <pre class="code">
  1265. {
  1266. iterations: Number // iterations it took
  1267. }
  1268. </pre>
  1269. </td>
  1270. <td>Fired when the network has stabilized or when the <code>stopSimulation()</code> has been called. The
  1271. amount of iterations it took could be used to tweak the maximum amount of iterations needed to
  1272. stabilize
  1273. the network.
  1274. </td>
  1275. <tr class="subHeader">
  1276. <td colspan="3">Event triggered by the canvas.</td>
  1277. </tr>
  1278. <tr class="">
  1279. <td>resize</td>
  1280. <td>
  1281. <pre class="code">
  1282. {
  1283. width: Number // the new width of the canvas
  1284. height: Number // the new height of the canvas
  1285. oldWidth: Number // the old width of the canvas
  1286. oldHeight: Number // the old height of the canvas
  1287. }
  1288. </pre>
  1289. <ul>
  1290. </ul>
  1291. </td>
  1292. <td>Fired when the size of the canvas has been resized, either by a redraw call when the container div
  1293. has
  1294. changed in size, a setSize() call with new values or a setOptions() with new width and/or height
  1295. values.
  1296. </td>
  1297. </tr>
  1298. <tr class="subHeader ">
  1299. <td colspan="3">Events triggered by the rendering module. Can be used to draw custom elements on the
  1300. canvas.
  1301. </td>
  1302. </tr>
  1303. <tr class="">
  1304. <td>initRedraw</td>
  1305. <td>none</td>
  1306. <td>Fired before the redrawing begins. The simulation step has completed at this point. Can be used to
  1307. move
  1308. custom elements before starting drawing the new frame.
  1309. </td>
  1310. <tr class="">
  1311. <td>beforeDrawing</td>
  1312. <td><code>canvas context</code></td>
  1313. <td>Fired after the canvas has been cleared, scaled and translated to the viewing position but before
  1314. all
  1315. edges and nodes are drawn. Can be used to draw behind the network.
  1316. </td>
  1317. <tr class="">
  1318. <td>afterDrawing</td>
  1319. <td><code>canvas context</code></td>
  1320. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1321. </td>
  1322. </tr>
  1323. <tr class="subHeader">
  1324. <td colspan="3">Event triggered by the view module.</td>
  1325. </tr>
  1326. <tr class="">
  1327. <td>animationFinished</td>
  1328. <td>none</td>
  1329. <td>Fired when an animation is finished.</td>
  1330. </table>
  1331. </div>
  1332. <div id="dotParserDiv" class=" hidden">
  1333. <p>
  1334. Network supports data in the
  1335. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  1336. To use data in the DOT language, you can use the vis.network.convertDot converter to transform the DOT
  1337. language
  1338. into a vis.Network compatible nodes, edges and options objects. You can extend the options object with other
  1339. options if you'd like.
  1340. </p>
  1341. <p>
  1342. Example usage:
  1343. </p>
  1344. <pre class="prettyprint lang-js">
  1345. // provide data in the DOT language
  1346. var DOTstring = 'dinetwork {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }';
  1347. var parsedData = vis.network.convertDot(DOTstring);
  1348. var data = {
  1349. nodes: parsedData.nodes,
  1350. edges: parsedData.edges
  1351. }
  1352. var options = parsedData.options;
  1353. // you can extend the options like a normal JSON variable:
  1354. options.nodes = {
  1355. color: 'red'
  1356. }
  1357. // create a network
  1358. var network = new vis.Network(container, data, options);
  1359. </pre>
  1360. </div>
  1361. <div id="gephiDiv" class=" hidden">
  1362. <p>
  1363. Network can import data straight from an exported json file from gephi. You can get the JSON exporter here:
  1364. <a href="https://marketplace.gephi.org/plugin/json-exporter/" target="_blank">https://marketplace.gephi.org/plugin/json-exporter/</a>.
  1365. An example exists showing how to get a JSON file into Vis: <a
  1366. href="../examples/network/30_importing_from_gephi.html">30_importing_from_gephi</a>.
  1367. </p>
  1368. <p>
  1369. Example usage:
  1370. </p>
  1371. <pre class="prettyprint lang-js">
  1372. // load the JSON file containing the Gephi network.
  1373. var gephiJSON = loadJSON("./data/WorldCup2014.json"); // code in example 30
  1374. // you can customize the result like with these options. These are explained below.
  1375. // These are the default options.
  1376. var parserOptions = {
  1377. edges: {
  1378. inheritColors: false
  1379. },
  1380. nodes: {
  1381. fixed: true,
  1382. parseColor: false
  1383. }
  1384. }
  1385. // parse the gephi file to receive an object
  1386. // containing nodes and edges in vis format.
  1387. var parsed = vis.network.convertGephi(gephiJSON, parserOptions);
  1388. // provide data in the normal fashion
  1389. var data = {
  1390. nodes: parsed.nodes,
  1391. edged: parsed.edges
  1392. };
  1393. // create a network
  1394. var network = new vis.Network(container, data);
  1395. </pre>
  1396. <br>
  1397. <h4>Gephi parser options</h4>
  1398. There are a few options you can use to tell Vis what to do with the data from Gephi.
  1399. <table class="options">
  1400. <tr>
  1401. <th>Name</th>
  1402. <th>Type</th>
  1403. <th>Default</th>
  1404. <th>Description</th>
  1405. </tr>
  1406. <tr>
  1407. <td>nodes.fixed</td>
  1408. <td>Boolean</td>
  1409. <td><code>true</code></td>
  1410. <td>When false, the nodes will move according to the physics model after import. If true, the nodes do
  1411. not move at all. If set to true, the node positions have to be defined to avoid infinite recursion
  1412. errors in the physics.
  1413. </td>
  1414. </tr>
  1415. <tr>
  1416. <td>nodes.parseColor</td>
  1417. <td>Boolean</td>
  1418. <td><code>false</code></td>
  1419. <td>If true, the color will be parsed by the vis parser, generating extra colors for the borders,
  1420. highlighs and hover. If false, the node will be the supplied color.
  1421. </td>
  1422. </tr>
  1423. <tr>
  1424. <td>edges.inheritColor</td>
  1425. <td>Boolean</td>
  1426. <td><code>false</code></td>
  1427. <td>When true, the color supplied by gephi is ignored and the inherit color mode is used with the global
  1428. setting.
  1429. </td>
  1430. </tr>
  1431. </table>
  1432. </div>
  1433. </div>
  1434. <!-- Bootstrap core JavaScript
  1435. ================================================== -->
  1436. <!-- Placed at the end of the document so the pages load faster -->
  1437. <script src="../js/jquery.min.js"></script>
  1438. <script src="../js/bootstrap.min.js"></script>
  1439. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  1440. <script src="../js/ie10-viewport-bug-workaround.js"></script>