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.

1560 lines
76 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
  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>Locales object. By default only <code>'en'</code>, <code>'de'</code>, <code>'es'</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','moveNode', this);">
  738. <td colspan="2"><span parent="moveNode" class="right-caret" id="method_moveNode"></span> moveNode(<code><i>nodeId, Number x, Number y</i></code>)</td>
  739. </tr>
  740. <tr class="hidden" parent="moveNode">
  741. <td class="midMethods">Returns: none</td>
  742. <td>You can use this to programatically move a node. <i>The supplied x and y positions have to be in canvas space!</i>
  743. </td>
  744. </tr>
  745. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getBoundingBox', this);">
  746. <td colspan="2"><span parent="getBoundingBox" class="right-caret" id="method_getBoundingBox"></span> getBoundingBox(<code><i>String
  747. nodeId</i></code>)
  748. </td>
  749. </tr>
  750. <tr class="hidden" parent="getBoundingBox">
  751. <td class="midMethods">Returns: Object</td>
  752. <td> Returns a bounding box for the node including label in the format:
  753. <pre class="code">
  754. {
  755. top: Number,
  756. left: Number,
  757. right: Number,
  758. bottom: Number
  759. }
  760. </pre>
  761. These values are in canvas space.
  762. </td>
  763. </tr>
  764. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedNodes', this);">
  765. <td colspan="2"><span parent="getConnectedNodes" class="right-caret" id="method_getConnectedNodes"></span> getConnectedNodes(<code><i>String
  766. nodeId or edgeId</i></code>)
  767. </td>
  768. </tr>
  769. <tr class="hidden" parent="getConnectedNodes">
  770. <td class="midMethods">Returns: Array</td>
  771. <td>Returns an array of nodeIds of the all the nodes that are directly connected to this node. If you supply an edgeId,
  772. 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>
  773. </tr>
  774. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedEdges', this);">
  775. <td colspan="2"><span parent="getConnectedEdges" class="right-caret" id="method_getConnectedEdges"></span> getConnectedEdges(<code><i>String
  776. nodeId</i></code>)
  777. </td>
  778. </tr>
  779. <tr class="hidden" parent="getConnectedEdges">
  780. <td class="midMethods">Returns: Array</td>
  781. <td>Returns an array of edgeIds of the edges connected to this node.</td>
  782. </tr>
  783. <tr class="subHeader">
  784. <td colspan="2">Physics methods to control when the simulation should run.</td>
  785. </tr>
  786. <tr class="collapsible toggle" onclick="toggleTable('methodTable','startSimulation', this);">
  787. <td colspan="2"><span parent="startSimulation" class="right-caret" id="method_startSimulation"></span> startSimulation()</td>
  788. </tr>
  789. <tr class="hidden" parent="startSimulation">
  790. <td class="midMethods">Returns: none</td>
  791. <td>Start the physics simulation. This is normally done whenever needed and is only really useful if you
  792. stop the simulation yourself and wish to continue it afterwards.
  793. </td>
  794. </tr>
  795. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stopSimulation', this);">
  796. <td colspan="2"><span parent="stopSimulation" class="right-caret" id="method_stopSimulation"></span> stopSimulation()</td>
  797. </tr>
  798. <tr class="hidden" parent="stopSimulation">
  799. <td class="midMethods">Returns: none</td>
  800. <td>This stops the physics simulation and triggers a <code>stabilized</code> event. It can be restarted
  801. by
  802. dragging a node, altering the dataset or calling <code>startSimulation()</code>.
  803. </td>
  804. </tr>
  805. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stabilize', this);">
  806. <td colspan="2"><span parent="stabilize" class="right-caret" id="method_stabilize"></span> stabilize([iterations])</td>
  807. </tr>
  808. <tr class="hidden" parent="stabilize">
  809. <td class="midMethods">Returns: none</td>
  810. <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>
  811. </tr>
  812. <tr class="subHeader">
  813. <td colspan="2">Selection methods for nodes and edges.</td>
  814. </tr>
  815. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelection', this);">
  816. <td colspan="2"><span parent="getSelection" class="right-caret" id="method_getSelection"></span> getSelection()</td>
  817. </tr>
  818. <tr class="hidden" parent="getSelection">
  819. <td class="midMethods">Returns: Object</td>
  820. <td>Returns an object with selected nodes and edges ids like this:
  821. <pre class="code">
  822. {
  823. nodes: [Array of selected nodeIds],
  824. edges: [Array of selected edgeIds]
  825. }</pre>
  826. </td>
  827. </tr>
  828. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedNodes', this);">
  829. <td colspan="2"><span parent="getSelectedNodes" class="right-caret" id="method_getSelectedNodes"></span> getSelectedNodes()</td>
  830. </tr>
  831. <tr class="hidden" parent="getSelectedNodes">
  832. <td class="midMethods">Returns: Array</td>
  833. <td>Returns an array of selected node ids like so:
  834. <code>[nodeId1, nodeId2, ..]</code>.
  835. </td>
  836. </tr>
  837. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedEdges', this);">
  838. <td colspan="2"><span parent="getSelectedEdges" class="right-caret" id="method_getSelectedEdges"></span> getSelectedEdges()</td>
  839. </tr>
  840. <tr class="hidden" parent="getSelectedEdges">
  841. <td class="midMethods">Returns: Array</td>
  842. <td>Returns an array of selected edge ids like so: <code>[edgeId1, edgeId2, ..]</code>.</td>
  843. </tr>
  844. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getNodeAt', this);">
  845. <td colspan="2"><span parent="getNodeAt" class="right-caret" id="method_getNodeAt"></span> getNodeAt(<code><i>{x: xPosition
  846. DOM, y: yPosition DOM}</i></code>)
  847. </td>
  848. </tr>
  849. <tr class="hidden" parent="getNodeAt">
  850. <td class="midMethods">Returns: String</td>
  851. <td>Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left
  852. corner
  853. of the canvas.
  854. </td>
  855. </tr>
  856. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getEdgeAt', this);">
  857. <td colspan="2"><span parent="getEdgeAt" class="right-caret" id="method_getEdgeAt"></span> getEdgeAt(<code><i>{x: xPosition
  858. DOM, y: yPosition DOM}</i></code>)
  859. </td>
  860. </tr>
  861. <tr class="hidden" parent="getEdgeAt">
  862. <td class="midMethods">Returns: String</td>
  863. <td>Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left
  864. corner
  865. of the canvas..
  866. </td>
  867. </tr>
  868. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectNodes', this);">
  869. <td colspan="2"><span parent="selectNodes" class="right-caret" id="method_selectNodes"></span> selectNodes(<code><i>Array with
  870. nodeIds</i></code>,<code><i>[Boolean
  871. highlightEdges]</i></code>)
  872. </td>
  873. </tr>
  874. <tr class="hidden" parent="selectNodes">
  875. <td class="midMethods">Returns: none</td>
  876. <td>Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or
  877. undefined,
  878. the neighbouring edges will also be selected. This method unselects all other objects before
  879. selecting
  880. its own objects. <i>Does not fire events</i>.
  881. </td>
  882. </tr>
  883. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectEdges', this);">
  884. <td colspan="2"><span parent="selectEdges" class="right-caret" id="method_selectEdges"></span> selectEdges(<code><i>Array with
  885. edgeIds</i></code>)
  886. </td>
  887. </tr>
  888. <tr class="hidden" parent="selectEdges">
  889. <td class="midMethods">Returns: none</td>
  890. <td>Selects the edges corresponding to the id's in the input array. This method unselects all other
  891. objects
  892. before selecting its own objects. <i>Does not fire events</i>.
  893. </td>
  894. </tr>
  895. <tr class="collapsible toggle" onclick="toggleTable('methodTable','unselectAll', this);">
  896. <td colspan="2"><span parent="unselectAll" class="right-caret" id="method_unselectAll"></span> unselectAll()</td>
  897. </tr>
  898. <tr class="hidden" parent="unselectAll">
  899. <td class="midMethods">Returns: none</td>
  900. <td>Unselect all objects. <i>Does not fire events</i>.</td>
  901. </tr>
  902. <tr class="subHeader">
  903. <td colspan="2">Methods to control the viewport for zoom and animation.</td>
  904. </tr>
  905. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getScale', this);">
  906. <td colspan="2"><span parent="getScale" class="right-caret" id="method_getScale"></span> getScale()</td>
  907. </tr>
  908. <tr class="hidden" parent="getScale">
  909. <td class="midMethods">Returns: Number</td>
  910. <td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.
  911. </td>
  912. </tr>
  913. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
  914. <td colspan="2"><span parent="clusterByHubsize" class="right-caret" id="method_getViewPosition"></span> getViewPosition()</td>
  915. </tr>
  916. <tr class="hidden" parent="clusterByHubsize">
  917. <td class="midMethods">Returns: Number</td>
  918. <td>Returns the current central focus point of the view.</td>
  919. </tr>
  920. <tr class="collapsible toggle" onclick="toggleTable('methodTable','fit', this);">
  921. <td colspan="2"><span parent="fit" class="right-caret" id="method_fit"></span> fit(<code>[Object
  922. options]</code>)
  923. </td>
  924. </tr>
  925. <tr class="hidden" parent="fit">
  926. <td class="midMethods">Returns: none</td>
  927. <td>Zooms out so all nodes fit on the canvas. You can supply options to customize this:
  928. <pre class="code">
  929. {
  930. nodes:[Array of nodeIds],
  931. animation: { // -------------------> can be a boolean too!
  932. duration: Number
  933. easingFunction: String
  934. }
  935. }
  936. </pre>
  937. The nodes can be used to zoom to fit only specific nodes in the view. <br/><br/>
  938. The other options are explained in the <code>moveTo()</code> description below.
  939. All options are optional for the fit method.
  940. </td>
  941. </tr>
  942. <tr class="collapsible toggle" onclick="toggleTable('methodTable','focus', this);">
  943. <td colspan="2"><span parent="focus" class="right-caret" id="method_focus"></span> focus(
  944. <code>String nodeId</code>,
  945. <code>[Object options]</code>)
  946. </td>
  947. </tr>
  948. <tr class="hidden" parent="focus">
  949. <td class="midMethods">Returns: none</td>
  950. <td>You can focus on a node with this function. What that means is the view will lock onto that node, if
  951. it
  952. is moving, the view will also move accordingly. If the view is dragged by the user, the focus is
  953. broken.
  954. You can supply options to customize the effect:
  955. <pre class="code">
  956. {
  957. scale: Number,
  958. offset: {x:Number, y:Number}
  959. locked: boolean
  960. animation: { // -------------------> can be a boolean too!
  961. duration: Number
  962. easingFunction: String
  963. }
  964. }
  965. </pre>
  966. All options except for locked are explained in the <code>moveTo()</code> description below. Locked
  967. denotes whether or not the view remains locked to the node once the zoom-in animation is finished.
  968. Default value is true. The options object is optional in the focus method.
  969. </td>
  970. </tr>
  971. <tr class="collapsible toggle" onclick="toggleTable('methodTable','moveTo', this);">
  972. <td colspan="2"><span parent="moveTo" class="right-caret" id="method_moveTo"></span> moveTo(<code>Object
  973. options</code>)
  974. </td>
  975. </tr>
  976. <tr class="hidden" parent="moveTo">
  977. <td class="midMethods">Returns: none</td>
  978. <td>You can animate or move the camera using the moveTo method. Options are:
  979. <pre class="code">
  980. {
  981. position: {x:Number, y:Number},
  982. scale: Number,
  983. offset: {x:Number, y:Number}
  984. animation: { // -------------------> can be a boolean too!
  985. duration: Number
  986. easingFunction: String
  987. }
  988. }
  989. </pre>
  990. The position (in canvas units!) is the position of the central focus point of the camera.
  991. The scale is the target zoomlevel. Default value is 1.0.
  992. The offset (in DOM units) is how many pixels from the center the view is focussed. Default value is
  993. {x:0,y:0}.
  994. For animation you can either use a Boolean to use it with the default options or disable it or you
  995. can
  996. define the duration (in milliseconds) and easing function manually. Available are:
  997. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  998. easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint</code>.
  999. <i>You will have to define at least a scale, position or offset. Otherwise, there is nothing to move
  1000. to.</i>
  1001. </td>
  1002. </tr>
  1003. <tr class="collapsible toggle" onclick="toggleTable('methodTable','releaseNode', this);">
  1004. <td colspan="2"><span parent="releaseNode" class="right-caret" id="method_releaseNode"></span> releaseNode()</td>
  1005. </tr>
  1006. <tr class="hidden" parent="releaseNode">
  1007. <td class="midMethods">Returns: none</td>
  1008. <td>Programatically release the focussed node.</td>
  1009. </tr>
  1010. <tr class="subHeader">
  1011. <td colspan="2">Methods to use with the configurator module.</td>
  1012. </tr>
  1013. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getOptionsFromConfigurator', this);">
  1014. <td colspan="2"><span parent="getOptionsFromConfigurator" class="right-caret" id="method_getOptionsFromConfigurator"></span> getOptionsFromConfigurator()</td>
  1015. </tr>
  1016. <tr class="hidden" parent="getOptionsFromConfigurator">
  1017. <td class="midMethods">Returns: Object</td>
  1018. <td>If you use the configurator, you can call this method to get an options object that contains all differences from the default options
  1019. caused by users interacting with the configurator.
  1020. </td>
  1021. </tr>
  1022. </table>
  1023. <br>
  1024. <br>
  1025. <h4 id="optionsObject">Cluster methods options object</h4>
  1026. <p>The options object supplied to the cluster functions can contain these properties:</p>
  1027. <table class="methods">
  1028. <tr>
  1029. <th>Name</th>
  1030. <th>Type</th>
  1031. <th>Description</th>
  1032. </tr>
  1033. <tr><td>joinCondition(<br>&nbsp;&nbsp;<code>nodeOptions:&nbsp;Object</code><br>)</td>
  1034. <td>Function</td>
  1035. <td><i>Optional for all but the cluster method. </i> The cluster module loops over all nodes that are
  1036. selected to be in the cluster and calls this function with their data as argument.
  1037. If this function returns true, this node will be added to the cluster. You have access to all
  1038. options
  1039. (including the default)
  1040. as well as any custom fields you may have added to the node to determine whether or not to include
  1041. it in
  1042. the cluster. Example:
  1043. <pre class="prettyprint lang-js">
  1044. var nodes = [
  1045. {id: 4, label: 'Node 4'},
  1046. {id: 5, label: 'Node 5'},
  1047. {id: 6, label: 'Node 6', cid:1},
  1048. {id: 7, label: 'Node 7', cid:1}
  1049. ]
  1050. var options = {
  1051. joinCondition:function(nodeOptions) {
  1052. return nodeOptions.cid === 1;
  1053. }
  1054. }
  1055. network.clustering.cluster(options);
  1056. </pre>
  1057. </td>
  1058. </tr>
  1059. <tr><td>processProperties(<br>&nbsp;&nbsp;<code>clusterOptions:&nbsp;Object</code>,<br>
  1060. &nbsp;&nbsp;<code>childNodesOptions:&nbsp;Array</code>,<br>
  1061. &nbsp;&nbsp;<code>childEdgesOptions:&nbsp;Array</code><br>)</td>
  1062. <td>Function</td>
  1063. <td><i>Optional. </i> Before creating the new cluster node, this (optional) function will be called with
  1064. the
  1065. properties supplied by you (<code>clusterNodeProperties</code>), all contained nodes and all
  1066. contained
  1067. edges. You can use this to update the
  1068. properties of the cluster based on which items it contains. The function should return the
  1069. properties to
  1070. create the cluster node. In the example below, we ensure preservation of mass and value when forming
  1071. the
  1072. cluster:
  1073. <pre class="prettyprint lang-js">
  1074. var options = {
  1075. processProperties: function (clusterOptions,
  1076. childNodes, childEdges) {
  1077. var totalMass = 0;
  1078. var totalValue = 0;
  1079. for (var i = 0; i < childNodes.length; i++) {
  1080. totalMass += childNodes[i].mass;
  1081. totalValue = childNodes[i].value
  1082. ? totalValue + childNodes[i].value
  1083. : totalValue;
  1084. }
  1085. clusterOptions.mass = totalMass;
  1086. if (totalValue > 0) {
  1087. clusterOptions.value = totalValue;
  1088. }
  1089. return clusterOptions;
  1090. },
  1091. }
  1092. </pre>
  1093. </td>
  1094. </tr>
  1095. <tr><td id="event_clusterNodeProperties">clusterNodeProperties</td>
  1096. <td>Object</td>
  1097. <td><i>Optional. </i> This is an object containing the options for the cluster node. All options
  1098. described
  1099. in the <a href="./nodes.html">nodes module</a> are allowed. This allows you to style your cluster
  1100. node
  1101. any way you want. This is also the style object that is provided in the processProperties function
  1102. for
  1103. fine tuning. If undefined, default node options will be used.
  1104. </td>
  1105. </tr>
  1106. <tr><td id="event_clusterEdgeProperties">clusterEdgeProperties</td>
  1107. <td>Object</td>
  1108. <td><i>Optional. </i> This is an object containing the options for the edges connected to the cluster.
  1109. All
  1110. options described in the <a href="./edges.html">edges module</a> are allowed. Using this, you can
  1111. style
  1112. the edges connecting to the cluster any way you want. If none are provided, the options from the
  1113. edges
  1114. that are replaced are used. If undefined, default edge options will be used.
  1115. </td>
  1116. </tr>
  1117. </table>
  1118. </div>
  1119. <br /><hr />
  1120. <div id="eventsDiv">
  1121. <h2 id="Events">Events</h2>
  1122. <p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
  1123. <p>These events are fired by the interaction module. They are related to user input.</p>
  1124. <table class="events">
  1125. <tr>
  1126. <th>Name</th>
  1127. <th>Properties</th>
  1128. <th>Description</th>
  1129. </tr>
  1130. <tr class="subHeader">
  1131. <td colspan="3">Events triggered by human interaction, selection, dragging etc.</td>
  1132. </tr>
  1133. <tr><td id="event_click">click</td>
  1134. <td>
  1135. Object
  1136. </td>
  1137. <td>Fired when the user clicks the mouse or taps on a touchscreen device. Passes an object with properties structured as:
  1138. <pre class="prettyprint lang-js">{
  1139. nodes: [Array of selected nodeIds],
  1140. edges: [Array of selected edgeIds],
  1141. event: [Object] original click event,
  1142. pointer: {
  1143. DOM: {x:pointer_x, y:pointer_y},
  1144. canvas: {x:canvas_x, y:canvas_y}
  1145. }
  1146. }
  1147. </pre>
  1148. </td>
  1149. </tr>
  1150. <tr><td id="event_doubleClick">doubleClick</td>
  1151. <td>same as <code>click</code>.</td>
  1152. <td>Fired when the user double clicks the mouse or double taps on a touchscreen device. Since a double
  1153. click
  1154. is in fact 2 clicks, 2 click events are fired, followed by a double click event. If you do not want
  1155. to
  1156. use the click events if a double click event is fired, just check the time between click events
  1157. before
  1158. processing them.
  1159. </td>
  1160. </tr>
  1161. <tr><td id="event_oncontext">oncontext</td>
  1162. <td>same as <code>click</code>.</td>
  1163. <td>Fired when the user click on the canvas with the right mouse button. The right mouse button does not
  1164. select by default. You can use the method <code>getNodeAt</code> to select the node if you
  1165. want.
  1166. </td>
  1167. </tr>
  1168. <tr><td id="event_hold">hold</td>
  1169. <td>same as <code>click</code>.</td>
  1170. <td>Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device. A click
  1171. event
  1172. is also fired in this case.
  1173. </td>
  1174. </tr>
  1175. <tr><td id="event_release">release</td>
  1176. <td>same as <code>click</code>.</td>
  1177. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1178. </td>
  1179. </tr>
  1180. <tr><td id="event_select">select</td>
  1181. <td>same as <code>click</code>.</td>
  1182. <td>Fired when the selection has changed by user action. This means a node or edge has been selected,
  1183. added
  1184. to the selection or deselected. <b>All select events are only triggered on click and hold</b>.
  1185. </td>
  1186. </tr>
  1187. <tr><td id="event_selectNode">selectNode</td>
  1188. <td>same as <code>click</code>.</td>
  1189. <td>Fired when a node has been selected by the user.</td>
  1190. </tr>
  1191. <tr><td id="event_selectEdge">selectEdge</td>
  1192. <td>same as <code>click</code>.</td>
  1193. <td>Fired when a edge has been selected by the user.</td>
  1194. </tr>
  1195. <tr><td id="event_deselectNode">deselectNode</td>
  1196. <td>Object
  1197. </td>
  1198. <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:
  1199. <pre class="prettyprint lang-js">{
  1200. nodes: [Array of selected nodeIds],
  1201. edges: [Array of selected edgeIds],
  1202. event: [Object] original click event,
  1203. pointer: {
  1204. DOM: {x:pointer_x, y:pointer_y},
  1205. canvas: {x:canvas_x, y:canvas_y}
  1206. }
  1207. },
  1208. previousSelection: {
  1209. nodes: [Array of previously selected nodeIds],
  1210. edges: [Array of previously selected edgeIds]
  1211. }
  1212. }
  1213. </pre>
  1214. </td>
  1215. </tr>
  1216. <tr><td id="event_deselectEdge">deselectEdge</td>
  1217. <td>same as <code>deselectNode</code>.</td>
  1218. <td>Fired when a edge (or edges) has (or have) been deselected by the user. The previous selection is
  1219. the
  1220. list of nodes and edges that were selected before the last user event.
  1221. </td>
  1222. </tr>
  1223. <tr><td id="event_dragStart">dragStart</td>
  1224. <td>same as <code>click</code>.</td>
  1225. <td>Fired when starting a drag.</td>
  1226. </tr>
  1227. <tr><td id="event_dragging">dragging</td>
  1228. <td>same as <code>click</code>.</td>
  1229. <td>Fired when dragging node(s) or the view.</td>
  1230. </tr>
  1231. <tr><td id="event_dragEnd">dragEnd</td>
  1232. <td>same as <code>click</code>.</td>
  1233. <td>Fired when the drag has finished.</td>
  1234. </tr>
  1235. <tr><td id="event_hoverNode">hoverNode</td>
  1236. <td><code>{node: nodeId}</code></td>
  1237. <td>Fired interaction:{hover:true} and the mouse hovers over a node.</td>
  1238. </tr>
  1239. <tr><td id="event_blurNode">blurNode</td>
  1240. <td><code>{node: nodeId}</code></td>
  1241. <td>Fired interaction:{hover:true} and the mouse moved away from a node it was hovering over before.</td>
  1242. </tr>
  1243. <tr><td id="event_hoverEdge">hoverEdge</td>
  1244. <td><code>{edge: edgeId}</code></td>
  1245. <td>Fired interaction:{hover:true} and the mouse hovers over an edge.</td>
  1246. </tr>
  1247. <tr><td id="event_blurEdge">blurEdge</td>
  1248. <td><code>{edge: edgeId}</code></td>
  1249. <td>Fired interaction:{hover:true} and the mouse moved away from an edge it was hovering over before.</td>
  1250. </tr>
  1251. <tr><td id="event_zoom">zoom</td>
  1252. <td><code>{direction:'+'/'-', scale: Number}</code></td>
  1253. <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>
  1254. </tr>
  1255. <tr><td id="event_showPopup">showPopup</td>
  1256. <td><code>id of item corresponding to popup</code></td>
  1257. <td>Fired when the popup (tooltip) is shown.</td>
  1258. </tr>
  1259. <tr><td id="event_hidePopup">hidePopup</td>
  1260. <td>none</td>
  1261. <td>Fired when the popup (tooltip) is hidden.</td>
  1262. </tr>
  1263. <tr class="subHeader ">
  1264. <td colspan="3">Events triggered the physics simulation. Can be used to trigger GUI updates.</td>
  1265. </tr>
  1266. <tr><td id="event_startStabilizing">startStabilizing</td>
  1267. <td>none</td>
  1268. <td>Fired when stabilization starts. This is also the case when you drag a node and the physics
  1269. simulation
  1270. restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.
  1271. </td>
  1272. <tr><td id="event_stabilizationProgress">stabilizationProgress</td>
  1273. <td>Object</td>
  1274. <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:
  1275. <pre class="prettyprint lang-js">{
  1276. iterations: Number // iterations so far,
  1277. total: Number // total iterations in options
  1278. }</pre>
  1279. </td>
  1280. </tr>
  1281. <tr><td id="event_stabilizationIterationsDone">stabilizationIterationsDone</td>
  1282. <td>none</td>
  1283. <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.
  1284. </td>
  1285. <tr><td id="event_stabilized">stabilized</td>
  1286. <td>Object</td>
  1287. <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:
  1288. <pre class="prettyprint lang-js">{
  1289. iterations: Number // iterations it took
  1290. }</pre>
  1291. </td>
  1292. <tr class="subHeader">
  1293. <td colspan="3">Event triggered by the canvas.</td>
  1294. </tr>
  1295. <tr><td id="event_resize">resize</td>
  1296. <td>Object</td>
  1297. <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:
  1298. <pre class="prettyprint lang-js">
  1299. {
  1300. width: Number // the new width of the canvas
  1301. height: Number // the new height of the canvas
  1302. oldWidth: Number // the old width of the canvas
  1303. oldHeight: Number // the old height of the canvas
  1304. }
  1305. </pre>
  1306. </td>
  1307. </tr>
  1308. <tr class="subHeader ">
  1309. <td colspan="3">Events triggered by the rendering module. Can be used to draw custom elements on the
  1310. canvas.
  1311. </td>
  1312. </tr>
  1313. <tr><td id="event_initRedraw">initRedraw</td>
  1314. <td>none</td>
  1315. <td>Fired before the redrawing begins. The simulation step has completed at this point. Can be used to
  1316. move
  1317. custom elements before starting drawing the new frame.
  1318. </td>
  1319. <tr><td id="event_beforeDrawing">beforeDrawing</td>
  1320. <td><code>canvas context</code></td>
  1321. <td>Fired after the canvas has been cleared, scaled and translated to the viewing position but before
  1322. all
  1323. edges and nodes are drawn. Can be used to draw behind the network.
  1324. </td>
  1325. <tr><td id="event_afterDrawing">afterDrawing</td>
  1326. <td><code>canvas context</code></td>
  1327. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1328. </td>
  1329. </tr>
  1330. <tr class="subHeader">
  1331. <td colspan="3">Event triggered by the view module.</td>
  1332. </tr>
  1333. <tr><td id="event_animationFinished">animationFinished</td>
  1334. <td>none</td>
  1335. <td>Fired when an animation is finished.</td>
  1336. </tr>
  1337. <tr class="subHeader">
  1338. <td colspan="3">Event triggered by the configuration module.</td>
  1339. </tr>
  1340. <tr><td id="event_configChange">configChange</td>
  1341. <td>Object</td>
  1342. <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().
  1343. You do not have to manually put the options into the network: this is done automatically. You can use the event
  1344. to store user options in the database.
  1345. </td>
  1346. </tr>
  1347. </table>
  1348. </div>
  1349. <br /><hr />
  1350. <div id="importDiv">
  1351. <h2 id="importing_data">Importing data</h2>
  1352. <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>
  1353. <h3 id="importGephi">Import data from Gephi</h3>
  1354. <p>
  1355. Network can import data straight from an exported json file from gephi. You can get the JSON exporter here:
  1356. <a href="https://marketplace.gephi.org/plugin/json-exporter/" target="_blank">https://marketplace.gephi.org/plugin/json-exporter/</a>.
  1357. An example exists showing how to get a JSON file into Vis:
  1358. </p>
  1359. <p>
  1360. Example usage:
  1361. </p>
  1362. <pre class="prettyprint lang-js">
  1363. // load the JSON file containing the Gephi network.
  1364. var gephiJSON = loadJSON("./datasources/WorldCup2014.json"); // code in <a href="http://visjs.org/examples/network/data/importingFromGephi.html">importing_from_gephi</a>.
  1365. // you can customize the result like with these options. These are explained below.
  1366. // These are the default options.
  1367. var parserOptions = {
  1368. edges: {
  1369. inheritColors: false
  1370. },
  1371. nodes: {
  1372. fixed: true,
  1373. parseColor: false
  1374. }
  1375. }
  1376. // parse the gephi file to receive an object
  1377. // containing nodes and edges in vis format.
  1378. var parsed = vis.network.convertGephi(gephiJSON, parserOptions);
  1379. // provide data in the normal fashion
  1380. var data = {
  1381. nodes: parsed.nodes,
  1382. edged: parsed.edges
  1383. };
  1384. // create a network
  1385. var network = new vis.Network(container, data);
  1386. </pre>
  1387. <br>
  1388. <h4>Gephi parser options</h4>
  1389. There are a few options you can use to tell Vis what to do with the data from Gephi.
  1390. <table class="options">
  1391. <tr>
  1392. <th>Name</th>
  1393. <th>Type</th>
  1394. <th>Default</th>
  1395. <th>Description</th>
  1396. </tr>
  1397. <tr><td>nodes.fixed</td>
  1398. <td>Boolean</td>
  1399. <td><code>true</code></td>
  1400. <td>When false, the nodes will move according to the physics model after import. If true, the nodes do
  1401. not move at all. If set to true, the node positions have to be defined to avoid infinite recursion
  1402. errors in the physics.
  1403. </td>
  1404. </tr>
  1405. <tr><td>nodes.parseColor</td>
  1406. <td>Boolean</td>
  1407. <td><code>false</code></td>
  1408. <td>If true, the color will be parsed by the vis parser, generating extra colors for the borders,
  1409. highlighs and hover. If false, the node will be the supplied color.
  1410. </td>
  1411. </tr>
  1412. <tr><td>edges.inheritColor</td>
  1413. <td>Boolean</td>
  1414. <td><code>false</code></td>
  1415. <td>When true, the color supplied by gephi is ignored and the inherit color mode is used with the global
  1416. setting.
  1417. </td>
  1418. </tr>
  1419. </table>
  1420. <h3 id="importDot">Import data in DOT language</h3>
  1421. <p>
  1422. Network supports data in the
  1423. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  1424. To use data in the DOT language, you can use the vis.network.convertDot converter to transform the DOT
  1425. language
  1426. into a vis.Network compatible nodes, edges and options objects. You can extend the options object with other
  1427. options if you'd like.
  1428. </p>
  1429. <p>
  1430. Example usage:
  1431. </p>
  1432. <pre class="prettyprint lang-js">
  1433. // provide data in the DOT language
  1434. var DOTstring = 'dinetwork {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }';
  1435. var parsedData = vis.network.convertDot(DOTstring);
  1436. var data = {
  1437. nodes: parsedData.nodes,
  1438. edges: parsedData.edges
  1439. }
  1440. var options = parsedData.options;
  1441. // you can extend the options like a normal JSON variable:
  1442. options.nodes = {
  1443. color: 'red'
  1444. }
  1445. // create a network
  1446. var network = new vis.Network(container, data, options);
  1447. </pre>
  1448. </div>
  1449. </div>
  1450. <!-- Bootstrap core JavaScript
  1451. ================================================== -->
  1452. <!-- Placed at the end of the document so the pages load faster -->
  1453. <script src="../js/jquery.min.js"></script>
  1454. <script src="../js/bootstrap.min.js"></script>
  1455. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  1456. <script src="../js/ie10-viewport-bug-workaround.js"></script>
  1457. <!-- jquery extensions -->
  1458. <script src="../js/jquery.highlight.js"></script>
  1459. <script src="../js/jquery.url.min.js"></script>
  1460. <!-- Tipue vendor js -->
  1461. <script src="../js/tipuesearch.config.js"></script>
  1462. <script src="../js/tipuesearch.js"></script>
  1463. <!-- controller -->
  1464. <script src="../js/main.js"></script>