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.

1553 lines
75 KiB

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