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.

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