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.

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