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.

1523 lines
69 KiB

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