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.

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