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.

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