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