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.

1500 lines
67 KiB

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