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.

1589 lines
73 KiB

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