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.

1493 lines
66 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. 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="methods">
  961. <tr>
  962. <th>Name</th>
  963. <th>Type</th>
  964. <th>Description</th>
  965. </tr>
  966. <tr>
  967. <td>joinCondition(<br>&nbsp;&nbsp;<code>nodeOptions:&nbsp;Object</code><br>)</td>
  968. <td>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>nodeOptions:&nbsp;Object</code><br>)</td>
  995. <td>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,
  1009. childNodes, childEdges) {
  1010. var totalMass = 0;
  1011. var totalValue = 0;
  1012. for (var i = 0; i < childNodes.length; i++) {
  1013. totalMass += childNodes[i].mass;
  1014. totalValue = childNodes[i].value
  1015. ? totalValue + childNodes[i].value
  1016. : totalValue;
  1017. }
  1018. clusterOptions.mass = totalMass;
  1019. if (totalValue > 0) {
  1020. clusterOptions.value = totalValue;
  1021. }
  1022. return clusterOptions;
  1023. },
  1024. }
  1025. </pre>
  1026. </td>
  1027. </tr>
  1028. <tr>
  1029. <td>clusterNodeProperties</td>
  1030. <td>Object</td>
  1031. <td><i>Optional. </i> This is an object containing the options for the cluster node. All options
  1032. described
  1033. in the <a href="./nodes.html">nodes module</a> are allowed. This allows you to style your cluster
  1034. node
  1035. any way you want. This is also the style object that is provided in the processProperties function
  1036. for
  1037. fine tuning. If undefined, default node options will be used.
  1038. </td>
  1039. </tr>
  1040. <tr>
  1041. <td>clusterEdgeProperties</td>
  1042. <td>Object</td>
  1043. <td><i>Optional. </i> This is an object containing the options for the edges connected to the cluster.
  1044. All
  1045. options described in the <a href="./edges.html">edges module</a> are allowed. Using this, you can
  1046. style
  1047. the edges connecting to the cluster any way you want. If none are provided, the optoins from the
  1048. edges
  1049. that are replaced are used. If undefined, default edge options will be used.
  1050. </td>
  1051. </tr>
  1052. </table>
  1053. </div>
  1054. <div id="eventsDiv" class=" hidden">
  1055. <h3>All Events</h3>
  1056. <p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
  1057. <p>These events are fired by the interaction module. They are related to user input.</p>
  1058. <table class="events">
  1059. <tr>
  1060. <th>Name</th>
  1061. <th>Properties</th>
  1062. <th>Description</th>
  1063. </tr>
  1064. <tr class="subHeader">
  1065. <td colspan="3">Events triggered by human interaction, selection, dragging etc.</td>
  1066. </tr>
  1067. <tr class="">
  1068. <td>click</td>
  1069. <td>
  1070. <pre class="code">
  1071. {
  1072. nodes: [Array of selected nodeIds],
  1073. edges: [Array of selected edgeIds],
  1074. event: [Object] original click event,
  1075. pointer: {
  1076. DOM: {x:pointer_x, y:pointer_y},
  1077. canvas: {x:canvas_x, y:canvas_y}
  1078. }
  1079. }
  1080. </pre>
  1081. </td>
  1082. <td>Fired when the user clicks the mouse or taps on a touchscreen device.</td>
  1083. </tr>
  1084. <tr class="">
  1085. <td>doubleClick</td>
  1086. <td>same as <code>click</code>.</td>
  1087. <td>Fired when the user double clicks the mouse or double taps on a touchscreen device. Since a double
  1088. click
  1089. is in fact 2 clicks, 2 click events are fired, followed by a double click event. If you do not want
  1090. to
  1091. use the click events if a double click event is fired, just check the time between click events
  1092. before
  1093. processing them.
  1094. </td>
  1095. </tr>
  1096. <tr class="">
  1097. <td>oncontext</td>
  1098. <td>same as <code>click</code>.</td>
  1099. <td>Fired when the user click on the canvas with the right mouse button. The right mouse button does not
  1100. select by default. You can use <a href="./selection.html">getNodeAt</a> to select the node if you
  1101. want.
  1102. </td>
  1103. </tr>
  1104. <tr class="">
  1105. <td>hold</td>
  1106. <td>same as <code>click</code>.</td>
  1107. <td>Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device. A click
  1108. event
  1109. is also fired in this case.
  1110. </td>
  1111. </tr>
  1112. <tr class="">
  1113. <td>release</td>
  1114. <td>same as <code>click</code>.</td>
  1115. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1116. </td>
  1117. </tr>
  1118. <tr class="">
  1119. <td>select</td>
  1120. <td>same as <code>click</code>.</td>
  1121. <td>Fired when the selection has changed by user action. This means a node or edge has been selected,
  1122. added
  1123. to the selection or deselected. <b>All select events are only triggered on click and hold</b>.
  1124. </td>
  1125. </tr>
  1126. <tr class="">
  1127. <td>selectNode</td>
  1128. <td>same as <code>click</code>.</td>
  1129. <td>Fired when a node has been selected by the user.</td>
  1130. </tr>
  1131. <tr class="">
  1132. <td>selectEdge</td>
  1133. <td>same as <code>click</code>.</td>
  1134. <td>Fired when a edge has been selected by the user.</td>
  1135. </tr>
  1136. <tr class="">
  1137. <td>deselectNode</td>
  1138. <td><pre class="code">
  1139. {
  1140. nodes: [Array of selected nodeIds],
  1141. edges: [Array of selected edgeIds],
  1142. event: [Object] original click event,
  1143. pointer: {
  1144. DOM: {x:pointer_x, y:pointer_y},
  1145. canvas: {x:canvas_x, y:canvas_y}
  1146. }
  1147. },
  1148. previousSelection: {
  1149. nodes: [Array of previously selected nodeIds],
  1150. edges: [Array of previously selected edgeIds]
  1151. }
  1152. }
  1153. </pre>
  1154. </td>
  1155. <td>Fired when a node (or nodes) has (or have) been deselected by the user. The previous selection is
  1156. the
  1157. list of nodes and edges that were selected before the last user event.
  1158. </td>
  1159. </tr>
  1160. <tr class="">
  1161. <td>deselectEdge</td>
  1162. <td>same as <code>deselectNode</code>.</td>
  1163. <td>Fired when a edge (or edges) has (or have) been deselected by the user. The previous selection is
  1164. the
  1165. list of nodes and edges that were selected before the last user event.
  1166. </td>
  1167. </tr>
  1168. <tr class="">
  1169. <td>dragStart</td>
  1170. <td>same as <code>click</code>.</td>
  1171. <td>Fired when starting a drag.</td>
  1172. </tr>
  1173. <tr class="">
  1174. <td>dragging</td>
  1175. <td>same as <code>click</code>.</td>
  1176. <td>Fired when dragging node(s) or the view.</td>
  1177. </tr>
  1178. <tr class="">
  1179. <td>dragEnd</td>
  1180. <td>same as <code>click</code>.</td>
  1181. <td>Fired when the drag has finished.</td>
  1182. </tr>
  1183. <tr class="">
  1184. <td>zoom</td>
  1185. <td><code>{direction:'+'/'-'}</code></td>
  1186. <td>Fired when the user zooms in or out. The properties tell you which direction the zoom is in.</td>
  1187. </tr>
  1188. <tr class="">
  1189. <td>showPopup</td>
  1190. <td><code>id of item corresponding to popup</code></td>
  1191. <td>Fired when the popup (tooltip) is shown.</td>
  1192. </tr>
  1193. <tr class="">
  1194. <td>hidePopup</td>
  1195. <td>none</td>
  1196. <td>Fired when the popup (tooltip) is hidden.</td>
  1197. </tr>
  1198. <tr class="subHeader ">
  1199. <td colspan="3">Events triggered the physics simulation. Can be used to trigger GUI updates.</td>
  1200. </tr>
  1201. <tr class="">
  1202. <td>startStabilizing</td>
  1203. <td>none</td>
  1204. <td>Fired when stabilization starts. This is also the case when you drag a node and the physics
  1205. simulation
  1206. restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.
  1207. </td>
  1208. <tr class="">
  1209. <td>stabilizationProgress</td>
  1210. <td>
  1211. <pre class="code">
  1212. {
  1213. iterations: Number // iterations so far,
  1214. total: Number // total iterations in options
  1215. }
  1216. </pre>
  1217. </td>
  1218. <td>Fired when a multiple of the <code>updateInterval</code> number of iterations is reached. This only
  1219. occurs in the 'hidden' stabilization.
  1220. </td>
  1221. </tr>
  1222. <tr class="">
  1223. <td>stabilizationIterationsDone</td>
  1224. <td>none</td>
  1225. <td>Fired when the 'hidden' stabilization finishes. This does not necessarily mean the network is
  1226. stabilized; it could also mean that the amount of iterations defined in the options has been
  1227. reached.
  1228. </td>
  1229. <tr class="">
  1230. <td>stabilized</td>
  1231. <td>
  1232. <pre class="code">
  1233. {
  1234. iterations: Number // iterations it took
  1235. }
  1236. </pre>
  1237. </td>
  1238. <td>Fired when the network has stabilized or when the <code>stopSimulation()</code> has been called. The
  1239. amount of iterations it took could be used to tweak the maximum amount of iterations needed to
  1240. stabilize
  1241. the network.
  1242. </td>
  1243. <tr class="subHeader">
  1244. <td colspan="3">Event triggered by the canvas.</td>
  1245. </tr>
  1246. <tr class="">
  1247. <td>resize</td>
  1248. <td>
  1249. <pre class="code">
  1250. {
  1251. width: Number // the new width of the canvas
  1252. height: Number // the new height of the canvas
  1253. oldWidth: Number // the old width of the canvas
  1254. oldHeight: Number // the old height of the canvas
  1255. }
  1256. </pre>
  1257. <ul>
  1258. </ul>
  1259. </td>
  1260. <td>Fired when the size of the canvas has been resized, either by a redraw call when the container div
  1261. has
  1262. changed in size, a setSize() call with new values or a setOptions() with new width and/or height
  1263. values.
  1264. </td>
  1265. </tr>
  1266. <tr class="subHeader ">
  1267. <td colspan="3">Events triggered by the rendering module. Can be used to draw custom elements on the
  1268. canvas.
  1269. </td>
  1270. </tr>
  1271. <tr class="">
  1272. <td>initRedraw</td>
  1273. <td>none</td>
  1274. <td>Fired before the redrawing begins. The simulation step has completed at this point. Can be used to
  1275. move
  1276. custom elements before starting drawing the new frame.
  1277. </td>
  1278. <tr class="">
  1279. <td>beforeDrawing</td>
  1280. <td><code>canvas context</code></td>
  1281. <td>Fired after the canvas has been cleared, scaled and translated to the viewing position but before
  1282. all
  1283. edges and nodes are drawn. Can be used to draw behind the network.
  1284. </td>
  1285. <tr class="">
  1286. <td>afterDrawing</td>
  1287. <td><code>canvas context</code></td>
  1288. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1289. </td>
  1290. </tr>
  1291. <tr class="subHeader">
  1292. <td colspan="3">Event triggered by the view module.</td>
  1293. </tr>
  1294. <tr class="">
  1295. <td>animationFinished</td>
  1296. <td>none</td>
  1297. <td>Fired when an animation is finished.</td>
  1298. </table>
  1299. </div>
  1300. <div id="dotParserDiv" class=" hidden">
  1301. <p>
  1302. Network supports data in the
  1303. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  1304. To use data in the DOT language, you can use the vis.network.convertDot converter to transform the DOT
  1305. language
  1306. into a vis.Network compatible nodes, edges and options objects. You can extend the options object with other
  1307. options if you'd like.
  1308. </p>
  1309. <p>
  1310. Example usage:
  1311. </p>
  1312. <pre class="prettyprint lang-js">
  1313. // provide data in the DOT language
  1314. var DOTstring = 'dinetwork {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }';
  1315. var parsedData = vis.network.convertDot(DOTstring);
  1316. var data = {
  1317. nodes: parsedData.nodes,
  1318. edges: parsedData.edges
  1319. }
  1320. var options = parsedData.options;
  1321. // you can extend the options like a normal JSON variable:
  1322. options.nodes = {
  1323. color: 'red'
  1324. }
  1325. // create a network
  1326. var network = new vis.Network(container, data, options);
  1327. </pre>
  1328. </div>
  1329. <div id="gephiDiv" class=" hidden">
  1330. <p>
  1331. Network can import data straight from an exported json file from gephi. You can get the JSON exporter here:
  1332. <a href="https://marketplace.gephi.org/plugin/json-exporter/" target="_blank">https://marketplace.gephi.org/plugin/json-exporter/</a>.
  1333. An example exists showing how to get a JSON file into Vis: <a
  1334. href="../examples/network/30_importing_from_gephi.html">30_importing_from_gephi</a>.
  1335. </p>
  1336. <p>
  1337. Example usage:
  1338. </p>
  1339. <pre class="prettyprint lang-js">
  1340. // load the JSON file containing the Gephi network.
  1341. var gephiJSON = loadJSON("./data/WorldCup2014.json"); // code in example 30
  1342. // you can customize the result like with these options. These are explained below.
  1343. // These are the default options.
  1344. var parserOptions = {
  1345. edges: {
  1346. inheritColors: false
  1347. },
  1348. nodes: {
  1349. fixed: true,
  1350. parseColor: false
  1351. }
  1352. }
  1353. // parse the gephi file to receive an object
  1354. // containing nodes and edges in vis format.
  1355. var parsed = vis.network.convertGephi(gephiJSON, parserOptions);
  1356. // provide data in the normal fashion
  1357. var data = {
  1358. nodes: parsed.nodes,
  1359. edged: parsed.edges
  1360. };
  1361. // create a network
  1362. var network = new vis.Network(container, data);
  1363. </pre>
  1364. <br>
  1365. <h4>Gephi parser options</h4>
  1366. There are a few options you can use to tell Vis what to do with the data from Gephi.
  1367. <table class="options">
  1368. <tr>
  1369. <th>Name</th>
  1370. <th>Type</th>
  1371. <th>Default</th>
  1372. <th>Description</th>
  1373. </tr>
  1374. <tr>
  1375. <td>nodes.fixed</td>
  1376. <td>Boolean</td>
  1377. <td><code>true</code></td>
  1378. <td>When false, the nodes will move according to the physics model after import. If true, the nodes do
  1379. not move at all. If set to true, the node positions have to be defined to avoid infinite recursion
  1380. errors in the physics.
  1381. </td>
  1382. </tr>
  1383. <tr>
  1384. <td>nodes.parseColor</td>
  1385. <td>Boolean</td>
  1386. <td><code>false</code></td>
  1387. <td>If true, the color will be parsed by the vis parser, generating extra colors for the borders,
  1388. highlighs and hover. If false, the node will be the supplied color.
  1389. </td>
  1390. </tr>
  1391. <tr>
  1392. <td>edges.inheritColor</td>
  1393. <td>Boolean</td>
  1394. <td><code>false</code></td>
  1395. <td>When true, the color supplied by gephi is ignored and the inherit color mode is used with the global
  1396. setting.
  1397. </td>
  1398. </tr>
  1399. </table>
  1400. </div>
  1401. </div>
  1402. <!-- Bootstrap core JavaScript
  1403. ================================================== -->
  1404. <!-- Placed at the end of the document so the pages load faster -->
  1405. <script src="../js/jquery.min.js"></script>
  1406. <script src="../js/bootstrap.min.js"></script>
  1407. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  1408. <script src="../js/ie10-viewport-bug-workaround.js"></script>