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.

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