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.

1578 lines
77 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
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><a 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><a 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><a 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><a href="./layout.html">layout</a></td>
  215. <td>Governs the initial and hierarchical positioning.</td>
  216. </tr>
  217. <tr>
  218. <td><a 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><a 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><a 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>, <code>'de'</code>, <code>'es'</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>When a Network is configured to be <code>clickToUse</code>, it will react to mouse and touch events only when active. When active, a blue shadow border is displayed around the Network. The network is set active by clicking on it, and is changed to inactive again by clicking outside the Network or by pressing the ESC key.
  303. </td>
  304. </tr>
  305. <tr><td id="event_configure">configure</td>
  306. <td>Object</td>
  307. <td>Object</td>
  308. <td href="./configure.html">All options in this object are explained in the configure module.</a>
  309. </td>
  310. </tr>
  311. <tr><td id="event_edges">edges</td>
  312. <td>Object</td>
  313. <td>Object</td>
  314. <td href="./edges.html">All options in this object are explained in the edges module.</a>
  315. </td>
  316. </tr>
  317. <tr><td id="event_nodes">nodes</td>
  318. <td>Object</td>
  319. <td>Object</td>
  320. <td href="./nodes.html">All options in this object are explained in the nodes module.</a>
  321. </td>
  322. </tr>
  323. <tr><td id="event_groups">groups</td>
  324. <td>Object</td>
  325. <td>Object</td>
  326. <td href="./groups.html">All options in this object are explained in the groups module.</a>
  327. </td>
  328. </tr>
  329. <tr><td id="event_layout">layout</td>
  330. <td>Object</td>
  331. <td>Object</td>
  332. <td href="./layout.html">All options in this object are explained in the layout module.</a>
  333. </td>
  334. </tr>
  335. <tr><td id="event_interaction">interaction</td>
  336. <td>Object</td>
  337. <td>Object</td>
  338. <td href="./interaction.html">All options in this object are explained in the interaction module.</a>
  339. </td>
  340. </tr>
  341. <tr><td id="event_manipulation">manipulation</td>
  342. <td>Object</td>
  343. <td>Object</td>
  344. <td href="./manipulation.html">All options in this object are explained in the manipulation module.</a>
  345. </td>
  346. </tr>
  347. <tr><td id="event_physics">physics</td>
  348. <td>Object</td>
  349. <td>Object</td>
  350. <td href="./physics.html">All options in this object are explained in the physics module.</a>
  351. </td>
  352. </tr>
  353. </table>
  354. <br>
  355. <br>
  356. <h4 id="locales">Custom locales</h4>
  357. <p>The locales object has the following format:</p>
  358. <pre class="prettyprint lang-js">
  359. var locales = {
  360. en: {
  361. edit: 'Edit',
  362. del: 'Delete selected',
  363. back: 'Back',
  364. addNode: 'Add Node',
  365. addEdge: 'Add Edge',
  366. editNode: 'Edit Node',
  367. editEdge: 'Edit Edge',
  368. addDescription: 'Click in an empty space to place a new node.',
  369. edgeDescription: 'Click on a node and drag the edge to another node to connect them.',
  370. editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
  371. createEdgeError: 'Cannot link edges to a cluster.',
  372. deleteClusterError: 'Clusters cannot be deleted.',
  373. editClusterError: 'Clusters cannot be edited.'
  374. }
  375. }</pre>
  376. <p>If you want to define your own locale, you can change the key ('en' here) and change all the strings. You can
  377. then use your new key in the locale option.</p>
  378. </div>
  379. <br /><hr />
  380. <div id="methodsDiv">
  381. <h2 id="methods">Methods</h2>
  382. <p>This is a list of all the methods in the public API. They have been grouped by category, which correspond to
  383. the
  384. modules listed above.</p>
  385. <table class="methods-collapsable" id="methodTable">
  386. <tr class="subHeader">
  387. <td colspan="2">Global methods for the network.</td>
  388. </tr>
  389. <tr class="collapsible toggle" onclick="toggleTable('methodTable','destroy', this);">
  390. <td colspan="2"><span parent="destroy" class="right-caret" id="method_destroy"></span> destroy()</td>
  391. </tr>
  392. <tr class="hidden" parent="destroy">
  393. <td class="midMethods">Returns: none</td>
  394. <td>Remove the network from the DOM and remove all Hammer bindings and references.</td>
  395. </tr>
  396. <tr class="collapsible toggle" onclick="toggleTable('methodTable','setData', this);">
  397. <td colspan="2"><span parent="setData" class="right-caret" id="method_setData"></span> setData({<code><i>nodes: vis
  398. DataSet/Array</i></code>,<code><i>edges: vis
  399. DataSet/Array</i></code>})
  400. </td>
  401. </tr>
  402. <tr class="hidden" parent="setData">
  403. <td class="midMethods">Returns: none</td>
  404. <td>Override all the data in the network. If stabilization is enabled in the <a href="physics.html">physics
  405. module</a>, the network will stabilize again. This method is also performed when first initializing
  406. the
  407. network.
  408. </td>
  409. </tr>
  410. <tr class="collapsible toggle" onclick="toggleTable('methodTable','setOptions', this);">
  411. <td colspan="2"><span parent="setOptions" class="right-caret" id="method_setOptions"></span> setOptions(<code>Object
  412. options</code>)
  413. </td>
  414. </tr>
  415. <tr class="hidden" parent="setOptions">
  416. <td class="midMethods">Returns: none</td>
  417. <td>Set the options. All available options can be found in the modules above. Each module requires it's
  418. own
  419. container with the module name to contain its options.
  420. </td>
  421. </tr>
  422. <tr class="collapsible toggle" onclick="toggleTable('methodTable','onEvent', this);">
  423. <td colspan="2"><span parent="onEvent" class="right-caret" id="method_on"></span> on(<code>String event name, Function callback</code>)
  424. </td>
  425. </tr>
  426. <tr class="hidden" parent="onEvent">
  427. <td class="midMethods">Returns: none</td>
  428. <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.
  429. </td>
  430. </tr>
  431. <tr class="collapsible toggle" onclick="toggleTable('methodTable','offEvent', this);">
  432. <td colspan="2"><span parent="offEvent" class="right-caret" id="method_off"></span> off(<code>String event name, Function callback</code>)
  433. </td>
  434. </tr>
  435. <tr class="hidden" parent="offEvent">
  436. <td class="midMethods">Returns: none</td>
  437. <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.
  438. </td>
  439. </tr>
  440. <tr class="collapsible toggle" onclick="toggleTable('methodTable','onceEvent', this);">
  441. <td colspan="2"><span parent="onceEvent" class="right-caret" id="method_once"></span> once(<code>String event name, Function callback</code>)
  442. </td>
  443. </tr>
  444. <tr class="hidden" parent="onceEvent">
  445. <td class="midMethods">Returns: none</td>
  446. <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.
  447. </td>
  448. </tr>
  449. <tr class="subHeader">
  450. <td colspan="2">Methods related to the canvas.</td>
  451. </tr>
  452. <tr class="collapsible toggle" onclick="toggleTable('methodTable','canvasToDOM', this);">
  453. <td colspan="2"><span parent="canvasToDOM" class="right-caret" id="method_canvasToDOM"></span> canvasToDOM({<code><i>x:
  454. Number</i></code>,<code><i>y:
  455. Number</i></code>})
  456. </td>
  457. </tr>
  458. <tr class="hidden" parent="canvasToDOM">
  459. <td class="midMethods">Returns: Object</td>
  460. <td>This function converts canvas coordinates to coordinates on the DOM. Input and output are in the
  461. form of
  462. <code>{x:Number,y:Number}</code>. The DOM values are relative to the network container.
  463. </td>
  464. </tr>
  465. <tr class="collapsible toggle" onclick="toggleTable('methodTable','DOMtoCanvas', this);">
  466. <td colspan="2"><span parent="DOMtoCanvas" class="right-caret" id="method_DOMtoCanvas"></span> DOMtoCanvas({<code><i>x:
  467. Number</i></code>,<code><i>y:
  468. Number</i></code>})
  469. </td>
  470. </tr>
  471. <tr class="hidden" parent="DOMtoCanvas">
  472. <td class="midMethods">Returns: Object</td>
  473. <td>This function converts DOM coordinates to coordinates on the canvas. Input and output are in the
  474. form of
  475. <code>{x:Number,y:Number}</code>. The DOM values are relative to the network container.
  476. </td>
  477. </tr>
  478. <tr class="collapsible toggle" onclick="toggleTable('methodTable','redraw', this);">
  479. <td colspan="2"><span parent="redraw" class="right-caret" id="method_redraw"></span> redraw()</td>
  480. </tr>
  481. <tr class="hidden" parent="redraw">
  482. <td class="midMethods">Returns: none</td>
  483. <td>Redraw the network.</td>
  484. </tr>
  485. <tr class="collapsible toggle" onclick="toggleTable('methodTable','setSize', this);">
  486. <td colspan="2"><span parent="setSize" class="right-caret" id="method_setSize"></span> setSize(<code><i>String
  487. width</i></code>,<code><i>String
  488. height</i></code>)
  489. </td>
  490. </tr>
  491. <tr class="hidden" parent="setSize">
  492. <td class="midMethods">Returns: none</td>
  493. <td>Set the size of the canvas. This is automatically done on a window resize.</td>
  494. </tr>
  495. <tr class="subHeader">
  496. <td colspan="2">Clustering</td>
  497. </tr>
  498. <tr class="collapsible toggle" onclick="toggleTable('methodTable','cluster', this);">
  499. <td colspan="2"><span parent="cluster" class="right-caret" id="method_cluster"></span> cluster(
  500. <code>Object options</code>)
  501. </td>
  502. </tr>
  503. <tr class="hidden" parent="cluster">
  504. <td class="midMethods">Returns: none</td>
  505. <td>The options object is explained in full <a data-scroll=""
  506. data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }"
  507. href="#optionsObject">below</a>. The joinCondition
  508. function
  509. is presented with all nodes.
  510. </td>
  511. </tr>
  512. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByConnection', this);">
  513. <td colspan="2"><span parent="clusterByConnection" class="right-caret" id="method_clusterByConnection"></span> clusterByConnection(
  514. <code>String nodeId</code>,
  515. <code>[Object options]</code>
  516. )
  517. </td>
  518. </tr>
  519. <tr class="hidden" parent="clusterByConnection">
  520. <td class="midMethods">Returns: none</td>
  521. <td>This method looks at the provided node and makes a cluster of it and all it's connected nodes. The
  522. behaviour can be customized by proving the options object. All options of this object are explained
  523. <a
  524. data-scroll="" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }"
  525. href="#optionsObject">below</a>. The joinCondition is only presented with the connected
  526. nodes.
  527. </td>
  528. </tr>
  529. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
  530. <td colspan="2"><span parent="clusterByHubsize" class="right-caret" id="method_clusterByHubsize"></span> clusterByHubsize(
  531. <code>[Number hubsize]</code>,
  532. <code>[Object options]</code>)
  533. </td>
  534. </tr>
  535. <tr class="hidden" parent="clusterByHubsize">
  536. <td class="midMethods">Returns: none</td>
  537. <td>This method checks all nodes in the network and those with a equal or higher amount of edges than
  538. specified with the <code>hubsize</code> qualify. If a hubsize is not defined, the hubsize will be determined as the average
  539. value plus two standard deviations. <br><br>
  540. For all qualifying nodes, clusterByConnection is performed on each of them.
  541. The options object is described for <code>clusterByConnection</code> and does the same here.
  542. </td>
  543. </tr>
  544. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterOutliers', this);">
  545. <td colspan="2"><span parent="clusterOutliers" class="right-caret" id="method_clusterOutliers"></span> clusterOutliers(
  546. <code>[Object options]</code>)
  547. </tr>
  548. <tr class="hidden" parent="clusterOutliers">
  549. <td class="midMethods">Returns: none</td>
  550. <td>This method will cluster all nodes with 1 edge with their respective connected node.
  551. The options object is explained in full <a data-scroll="" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }" href="#optionsObject">below</a>.
  552. </td>
  553. </tr>
  554. <tr class="collapsible toggle" onclick="toggleTable('methodTable','findNode', this);">
  555. <td colspan="2"><span parent="findNode" class="right-caret" id="method_findNode"></span> findNode(
  556. <code>String nodeId</code>)
  557. </tr>
  558. <tr class="hidden" parent="findNode">
  559. <td class="midMethods">Returns: Array</td>
  560. <td>Nodes can be in clusters. Clusters can also be in clusters. This function returns and array of
  561. nodeIds
  562. showing where the node is. <br><br> Example:
  563. cluster 'A' contains cluster 'B',
  564. cluster 'B' contains cluster 'C',
  565. cluster 'C' contains node 'fred'.
  566. <code>network.clustering.findNode('fred')</code> will return <code>['A','B','C','fred']</code>.
  567. </td>
  568. </tr>
  569. <tr class="collapsible toggle" onclick="toggleTable('methodTable','isCluster', this);">
  570. <td colspan="2"><span parent="isCluster" class="right-caret" id="method_isCluster"></span> isCluster(
  571. <code>String nodeId</code>)
  572. </tr>
  573. <tr class="hidden" parent="isCluster">
  574. <td class="midMethods">Returns: Boolean</td>
  575. <td>Returns true if the node whose ID has been supplied is a cluster.</td>
  576. </tr>
  577. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getNodesInCluster', this);">
  578. <td colspan="2"><span parent="getNodesInCluster" class="right-caret" id="method_getNodesInCluster"></span> getNodesInCluster(
  579. <code>String clusterNodeId</code>)
  580. </tr>
  581. <tr class="hidden" parent="getNodesInCluster">
  582. <td class="midMethods">Returns: Array</td>
  583. <td>Returns an array of all nodeIds of the nodes that would be released if you open the cluster.
  584. </td>
  585. </tr>
  586. <tr class="collapsible toggle" onclick="toggleTable('methodTable','openCluster', this);">
  587. <td colspan="2"><span parent="openCluster" class="right-caret" id="method_openCluster"></span> openCluster(
  588. <code>String nodeId, Object options</code>)
  589. </tr>
  590. <tr class="hidden" parent="openCluster">
  591. <td class="midMethods">Returns: none</td>
  592. <td>Opens the cluster, releases the contained nodes and edges, removing the cluster node and cluster
  593. edges. The options object is optional and currently supports one option, releaseFunction, which is a function that can be used to manually
  594. position the nodes after the cluster is opened. <br>
  595. <pre class="code">
  596. function releaseFunction (clusterPosition, containedNodesPositions) {
  597. var newPositions = {};
  598. // clusterPosition = {x:clusterX, y:clusterY};
  599. // containedNodesPositions = {nodeId:{x:nodeX,y:nodeY}, nodeId2....}
  600. newPositions[nodeId] = {x:newPosX, y:newPosY};
  601. return newPositions;
  602. }</pre>
  603. The containedNodesPositions contain the positions of the nodes in the cluster at the moment they were clustered.
  604. 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
  605. to the nodeIds that exist in the containedNodesPositions and an <code>{x:x,y:y}</code> position object. <br><br>
  606. 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.
  607. </td>
  608. </tr>
  609. <tr class="subHeader">
  610. <td colspan="2">Layout</td>
  611. </tr>
  612. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSeed', this);">
  613. <td colspan="2"><span parent="getSeed" class="right-caret" id="method_getSeed"></span> getSeed()</td>
  614. </tr>
  615. <tr class="hidden" parent="clusterByHubsize">
  616. </tr>
  617. <tr class="hidden" parent="getSeed">
  618. <td class="midMethods">Returns: Number</td>
  619. <td>If you like the layout of your network and would like it to start in the same way next time, ask for
  620. the
  621. seed using this method and put it in the <code>layout.randomSeed</code> option.
  622. </td>
  623. </tr>
  624. <tr class="subHeader">
  625. <td colspan="2">Manipulation methods to use the manipulation system without GUI.</td>
  626. </tr>
  627. <tr class="collapsible toggle" onclick="toggleTable('methodTable','enableEditMode', this);">
  628. <td colspan="2"><span parent="enableEditMode" class="right-caret" id="method_enableEditMode"></span> enableEditMode()</td>
  629. </tr>
  630. <tr class="hidden" parent="enableEditMode">
  631. <td class="midMethods">Returns: none</td>
  632. <td>Programatically enable the edit mode. Similar effect to pressing the edit button.</td>
  633. </tr>
  634. <tr class="collapsible toggle" onclick="toggleTable('methodTable','disableEditMode', this);">
  635. <td colspan="2"><span parent="disableEditMode" class="right-caret" id="method_disableEditMode"></span> disableEditMode()</td>
  636. </tr>
  637. <tr class="hidden" parent="disableEditMode">
  638. <td class="midMethods">Returns: none</td>
  639. <td>Programatically disable the edit mode. Similar effect to pressing the close icon (small cross in the
  640. corner of the toolbar).
  641. </td>
  642. </tr>
  643. <tr class="collapsible toggle" onclick="toggleTable('methodTable','addNodeMode', this);">
  644. <td colspan="2"><span parent="addNodeMode" class="right-caret" id="method_addNodeMode"></span> addNodeMode()</td>
  645. </tr>
  646. <tr class="hidden" parent="addNodeMode">
  647. <td class="midMethods">Returns: none</td>
  648. <td>Go into addNode mode. Having edit mode or manipulation enabled is not required. To get out of this
  649. mode,
  650. call <code>disableEditMode()</code>. The callback functions defined in <code>handlerFunctions</code>
  651. still apply. To use these methods without having the manipulation GUI, make sure you set
  652. <code>enabled</code> to false.
  653. </td>
  654. </tr>
  655. <tr class="collapsible toggle" onclick="toggleTable('methodTable','editNode', this);">
  656. <td colspan="2"><span parent="editNode" class="right-caret" id="method_editNode"></span> editNode()</td>
  657. </tr>
  658. <tr class="hidden" parent="editNode">
  659. <td class="midMethods">Returns: none</td>
  660. <td>Edit the selected node. The explaination from <code>addNodeMode</code> applies here as well.</td>
  661. </tr>
  662. <tr class="collapsible toggle" onclick="toggleTable('methodTable','addEdgeMode', this);">
  663. <td colspan="2"><span parent="addEdgeMode" class="right-caret" id="method_addEdgeMode"></span> addEdgeMode()</td>
  664. </tr>
  665. <tr class="hidden" parent="addEdgeMode">
  666. <td class="midMethods">Returns: none</td>
  667. <td>Go into addEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
  668. </tr>
  669. <tr class="collapsible toggle" onclick="toggleTable('methodTable','editEdgeMode', this);">
  670. <td colspan="2"><span parent="editEdgeMode" class="right-caret" id="method_editEdgeMode"></span> editEdgeMode()</td>
  671. </tr>
  672. <tr class="hidden" parent="editEdgeMode">
  673. <td class="midMethods">Returns: none</td>
  674. <td>Go into editEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
  675. </tr>
  676. <tr class="collapsible toggle" onclick="toggleTable('methodTable','deleteSelected', this);">
  677. <td colspan="2"><span parent="deleteSelected" class="right-caret" id="method_deleteSelected"></span> deleteSelected()</td>
  678. </tr>
  679. <tr class="hidden" parent="deleteSelected">
  680. <td class="midMethods">Returns: none</td>
  681. <td>Delete selected. Having edit mode or manipulation enabled is not required.</td>
  682. </tr>
  683. <tr class="subHeader">
  684. <td colspan="2">Methods to get information on nodes and edges.</td>
  685. </tr>
  686. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getPositions', this);">
  687. <td colspan="2"><span parent="getPositions" class="right-caret" id="method_getPositions"></span> getPositions(<code><i>[Array of
  688. nodeIds]</i></code>)
  689. </td>
  690. </tr>
  691. <tr class="hidden" parent="getPositions">
  692. <td class="midMethods">Returns: Object</td>
  693. <td>Returns the x y positions in canvas space of the nodes with the supplied nodeIds as an object:
  694. <pre class="code">
  695. {
  696. nodeId1: {x: xValue, y:yValue},
  697. nodeId2: {x: xValue, y:yValue},
  698. ...
  699. }
  700. </pre>
  701. Alternative inputs are a String containing a nodeId or nothing. When a String is supplied, the
  702. position
  703. of the node corresponding to the ID is returned. When nothing is supplied, the positions of all
  704. nodes
  705. are returned.
  706. </td>
  707. </tr>
  708. <tr class="collapsible toggle" onclick="toggleTable('methodTable','storePositions', this);">
  709. <td colspan="2"><span parent="storePositions" class="right-caret" id="method_storePositions"></span> storePositions()</td>
  710. </tr>
  711. <tr class="hidden" parent="storePositions">
  712. <td class="midMethods">Returns: none</td>
  713. <td>When using the vis.DataSet to load your nodes into the network, this method will put the X and Y
  714. positions of all nodes into that dataset. If you're loading your nodes from a database and have
  715. this dynamically coupled with
  716. the DataSet, you can
  717. use this to stablize your network once, then save the positions in that database through the DataSet
  718. so
  719. the next
  720. time you load the nodes, stabilization will be near instantaneous.
  721. <br><br>
  722. If the nodes are still moving and you're using dynamic smooth edges (which is on by default), you
  723. can
  724. use the option <code>stabilization.onlyDynamicEdges</code> in the <a href="physics.html">physics
  725. module</a>
  726. to improve initialization time.
  727. <br><br>
  728. <b>This method does not support clustering. At the moment it is not possible to cache
  729. positions when using clusters since they cannot be correctly initialized from just the
  730. positions.</b>
  731. </td>
  732. </tr>
  733. <tr class="collapsible toggle" onclick="toggleTable('methodTable','moveNode', this);">
  734. <td colspan="2"><span parent="moveNode" class="right-caret" id="method_moveNode"></span> moveNode(<code><i>nodeId, Number x, Number y</i></code>)</td>
  735. </tr>
  736. <tr class="hidden" parent="moveNode">
  737. <td class="midMethods">Returns: none</td>
  738. <td>You can use this to programatically move a node. <i>The supplied x and y positions have to be in canvas space!</i>
  739. </td>
  740. </tr>
  741. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getBoundingBox', this);">
  742. <td colspan="2"><span parent="getBoundingBox" class="right-caret" id="method_getBoundingBox"></span> getBoundingBox(<code><i>String
  743. nodeId</i></code>)
  744. </td>
  745. </tr>
  746. <tr class="hidden" parent="getBoundingBox">
  747. <td class="midMethods">Returns: Object</td>
  748. <td> Returns a bounding box for the node including label in the format:
  749. <pre class="code">
  750. {
  751. top: Number,
  752. left: Number,
  753. right: Number,
  754. bottom: Number
  755. }
  756. </pre>
  757. These values are in canvas space.
  758. </td>
  759. </tr>
  760. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedNodes', this);">
  761. <td colspan="2"><span parent="getConnectedNodes" class="right-caret" id="method_getConnectedNodes"></span> getConnectedNodes(<code><i>String
  762. nodeId or edgeId</i></code>)
  763. </td>
  764. </tr>
  765. <tr class="hidden" parent="getConnectedNodes">
  766. <td class="midMethods">Returns: Array</td>
  767. <td>Returns an array of nodeIds of the all the nodes that are directly connected to this node. If you supply an edgeId,
  768. 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>
  769. </tr>
  770. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedEdges', this);">
  771. <td colspan="2"><span parent="getConnectedEdges" class="right-caret" id="method_getConnectedEdges"></span> getConnectedEdges(<code><i>String
  772. nodeId</i></code>)
  773. </td>
  774. </tr>
  775. <tr class="hidden" parent="getConnectedEdges">
  776. <td class="midMethods">Returns: Array</td>
  777. <td>Returns an array of edgeIds of the edges connected to this node.</td>
  778. </tr>
  779. <tr class="subHeader">
  780. <td colspan="2">Physics methods to control when the simulation should run.</td>
  781. </tr>
  782. <tr class="collapsible toggle" onclick="toggleTable('methodTable','startSimulation', this);">
  783. <td colspan="2"><span parent="startSimulation" class="right-caret" id="method_startSimulation"></span> startSimulation()</td>
  784. </tr>
  785. <tr class="hidden" parent="startSimulation">
  786. <td class="midMethods">Returns: none</td>
  787. <td>Start the physics simulation. This is normally done whenever needed and is only really useful if you
  788. stop the simulation yourself and wish to continue it afterwards.
  789. </td>
  790. </tr>
  791. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stopSimulation', this);">
  792. <td colspan="2"><span parent="stopSimulation" class="right-caret" id="method_stopSimulation"></span> stopSimulation()</td>
  793. </tr>
  794. <tr class="hidden" parent="stopSimulation">
  795. <td class="midMethods">Returns: none</td>
  796. <td>This stops the physics simulation and triggers a <code>stabilized</code> event. It can be restarted
  797. by
  798. dragging a node, altering the dataset or calling <code>startSimulation()</code>.
  799. </td>
  800. </tr>
  801. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stabilize', this);">
  802. <td colspan="2"><span parent="stabilize" class="right-caret" id="method_stabilize"></span> stabilize([iterations])</td>
  803. </tr>
  804. <tr class="hidden" parent="stabilize">
  805. <td class="midMethods">Returns: none</td>
  806. <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>
  807. </tr>
  808. <tr class="subHeader">
  809. <td colspan="2">Selection methods for nodes and edges.</td>
  810. </tr>
  811. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelection', this);">
  812. <td colspan="2"><span parent="getSelection" class="right-caret" id="method_getSelection"></span> getSelection()</td>
  813. </tr>
  814. <tr class="hidden" parent="getSelection">
  815. <td class="midMethods">Returns: Object</td>
  816. <td>Returns an object with selected nodes and edges ids like this:
  817. <pre class="code">
  818. {
  819. nodes: [Array of selected nodeIds],
  820. edges: [Array of selected edgeIds]
  821. }</pre>
  822. </td>
  823. </tr>
  824. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedNodes', this);">
  825. <td colspan="2"><span parent="getSelectedNodes" class="right-caret" id="method_getSelectedNodes"></span> getSelectedNodes()</td>
  826. </tr>
  827. <tr class="hidden" parent="getSelectedNodes">
  828. <td class="midMethods">Returns: Array</td>
  829. <td>Returns an array of selected node ids like so:
  830. <code>[nodeId1, nodeId2, ..]</code>.
  831. </td>
  832. </tr>
  833. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedEdges', this);">
  834. <td colspan="2"><span parent="getSelectedEdges" class="right-caret" id="method_getSelectedEdges"></span> getSelectedEdges()</td>
  835. </tr>
  836. <tr class="hidden" parent="getSelectedEdges">
  837. <td class="midMethods">Returns: Array</td>
  838. <td>Returns an array of selected edge ids like so: <code>[edgeId1, edgeId2, ..]</code>.</td>
  839. </tr>
  840. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getNodeAt', this);">
  841. <td colspan="2"><span parent="getNodeAt" class="right-caret" id="method_getNodeAt"></span> getNodeAt(<code><i>{x: xPosition
  842. DOM, y: yPosition DOM}</i></code>)
  843. </td>
  844. </tr>
  845. <tr class="hidden" parent="getNodeAt">
  846. <td class="midMethods">Returns: String</td>
  847. <td>Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left
  848. corner
  849. of the canvas.
  850. </td>
  851. </tr>
  852. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getEdgeAt', this);">
  853. <td colspan="2"><span parent="getEdgeAt" class="right-caret" id="method_getEdgeAt"></span> getEdgeAt(<code><i>{x: xPosition
  854. DOM, y: yPosition DOM}</i></code>)
  855. </td>
  856. </tr>
  857. <tr class="hidden" parent="getEdgeAt">
  858. <td class="midMethods">Returns: String</td>
  859. <td>Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left
  860. corner
  861. of the canvas..
  862. </td>
  863. </tr>
  864. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectNodes', this);">
  865. <td colspan="2"><span parent="selectNodes" class="right-caret" id="method_selectNodes"></span> selectNodes(<code><i>Array with
  866. nodeIds</i></code>,<code><i>[Boolean
  867. highlightEdges]</i></code>)
  868. </td>
  869. </tr>
  870. <tr class="hidden" parent="selectNodes">
  871. <td class="midMethods">Returns: none</td>
  872. <td>Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or
  873. undefined,
  874. the neighbouring edges will also be selected. This method unselects all other objects before
  875. selecting
  876. its own objects. <i>Does not fire events</i>.
  877. </td>
  878. </tr>
  879. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectEdges', this);">
  880. <td colspan="2"><span parent="selectEdges" class="right-caret" id="method_selectEdges"></span> selectEdges(<code><i>Array with
  881. edgeIds</i></code>)
  882. </td>
  883. </tr>
  884. <tr class="hidden" parent="selectEdges">
  885. <td class="midMethods">Returns: none</td>
  886. <td>Selects the edges corresponding to the id's in the input array. This method unselects all other
  887. objects
  888. before selecting its own objects. <i>Does not fire events</i>.
  889. </td>
  890. </tr>
  891. <tr class="collapsible toggle" onclick="toggleTable('methodTable','setSelection', this);">
  892. <td colspan="2"><span parent="setSelection" class="right-caret" id="method_setSelection"></span> setSelection(
  893. <code>Object selection</code>,
  894. <code>[Object options]</code>)</td>
  895. </tr>
  896. <tr class="hidden" parent="setSelection">
  897. <td class="midMethods">Returns: none</td>
  898. <td>Sets the selection, wich must be an object like this:
  899. <pre class="code">
  900. {
  901. nodes: [Array of nodeIds],
  902. edges: [Array of edgeIds]
  903. }</pre>
  904. You can also pass only <code>nodes</code> or <code>edges</code> in <code>selection</code> object.
  905. Available options are:
  906. <pre class="code">
  907. {
  908. unselectAll: Boolean,
  909. highlightEdges: Boolean
  910. }</pre>
  911. </td>
  912. </tr>
  913. <tr class="collapsible toggle" onclick="toggleTable('methodTable','unselectAll', this);">
  914. <td colspan="2"><span parent="unselectAll" class="right-caret" id="method_unselectAll"></span> unselectAll()</td>
  915. </tr>
  916. <tr class="hidden" parent="unselectAll">
  917. <td class="midMethods">Returns: none</td>
  918. <td>Unselect all objects. <i>Does not fire events</i>.</td>
  919. </tr>
  920. <tr class="subHeader">
  921. <td colspan="2">Methods to control the viewport for zoom and animation.</td>
  922. </tr>
  923. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getScale', this);">
  924. <td colspan="2"><span parent="getScale" class="right-caret" id="method_getScale"></span> getScale()</td>
  925. </tr>
  926. <tr class="hidden" parent="getScale">
  927. <td class="midMethods">Returns: Number</td>
  928. <td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.
  929. </td>
  930. </tr>
  931. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
  932. <td colspan="2"><span parent="clusterByHubsize" class="right-caret" id="method_getViewPosition"></span> getViewPosition()</td>
  933. </tr>
  934. <tr class="hidden" parent="clusterByHubsize">
  935. <td class="midMethods">Returns: Object</td>
  936. <td>Returns the current central focus point of the view in the form: <code>{ x: {Number}, y: {Number} }</code></td>
  937. </tr>
  938. <tr class="collapsible toggle" onclick="toggleTable('methodTable','fit', this);">
  939. <td colspan="2"><span parent="fit" class="right-caret" id="method_fit"></span> fit(<code>[Object
  940. options]</code>)
  941. </td>
  942. </tr>
  943. <tr class="hidden" parent="fit">
  944. <td class="midMethods">Returns: none</td>
  945. <td>Zooms out so all nodes fit on the canvas. You can supply options to customize this:
  946. <pre class="code">
  947. {
  948. nodes:[Array of nodeIds],
  949. animation: { // -------------------> can be a boolean too!
  950. duration: Number
  951. easingFunction: String
  952. }
  953. }
  954. </pre>
  955. The nodes can be used to zoom to fit only specific nodes in the view. <br/><br/>
  956. The other options are explained in the <code>moveTo()</code> description below.
  957. All options are optional for the fit method.
  958. </td>
  959. </tr>
  960. <tr class="collapsible toggle" onclick="toggleTable('methodTable','focus', this);">
  961. <td colspan="2"><span parent="focus" class="right-caret" id="method_focus"></span> focus(
  962. <code>String nodeId</code>,
  963. <code>[Object options]</code>)
  964. </td>
  965. </tr>
  966. <tr class="hidden" parent="focus">
  967. <td class="midMethods">Returns: none</td>
  968. <td>You can focus on a node with this function. What that means is the view will lock onto that node, if
  969. it
  970. is moving, the view will also move accordingly. If the view is dragged by the user, the focus is
  971. broken.
  972. You can supply options to customize the effect:
  973. <pre class="code">
  974. {
  975. scale: Number,
  976. offset: {x:Number, y:Number}
  977. locked: boolean
  978. animation: { // -------------------> can be a boolean too!
  979. duration: Number
  980. easingFunction: String
  981. }
  982. }
  983. </pre>
  984. All options except for locked are explained in the <code>moveTo()</code> description below. Locked
  985. denotes whether or not the view remains locked to the node once the zoom-in animation is finished.
  986. Default value is true. The options object is optional in the focus method.
  987. </td>
  988. </tr>
  989. <tr class="collapsible toggle" onclick="toggleTable('methodTable','moveTo', this);">
  990. <td colspan="2"><span parent="moveTo" class="right-caret" id="method_moveTo"></span> moveTo(<code>Object
  991. options</code>)
  992. </td>
  993. </tr>
  994. <tr class="hidden" parent="moveTo">
  995. <td class="midMethods">Returns: none</td>
  996. <td>You can animate or move the camera using the moveTo method. Options are:
  997. <pre class="code">
  998. {
  999. position: {x:Number, y:Number},
  1000. scale: Number,
  1001. offset: {x:Number, y:Number}
  1002. animation: { // -------------------> can be a boolean too!
  1003. duration: Number
  1004. easingFunction: String
  1005. }
  1006. }
  1007. </pre>
  1008. The position (in canvas units!) is the position of the central focus point of the camera.
  1009. The scale is the target zoomlevel. Default value is 1.0.
  1010. The offset (in DOM units) is how many pixels from the center the view is focussed. Default value is
  1011. {x:0,y:0}.
  1012. For animation you can either use a Boolean to use it with the default options or disable it or you
  1013. can
  1014. define the duration (in milliseconds) and easing function manually. Available are:
  1015. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  1016. easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint</code>.
  1017. <i>You will have to define at least a scale, position or offset. Otherwise, there is nothing to move
  1018. to.</i>
  1019. </td>
  1020. </tr>
  1021. <tr class="collapsible toggle" onclick="toggleTable('methodTable','releaseNode', this);">
  1022. <td colspan="2"><span parent="releaseNode" class="right-caret" id="method_releaseNode"></span> releaseNode()</td>
  1023. </tr>
  1024. <tr class="hidden" parent="releaseNode">
  1025. <td class="midMethods">Returns: none</td>
  1026. <td>Programatically release the focussed node.</td>
  1027. </tr>
  1028. <tr class="subHeader">
  1029. <td colspan="2">Methods to use with the configurator module.</td>
  1030. </tr>
  1031. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getOptionsFromConfigurator', this);">
  1032. <td colspan="2"><span parent="getOptionsFromConfigurator" class="right-caret" id="method_getOptionsFromConfigurator"></span> getOptionsFromConfigurator()</td>
  1033. </tr>
  1034. <tr class="hidden" parent="getOptionsFromConfigurator">
  1035. <td class="midMethods">Returns: Object</td>
  1036. <td>If you use the configurator, you can call this method to get an options object that contains all differences from the default options
  1037. caused by users interacting with the configurator.
  1038. </td>
  1039. </tr>
  1040. </table>
  1041. <br>
  1042. <br>
  1043. <h4 id="optionsObject">Cluster methods options object</h4>
  1044. <p>The options object supplied to the cluster functions can contain these properties:</p>
  1045. <table class="methods">
  1046. <tr>
  1047. <th>Name</th>
  1048. <th>Type</th>
  1049. <th>Description</th>
  1050. </tr>
  1051. <tr><td>joinCondition(<br>&nbsp;&nbsp;<code>nodeOptions:&nbsp;Object</code><br>)</td>
  1052. <td>Function</td>
  1053. <td><i>Optional for all but the cluster method. </i> The cluster module loops over all nodes that are
  1054. selected to be in the cluster and calls this function with their data as argument.
  1055. If this function returns true, this node will be added to the cluster. You have access to all
  1056. options
  1057. (including the default)
  1058. as well as any custom fields you may have added to the node to determine whether or not to include
  1059. it in
  1060. the cluster. Example:
  1061. <pre class="prettyprint lang-js">
  1062. var nodes = [
  1063. {id: 4, label: 'Node 4'},
  1064. {id: 5, label: 'Node 5'},
  1065. {id: 6, label: 'Node 6', cid:1},
  1066. {id: 7, label: 'Node 7', cid:1}
  1067. ]
  1068. var options = {
  1069. joinCondition:function(nodeOptions) {
  1070. return nodeOptions.cid === 1;
  1071. }
  1072. }
  1073. network.clustering.cluster(options);
  1074. </pre>
  1075. </td>
  1076. </tr>
  1077. <tr><td>processProperties(<br>&nbsp;&nbsp;<code>clusterOptions:&nbsp;Object</code>,<br>
  1078. &nbsp;&nbsp;<code>childNodesOptions:&nbsp;Array</code>,<br>
  1079. &nbsp;&nbsp;<code>childEdgesOptions:&nbsp;Array</code><br>)</td>
  1080. <td>Function</td>
  1081. <td><i>Optional. </i> Before creating the new cluster node, this (optional) function will be called with
  1082. the
  1083. properties supplied by you (<code>clusterNodeProperties</code>), all contained nodes and all
  1084. contained
  1085. edges. You can use this to update the
  1086. properties of the cluster based on which items it contains. The function should return the
  1087. properties to
  1088. create the cluster node. In the example below, we ensure preservation of mass and value when forming
  1089. the
  1090. cluster:
  1091. <pre class="prettyprint lang-js">
  1092. var options = {
  1093. processProperties: function (clusterOptions,
  1094. childNodes, childEdges) {
  1095. var totalMass = 0;
  1096. var totalValue = 0;
  1097. for (var i = 0; i < childNodes.length; i++) {
  1098. totalMass += childNodes[i].mass;
  1099. totalValue = childNodes[i].value
  1100. ? totalValue + childNodes[i].value
  1101. : totalValue;
  1102. }
  1103. clusterOptions.mass = totalMass;
  1104. if (totalValue > 0) {
  1105. clusterOptions.value = totalValue;
  1106. }
  1107. return clusterOptions;
  1108. },
  1109. }
  1110. </pre>
  1111. </td>
  1112. </tr>
  1113. <tr><td id="event_clusterNodeProperties">clusterNodeProperties</td>
  1114. <td>Object</td>
  1115. <td><i>Optional. </i> This is an object containing the options for the cluster node. All options
  1116. described
  1117. in the <a href="./nodes.html">nodes module</a> are allowed. This allows you to style your cluster
  1118. node
  1119. any way you want. This is also the style object that is provided in the processProperties function
  1120. for
  1121. fine tuning. If undefined, default node options will be used.
  1122. </td>
  1123. </tr>
  1124. <tr><td id="event_clusterEdgeProperties">clusterEdgeProperties</td>
  1125. <td>Object</td>
  1126. <td><i>Optional. </i> This is an object containing the options for the edges connected to the cluster.
  1127. All
  1128. options described in the <a href="./edges.html">edges module</a> are allowed. Using this, you can
  1129. style
  1130. the edges connecting to the cluster any way you want. If none are provided, the options from the
  1131. edges
  1132. that are replaced are used. If undefined, default edge options will be used.
  1133. </td>
  1134. </tr>
  1135. </table>
  1136. </div>
  1137. <br /><hr />
  1138. <div id="eventsDiv">
  1139. <h2 id="Events">Events</h2>
  1140. <p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
  1141. <p>These events are fired by the interaction module. They are related to user input.</p>
  1142. <table class="events">
  1143. <tr>
  1144. <th>Name</th>
  1145. <th>Properties</th>
  1146. <th>Description</th>
  1147. </tr>
  1148. <tr class="subHeader">
  1149. <td colspan="3">Events triggered by human interaction, selection, dragging etc.</td>
  1150. </tr>
  1151. <tr><td id="event_click">click</td>
  1152. <td>
  1153. Object
  1154. </td>
  1155. <td>Fired when the user clicks the mouse or taps on a touchscreen device. Passes an object with properties structured as:
  1156. <pre class="prettyprint lang-js">{
  1157. nodes: [Array of selected nodeIds],
  1158. edges: [Array of selected edgeIds],
  1159. event: [Object] original click event,
  1160. pointer: {
  1161. DOM: {x:pointer_x, y:pointer_y},
  1162. canvas: {x:canvas_x, y:canvas_y}
  1163. }
  1164. }
  1165. </pre>
  1166. </td>
  1167. </tr>
  1168. <tr><td id="event_doubleClick">doubleClick</td>
  1169. <td>same as <code>click</code>.</td>
  1170. <td>Fired when the user double clicks the mouse or double taps on a touchscreen device. Since a double
  1171. click
  1172. is in fact 2 clicks, 2 click events are fired, followed by a double click event. If you do not want
  1173. to
  1174. use the click events if a double click event is fired, just check the time between click events
  1175. before
  1176. processing them.
  1177. </td>
  1178. </tr>
  1179. <tr><td id="event_oncontext">oncontext</td>
  1180. <td>same as <code>click</code>.</td>
  1181. <td>Fired when the user click on the canvas with the right mouse button. The right mouse button does not
  1182. select by default. You can use the method <code>getNodeAt</code> to select the node if you
  1183. want.
  1184. </td>
  1185. </tr>
  1186. <tr><td id="event_hold">hold</td>
  1187. <td>same as <code>click</code>.</td>
  1188. <td>Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device. A click
  1189. event
  1190. is also fired in this case.
  1191. </td>
  1192. </tr>
  1193. <tr><td id="event_release">release</td>
  1194. <td>same as <code>click</code>.</td>
  1195. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1196. </td>
  1197. </tr>
  1198. <tr><td id="event_select">select</td>
  1199. <td>same as <code>click</code>.</td>
  1200. <td>Fired when the selection has changed by user action. This means a node or edge has been selected,
  1201. added
  1202. to the selection or deselected. <b>All select events are only triggered on click and hold</b>.
  1203. </td>
  1204. </tr>
  1205. <tr><td id="event_selectNode">selectNode</td>
  1206. <td>same as <code>click</code>.</td>
  1207. <td>Fired when a node has been selected by the user.</td>
  1208. </tr>
  1209. <tr><td id="event_selectEdge">selectEdge</td>
  1210. <td>same as <code>click</code>.</td>
  1211. <td>Fired when a edge has been selected by the user.</td>
  1212. </tr>
  1213. <tr><td id="event_deselectNode">deselectNode</td>
  1214. <td>Object
  1215. </td>
  1216. <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:
  1217. <pre class="prettyprint lang-js">{
  1218. nodes: [Array of selected nodeIds],
  1219. edges: [Array of selected edgeIds],
  1220. event: [Object] original click event,
  1221. pointer: {
  1222. DOM: {x:pointer_x, y:pointer_y},
  1223. canvas: {x:canvas_x, y:canvas_y}
  1224. }
  1225. },
  1226. previousSelection: {
  1227. nodes: [Array of previously selected nodeIds],
  1228. edges: [Array of previously selected edgeIds]
  1229. }
  1230. }
  1231. </pre>
  1232. </td>
  1233. </tr>
  1234. <tr><td id="event_deselectEdge">deselectEdge</td>
  1235. <td>same as <code>deselectNode</code>.</td>
  1236. <td>Fired when a edge (or edges) has (or have) been deselected by the user. The previous selection is
  1237. the
  1238. list of nodes and edges that were selected before the last user event.
  1239. </td>
  1240. </tr>
  1241. <tr><td id="event_dragStart">dragStart</td>
  1242. <td>same as <code>click</code>.</td>
  1243. <td>Fired when starting a drag.</td>
  1244. </tr>
  1245. <tr><td id="event_dragging">dragging</td>
  1246. <td>same as <code>click</code>.</td>
  1247. <td>Fired when dragging node(s) or the view.</td>
  1248. </tr>
  1249. <tr><td id="event_dragEnd">dragEnd</td>
  1250. <td>same as <code>click</code>.</td>
  1251. <td>Fired when the drag has finished.</td>
  1252. </tr>
  1253. <tr><td id="event_hoverNode">hoverNode</td>
  1254. <td><code>{node: nodeId}</code></td>
  1255. <td>Fired if the option <code>interaction:{hover:true}</code> is enabled and the mouse hovers over a node.</td>
  1256. </tr>
  1257. <tr><td id="event_blurNode">blurNode</td>
  1258. <td><code>{node: nodeId}</code></td>
  1259. <td>Fired if the option <code>interaction:{hover:true}</code> is enabled and the mouse moved away from a node it was hovering over before.</td>
  1260. </tr>
  1261. <tr><td id="event_hoverEdge">hoverEdge</td>
  1262. <td><code>{edge: edgeId}</code></td>
  1263. <td>Fired if the option <code>interaction:{hover:true}</code> is enabled and the mouse hovers over an edge.</td>
  1264. </tr>
  1265. <tr><td id="event_blurEdge">blurEdge</td>
  1266. <td><code>{edge: edgeId}</code></td>
  1267. <td>Fired if the option <code>interaction:{hover:true}</code> is enabled and the mouse moved away from an edge it was hovering over before.</td>
  1268. </tr>
  1269. <tr><td id="event_zoom">zoom</td>
  1270. <td><code>{direction:'+'/'-', scale: Number}</code></td>
  1271. <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>
  1272. </tr>
  1273. <tr><td id="event_showPopup">showPopup</td>
  1274. <td><code>id of item corresponding to popup</code></td>
  1275. <td>Fired when the popup (tooltip) is shown.</td>
  1276. </tr>
  1277. <tr><td id="event_hidePopup">hidePopup</td>
  1278. <td>none</td>
  1279. <td>Fired when the popup (tooltip) is hidden.</td>
  1280. </tr>
  1281. <tr class="subHeader ">
  1282. <td colspan="3">Events triggered the physics simulation. Can be used to trigger GUI updates.</td>
  1283. </tr>
  1284. <tr><td id="event_startStabilizing">startStabilizing</td>
  1285. <td>none</td>
  1286. <td>Fired when stabilization starts. This is also the case when you drag a node and the physics
  1287. simulation
  1288. restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.
  1289. </td>
  1290. <tr><td id="event_stabilizationProgress">stabilizationProgress</td>
  1291. <td>Object</td>
  1292. <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:
  1293. <pre class="prettyprint lang-js">{
  1294. iterations: Number // iterations so far,
  1295. total: Number // total iterations in options
  1296. }</pre>
  1297. </td>
  1298. </tr>
  1299. <tr><td id="event_stabilizationIterationsDone">stabilizationIterationsDone</td>
  1300. <td>none</td>
  1301. <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.
  1302. </td>
  1303. <tr><td id="event_stabilized">stabilized</td>
  1304. <td>Object</td>
  1305. <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:
  1306. <pre class="prettyprint lang-js">{
  1307. iterations: Number // iterations it took
  1308. }</pre>
  1309. </td>
  1310. <tr class="subHeader">
  1311. <td colspan="3">Event triggered by the canvas.</td>
  1312. </tr>
  1313. <tr><td id="event_resize">resize</td>
  1314. <td>Object</td>
  1315. <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:
  1316. <pre class="prettyprint lang-js">
  1317. {
  1318. width: Number // the new width of the canvas
  1319. height: Number // the new height of the canvas
  1320. oldWidth: Number // the old width of the canvas
  1321. oldHeight: Number // the old height of the canvas
  1322. }
  1323. </pre>
  1324. </td>
  1325. </tr>
  1326. <tr class="subHeader ">
  1327. <td colspan="3">Events triggered by the rendering module. Can be used to draw custom elements on the
  1328. canvas.
  1329. </td>
  1330. </tr>
  1331. <tr><td id="event_initRedraw">initRedraw</td>
  1332. <td>none</td>
  1333. <td>Fired before the redrawing begins. The simulation step has completed at this point. Can be used to
  1334. move
  1335. custom elements before starting drawing the new frame.
  1336. </td>
  1337. <tr><td id="event_beforeDrawing">beforeDrawing</td>
  1338. <td><code>canvas context</code></td>
  1339. <td>Fired after the canvas has been cleared, scaled and translated to the viewing position but before
  1340. all
  1341. edges and nodes are drawn. Can be used to draw behind the network.
  1342. </td>
  1343. <tr><td id="event_afterDrawing">afterDrawing</td>
  1344. <td><code>canvas context</code></td>
  1345. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1346. </td>
  1347. </tr>
  1348. <tr class="subHeader">
  1349. <td colspan="3">Event triggered by the view module.</td>
  1350. </tr>
  1351. <tr><td id="event_animationFinished">animationFinished</td>
  1352. <td>none</td>
  1353. <td>Fired when an animation is finished.</td>
  1354. </tr>
  1355. <tr class="subHeader">
  1356. <td colspan="3">Event triggered by the configuration module.</td>
  1357. </tr>
  1358. <tr><td id="event_configChange">configChange</td>
  1359. <td>Object</td>
  1360. <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().
  1361. You do not have to manually put the options into the network: this is done automatically. You can use the event
  1362. to store user options in the database.
  1363. </td>
  1364. </tr>
  1365. </table>
  1366. </div>
  1367. <br /><hr />
  1368. <div id="importDiv">
  1369. <h2 id="importing_data">Importing data</h2>
  1370. <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>
  1371. <h3 id="importGephi">Import data from Gephi</h3>
  1372. <p>
  1373. Network can import data straight from an exported json file from gephi. You can get the JSON exporter here:
  1374. <a href="https://marketplace.gephi.org/plugin/json-exporter/" target="_blank">https://marketplace.gephi.org/plugin/json-exporter/</a>.
  1375. An example exists showing how to get a JSON file into Vis:
  1376. </p>
  1377. <p>
  1378. Example usage:
  1379. </p>
  1380. <pre class="prettyprint lang-js">
  1381. // load the JSON file containing the Gephi network.
  1382. var gephiJSON = loadJSON("./datasources/WorldCup2014.json"); // code in <a href="http://visjs.org/examples/network/data/importingFromGephi.html">importing_from_gephi</a>.
  1383. // you can customize the result like with these options. These are explained below.
  1384. // These are the default options.
  1385. var parserOptions = {
  1386. edges: {
  1387. inheritColors: false
  1388. },
  1389. nodes: {
  1390. fixed: true,
  1391. parseColor: false
  1392. }
  1393. }
  1394. // parse the gephi file to receive an object
  1395. // containing nodes and edges in vis format.
  1396. var parsed = vis.network.convertGephi(gephiJSON, parserOptions);
  1397. // provide data in the normal fashion
  1398. var data = {
  1399. nodes: parsed.nodes,
  1400. edged: parsed.edges
  1401. };
  1402. // create a network
  1403. var network = new vis.Network(container, data);
  1404. </pre>
  1405. <br>
  1406. <h4>Gephi parser options</h4>
  1407. There are a few options you can use to tell Vis what to do with the data from Gephi.
  1408. <table class="options">
  1409. <tr>
  1410. <th>Name</th>
  1411. <th>Type</th>
  1412. <th>Default</th>
  1413. <th>Description</th>
  1414. </tr>
  1415. <tr><td>nodes.fixed</td>
  1416. <td>Boolean</td>
  1417. <td><code>true</code></td>
  1418. <td>When false, the nodes will move according to the physics model after import. If true, the nodes do
  1419. not move at all. If set to true, the node positions have to be defined to avoid infinite recursion
  1420. errors in the physics.
  1421. </td>
  1422. </tr>
  1423. <tr><td>nodes.parseColor</td>
  1424. <td>Boolean</td>
  1425. <td><code>false</code></td>
  1426. <td>If true, the color will be parsed by the vis parser, generating extra colors for the borders,
  1427. highlighs and hover. If false, the node will be the supplied color.
  1428. </td>
  1429. </tr>
  1430. <tr><td>edges.inheritColor</td>
  1431. <td>Boolean</td>
  1432. <td><code>false</code></td>
  1433. <td>When true, the color supplied by gephi is ignored and the inherit color mode is used with the global
  1434. setting.
  1435. </td>
  1436. </tr>
  1437. </table>
  1438. <h3 id="importDot">Import data in DOT language</h3>
  1439. <p>
  1440. Network supports data in the
  1441. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  1442. To use data in the DOT language, you can use the vis.network.convertDot converter to transform the DOT
  1443. language
  1444. into a vis.Network compatible nodes, edges and options objects. You can extend the options object with other
  1445. options if you'd like.
  1446. </p>
  1447. <p>
  1448. Example usage:
  1449. </p>
  1450. <pre class="prettyprint lang-js">
  1451. // provide data in the DOT language
  1452. var DOTstring = 'dinetwork {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }';
  1453. var parsedData = vis.network.convertDot(DOTstring);
  1454. var data = {
  1455. nodes: parsedData.nodes,
  1456. edges: parsedData.edges
  1457. }
  1458. var options = parsedData.options;
  1459. // you can extend the options like a normal JSON variable:
  1460. options.nodes = {
  1461. color: 'red'
  1462. }
  1463. // create a network
  1464. var network = new vis.Network(container, data, options);
  1465. </pre>
  1466. </div>
  1467. </div>
  1468. <!-- Bootstrap core JavaScript
  1469. ================================================== -->
  1470. <!-- Placed at the end of the document so the pages load faster -->
  1471. <script src="../js/jquery.min.js"></script>
  1472. <script src="../js/bootstrap.min.js"></script>
  1473. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  1474. <script src="../js/ie10-viewport-bug-workaround.js"></script>
  1475. <!-- jquery extensions -->
  1476. <script src="../js/jquery.highlight.js"></script>
  1477. <script src="../js/jquery.url.min.js"></script>
  1478. <!-- Tipue vendor js -->
  1479. <script src="../js/tipuesearch.config.js"></script>
  1480. <script src="../js/tipuesearch.js"></script>
  1481. <!-- controller -->
  1482. <script src="../js/main.js"></script>