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.

1556 lines
71 KiB

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