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.

1608 lines
79 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. <?js= self.partial('tmpl/renderMethod.tmpl', "Network#clusterOutliers") ?>
  518. <?js= self.partial('tmpl/renderMethod.tmpl', "Network#findNode") ?>
  519. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getClusteredEdges', this);">
  520. <td colspan="2"><span parent="getClusteredEdges" class="right-caret" id="method_getClusteredEdges"></span> getClusteredEdges(
  521. <code>String baseEdgeId</code>)
  522. </tr>
  523. <tr class="hidden" parent="getClusteredEdges">
  524. <td class="midMethods">Returns: Array</td>
  525. <td>Similiar to <code>findNode</code> in that it returns all the edge ids that were created from the provided edge during clustering
  526. </td>
  527. </tr>
  528. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getBaseEdge', this);">
  529. <td colspan="2"><span parent="getBaseEdge" class="right-caret" id="method_getBaseEdge"></span> getBaseEdge(
  530. <code>String clusteredEdgeId</code>)
  531. </tr>
  532. <tr class="hidden" parent="getBaseEdge">
  533. <td class="midMethods">Returns: Value</td>
  534. <td>When a clusteredEdgeId is available, this method will return the original baseEdgeId provided in <code>data.edges</code><br/>
  535. 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>
  536. <b>This method is deprecated. Please use <code>getBaseEdges()</code> instead.</b>
  537. </td>
  538. </tr>
  539. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getBaseEdges', this);">
  540. <td colspan="2"><span parent="getBaseEdges" class="right-caret" id="method_getBaseEdges"></span>
  541. getBaseEdges(<code>String clusteredEdgeId</code>)
  542. </td>
  543. </tr>
  544. <tr class="hidden" parent="getBaseEdges">
  545. <td class="midMethods">Returns: Array</td>
  546. <td>For the given <code>clusteredEdgeId</code>, this method will return all the original base edge id's provided in <code>data.edges</code>.
  547. For a non-clustered (i.e. 'base') edge, <code>clusteredEdgeId</code> is returned.<br/><br/>
  548. 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/>
  549. </td>
  550. </tr>
  551. <tr class="collapsible toggle" onclick="toggleTable('methodTable','updateEdge', this);">
  552. <td colspan="2"><span parent="updateEdge" class="right-caret" id="method_updateEdge"></span> updateEdge(
  553. <code>String startEdgeId, Object options</code>)
  554. </tr>
  555. <tr class="hidden" parent="updateEdge">
  556. <td class="midMethods">Returns: none</td>
  557. <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/>
  558. 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/>
  559. 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:
  560. <code>network.clustering.updateEdge(originalEdge.id, {color : '#aa0000'});</code><br/>
  561. This would turn the base edge and any subsequent edges red, so when opening clusters the edges will all be the same color.
  562. </td>
  563. </tr>
  564. <tr class="collapsible toggle" onclick="toggleTable('methodTable','updateClusteredNode', this);">
  565. <td colspan="2"><span parent="updateClusteredNode" class="right-caret" id="method_updateClusteredNode"></span> updateClusteredNode(
  566. <code>String clusteredNodeId, Object options</code>)
  567. </tr>
  568. <tr class="hidden" parent="updateClusteredNode">
  569. <td class="midMethods">Returns: none</td>
  570. <td>Clustered Nodes when created are not contained in the original <code>data.nodes</code> passed on <code>network</code> creation<br/>
  571. This method updates the cluster node.<br><br> Example:
  572. <code>network.clustering.updateClusteredNode(clusteredNodeId, {shape : 'star'});</code>
  573. </td>
  574. </tr>
  575. <tr class="collapsible toggle" onclick="toggleTable('methodTable','isCluster', this);">
  576. <td colspan="2"><span parent="isCluster" class="right-caret" id="method_isCluster"></span> isCluster(
  577. <code>String nodeId</code>)
  578. </tr>
  579. <tr class="hidden" parent="isCluster">
  580. <td class="midMethods">Returns: Boolean</td>
  581. <td>Returns true if the node whose ID has been supplied is a cluster.</td>
  582. </tr>
  583. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getNodesInCluster', this);">
  584. <td colspan="2"><span parent="getNodesInCluster" class="right-caret" id="method_getNodesInCluster"></span> getNodesInCluster(
  585. <code>String clusterNodeId</code>)
  586. </tr>
  587. <tr class="hidden" parent="getNodesInCluster">
  588. <td class="midMethods">Returns: Array</td>
  589. <td>Returns an array of all nodeIds of the nodes that would be released if you open the cluster.
  590. </td>
  591. </tr>
  592. <tr class="collapsible toggle" onclick="toggleTable('methodTable','openCluster', this);">
  593. <td colspan="2"><span parent="openCluster" class="right-caret" id="method_openCluster"></span> openCluster(
  594. <code>String nodeId, Object options</code>)
  595. </tr>
  596. <tr class="hidden" parent="openCluster">
  597. <td class="midMethods">Returns: none</td>
  598. <td>Opens the cluster, releases the contained nodes and edges, removing the cluster node and cluster
  599. edges. The options object is optional and currently supports one option, releaseFunction, which is a function that can be used to manually
  600. position the nodes after the cluster is opened. <br>
  601. <pre class="code">
  602. function releaseFunction (clusterPosition, containedNodesPositions) {
  603. var newPositions = {};
  604. // clusterPosition = {x:clusterX, y:clusterY};
  605. // containedNodesPositions = {nodeId:{x:nodeX,y:nodeY}, nodeId2....}
  606. newPositions[nodeId] = {x:newPosX, y:newPosY};
  607. return newPositions;
  608. }</pre>
  609. The containedNodesPositions contain the positions of the nodes in the cluster at the moment they were clustered.
  610. 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
  611. to the nodeIds that exist in the containedNodesPositions and an <code>{x:x,y:y}</code> position object. <br><br>
  612. 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.
  613. </td>
  614. </tr>
  615. <tr id="methodLayout" class="subHeader">
  616. <td colspan="2">Layout</td>
  617. </tr>
  618. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSeed', this);">
  619. <td colspan="2"><span parent="getSeed" class="right-caret" id="method_getSeed"></span> getSeed()</td>
  620. </tr>
  621. <tr class="hidden" parent="clusterByHubsize">
  622. </tr>
  623. <tr class="hidden" parent="getSeed">
  624. <td class="midMethods">Returns: Number</td>
  625. <td>If you like the layout of your network and would like it to start in the same way next time, ask for
  626. the
  627. seed using this method and put it in the <code>layout.randomSeed</code> option.
  628. </td>
  629. </tr>
  630. <tr id="methodManipulation" class="subHeader">
  631. <td colspan="2">Manipulation methods to use the manipulation system without GUI.</td>
  632. </tr>
  633. <tr class="collapsible toggle" onclick="toggleTable('methodTable','enableEditMode', this);">
  634. <td colspan="2"><span parent="enableEditMode" class="right-caret" id="method_enableEditMode"></span> enableEditMode()</td>
  635. </tr>
  636. <tr class="hidden" parent="enableEditMode">
  637. <td class="midMethods">Returns: none</td>
  638. <td>Programatically enable the edit mode. Similar effect to pressing the edit button.</td>
  639. </tr>
  640. <tr class="collapsible toggle" onclick="toggleTable('methodTable','disableEditMode', this);">
  641. <td colspan="2"><span parent="disableEditMode" class="right-caret" id="method_disableEditMode"></span> disableEditMode()</td>
  642. </tr>
  643. <tr class="hidden" parent="disableEditMode">
  644. <td class="midMethods">Returns: none</td>
  645. <td>Programatically disable the edit mode. Similar effect to pressing the close icon (small cross in the
  646. corner of the toolbar).
  647. </td>
  648. </tr>
  649. <tr class="collapsible toggle" onclick="toggleTable('methodTable','addNodeMode', this);">
  650. <td colspan="2"><span parent="addNodeMode" class="right-caret" id="method_addNodeMode"></span> addNodeMode()</td>
  651. </tr>
  652. <tr class="hidden" parent="addNodeMode">
  653. <td class="midMethods">Returns: none</td>
  654. <td>Go into addNode mode. Having edit mode or manipulation enabled is not required. To get out of this
  655. mode,
  656. call <code>disableEditMode()</code>. The callback functions defined in <code>handlerFunctions</code>
  657. still apply. To use these methods without having the manipulation GUI, make sure you set
  658. <code>enabled</code> to false.
  659. </td>
  660. </tr>
  661. <tr class="collapsible toggle" onclick="toggleTable('methodTable','editNode', this);">
  662. <td colspan="2"><span parent="editNode" class="right-caret" id="method_editNode"></span> editNode()</td>
  663. </tr>
  664. <tr class="hidden" parent="editNode">
  665. <td class="midMethods">Returns: none</td>
  666. <td>Edit the selected node. The explaination from <code>addNodeMode</code> applies here as well.</td>
  667. </tr>
  668. <tr class="collapsible toggle" onclick="toggleTable('methodTable','addEdgeMode', this);">
  669. <td colspan="2"><span parent="addEdgeMode" class="right-caret" id="method_addEdgeMode"></span> addEdgeMode()</td>
  670. </tr>
  671. <tr class="hidden" parent="addEdgeMode">
  672. <td class="midMethods">Returns: none</td>
  673. <td>Go into addEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
  674. </tr>
  675. <tr class="collapsible toggle" onclick="toggleTable('methodTable','editEdgeMode', this);">
  676. <td colspan="2"><span parent="editEdgeMode" class="right-caret" id="method_editEdgeMode"></span> editEdgeMode()</td>
  677. </tr>
  678. <tr class="hidden" parent="editEdgeMode">
  679. <td class="midMethods">Returns: none</td>
  680. <td>Go into editEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td>
  681. </tr>
  682. <tr class="collapsible toggle" onclick="toggleTable('methodTable','deleteSelected', this);">
  683. <td colspan="2"><span parent="deleteSelected" class="right-caret" id="method_deleteSelected"></span> deleteSelected()</td>
  684. </tr>
  685. <tr class="hidden" parent="deleteSelected">
  686. <td class="midMethods">Returns: none</td>
  687. <td>Delete selected. Having edit mode or manipulation enabled is not required.</td>
  688. </tr>
  689. <tr id="methodInformation" class="subHeader">
  690. <td colspan="2">Methods to get information on nodes and edges.</td>
  691. </tr>
  692. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getPositions', this);">
  693. <td colspan="2"><span parent="getPositions" class="right-caret" id="method_getPositions"></span> getPositions(<code><i>[Array of
  694. nodeIds]</i></code>)
  695. </td>
  696. </tr>
  697. <tr class="hidden" parent="getPositions">
  698. <td class="midMethods">Returns: Object</td>
  699. <td>Returns the x y positions in canvas space of the nodes with the supplied nodeIds as an object:
  700. <pre class="code">
  701. {
  702. nodeId1: {x: xValue, y:yValue},
  703. nodeId2: {x: xValue, y:yValue},
  704. ...
  705. }
  706. </pre>
  707. Alternative inputs are a String containing a nodeId or nothing. When a String is supplied, the
  708. position
  709. of the node corresponding to the ID is returned. When nothing is supplied, the positions of all
  710. nodes
  711. are returned.
  712. </td>
  713. </tr>
  714. <tr class="collapsible toggle" onclick="toggleTable('methodTable','storePositions', this);">
  715. <td colspan="2"><span parent="storePositions" class="right-caret" id="method_storePositions"></span> storePositions()</td>
  716. </tr>
  717. <tr class="hidden" parent="storePositions">
  718. <td class="midMethods">Returns: none</td>
  719. <td>When using the vis.DataSet to load your nodes into the network, this method will put the X and Y
  720. positions of all nodes into that dataset. If you're loading your nodes from a database and have
  721. this dynamically coupled with
  722. the DataSet, you can
  723. use this to stablize your network once, then save the positions in that database through the DataSet
  724. so
  725. the next
  726. time you load the nodes, stabilization will be near instantaneous.
  727. <br><br>
  728. If the nodes are still moving and you're using dynamic smooth edges (which is on by default), you
  729. can
  730. use the option <code>stabilization.onlyDynamicEdges</code> in the <a href="physics.html">physics
  731. module</a>
  732. to improve initialization time.
  733. <br><br>
  734. <b>This method does not support clustering. At the moment it is not possible to cache
  735. positions when using clusters since they cannot be correctly initialized from just the
  736. positions.</b>
  737. </td>
  738. </tr>
  739. <tr class="collapsible toggle" onclick="toggleTable('methodTable','moveNode', this);">
  740. <td colspan="2"><span parent="moveNode" class="right-caret" id="method_moveNode"></span> moveNode(<code><i>nodeId, Number x, Number y</i></code>)</td>
  741. </tr>
  742. <tr class="hidden" parent="moveNode">
  743. <td class="midMethods">Returns: none</td>
  744. <td>You can use this to programatically move a node. <i>The supplied x and y positions have to be in canvas space!</i>
  745. </td>
  746. </tr>
  747. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getBoundingBox', this);">
  748. <td colspan="2"><span parent="getBoundingBox" class="right-caret" id="method_getBoundingBox"></span> getBoundingBox(<code><i>String
  749. nodeId</i></code>)
  750. </td>
  751. </tr>
  752. <tr class="hidden" parent="getBoundingBox">
  753. <td class="midMethods">Returns: Object</td>
  754. <td> Returns a bounding box for the node including label in the format:
  755. <pre class="code">
  756. {
  757. top: Number,
  758. left: Number,
  759. right: Number,
  760. bottom: Number
  761. }
  762. </pre>
  763. These values are in canvas space.
  764. </td>
  765. </tr>
  766. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedNodes', this);">
  767. <td colspan="2"><span parent="getConnectedNodes" class="right-caret" id="method_getConnectedNodes"></span> getConnectedNodes(<code><i>String
  768. nodeId or edgeId, [String direction]</i></code>)
  769. </td>
  770. </tr>
  771. <tr class="hidden" parent="getConnectedNodes">
  772. <td class="midMethods">Returns: Array</td>
  773. <td>Returns an array of nodeIds of all the nodes that are directly connected to this node or edge.<br><br>
  774. For a node id, returns an array with the id's of the connected nodes.<br>
  775. If optional parameter <code>direction</code> is set to string <i>'from'</i>, only parent nodes are returned.<br>
  776. If <code>direction</code> is set to <i>'to'</i>, only child nodes are returned.<br>
  777. Any other value or <code>undefined</code> returns both parent and child nodes.
  778. <br><br>
  779. For an edge id, returns an array: <code>[fromId, toId]</code>.
  780. Parameter <i>direction</i> is ignored for edges.</td>
  781. </tr>
  782. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getConnectedEdges', this);">
  783. <td colspan="2"><span parent="getConnectedEdges" class="right-caret" id="method_getConnectedEdges"></span> getConnectedEdges(<code><i>String
  784. nodeId</i></code>)
  785. </td>
  786. </tr>
  787. <tr class="hidden" parent="getConnectedEdges">
  788. <td class="midMethods">Returns: Array</td>
  789. <td>Returns an array of edgeIds of the edges connected to this node.</td>
  790. </tr>
  791. <tr id="methodPhysics" class="subHeader">
  792. <td colspan="2">Physics methods to control when the simulation should run.</td>
  793. </tr>
  794. <tr class="collapsible toggle" onclick="toggleTable('methodTable','startSimulation', this);">
  795. <td colspan="2"><span parent="startSimulation" class="right-caret" id="method_startSimulation"></span> startSimulation()</td>
  796. </tr>
  797. <tr class="hidden" parent="startSimulation">
  798. <td class="midMethods">Returns: none</td>
  799. <td>Start the physics simulation. This is normally done whenever needed and is only really useful if you
  800. stop the simulation yourself and wish to continue it afterwards.
  801. </td>
  802. </tr>
  803. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stopSimulation', this);">
  804. <td colspan="2"><span parent="stopSimulation" class="right-caret" id="method_stopSimulation"></span> stopSimulation()</td>
  805. </tr>
  806. <tr class="hidden" parent="stopSimulation">
  807. <td class="midMethods">Returns: none</td>
  808. <td>This stops the physics simulation and triggers a <code>stabilized</code> event. It can be restarted
  809. by
  810. dragging a node, altering the dataset or calling <code>startSimulation()</code>.
  811. </td>
  812. </tr>
  813. <tr class="collapsible toggle" onclick="toggleTable('methodTable','stabilize', this);">
  814. <td colspan="2"><span parent="stabilize" class="right-caret" id="method_stabilize"></span> stabilize([iterations])</td>
  815. </tr>
  816. <tr class="hidden" parent="stabilize">
  817. <td class="midMethods">Returns: none</td>
  818. <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>
  819. </tr>
  820. <tr id="methodSelection" class="subHeader">
  821. <td colspan="2">Selection methods for nodes and edges.</td>
  822. </tr>
  823. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelection', this);">
  824. <td colspan="2"><span parent="getSelection" class="right-caret" id="method_getSelection"></span> getSelection()</td>
  825. </tr>
  826. <tr class="hidden" parent="getSelection">
  827. <td class="midMethods">Returns: Object</td>
  828. <td>Returns an object with selected nodes and edges ids like this:
  829. <pre class="code">
  830. {
  831. nodes: [Array of selected nodeIds],
  832. edges: [Array of selected edgeIds]
  833. }</pre>
  834. </td>
  835. </tr>
  836. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedNodes', this);">
  837. <td colspan="2"><span parent="getSelectedNodes" class="right-caret" id="method_getSelectedNodes"></span> getSelectedNodes()</td>
  838. </tr>
  839. <tr class="hidden" parent="getSelectedNodes">
  840. <td class="midMethods">Returns: Array</td>
  841. <td>Returns an array of selected node ids like so:
  842. <code>[nodeId1, nodeId2, ..]</code>.
  843. </td>
  844. </tr>
  845. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getSelectedEdges', this);">
  846. <td colspan="2"><span parent="getSelectedEdges" class="right-caret" id="method_getSelectedEdges"></span> getSelectedEdges()</td>
  847. </tr>
  848. <tr class="hidden" parent="getSelectedEdges">
  849. <td class="midMethods">Returns: Array</td>
  850. <td>Returns an array of selected edge ids like so: <code>[edgeId1, edgeId2, ..]</code>.</td>
  851. </tr>
  852. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getNodeAt', this);">
  853. <td colspan="2"><span parent="getNodeAt" class="right-caret" id="method_getNodeAt"></span> getNodeAt(<code><i>{x: xPosition
  854. DOM, y: yPosition DOM}</i></code>)
  855. </td>
  856. </tr>
  857. <tr class="hidden" parent="getNodeAt">
  858. <td class="midMethods">Returns: String</td>
  859. <td>Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left
  860. corner
  861. of the canvas.
  862. </td>
  863. </tr>
  864. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getEdgeAt', this);">
  865. <td colspan="2"><span parent="getEdgeAt" class="right-caret" id="method_getEdgeAt"></span> getEdgeAt(<code><i>{x: xPosition
  866. DOM, y: yPosition DOM}</i></code>)
  867. </td>
  868. </tr>
  869. <tr class="hidden" parent="getEdgeAt">
  870. <td class="midMethods">Returns: String</td>
  871. <td>Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left
  872. corner
  873. of the canvas..
  874. </td>
  875. </tr>
  876. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectNodes', this);">
  877. <td colspan="2"><span parent="selectNodes" class="right-caret" id="method_selectNodes"></span> selectNodes(<code><i>Array with
  878. nodeIds</i></code>,<code><i>[Boolean
  879. highlightEdges]</i></code>)
  880. </td>
  881. </tr>
  882. <tr class="hidden" parent="selectNodes">
  883. <td class="midMethods">Returns: none</td>
  884. <td>Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or
  885. undefined,
  886. the neighbouring edges will also be selected. This method unselects all other objects before
  887. selecting
  888. its own objects. <i>Does not fire events</i>.
  889. </td>
  890. </tr>
  891. <tr class="collapsible toggle" onclick="toggleTable('methodTable','selectEdges', this);">
  892. <td colspan="2"><span parent="selectEdges" class="right-caret" id="method_selectEdges"></span> selectEdges(<code><i>Array with
  893. edgeIds</i></code>)
  894. </td>
  895. </tr>
  896. <tr class="hidden" parent="selectEdges">
  897. <td class="midMethods">Returns: none</td>
  898. <td>Selects the edges corresponding to the id's in the input array. This method unselects all other
  899. objects
  900. before selecting its own objects. <i>Does not fire events</i>.
  901. </td>
  902. </tr>
  903. <tr class="collapsible toggle" onclick="toggleTable('methodTable','setSelection', this);">
  904. <td colspan="2"><span parent="setSelection" class="right-caret" id="method_setSelection"></span> setSelection(
  905. <code>Object selection</code>,
  906. <code>[Object options]</code>)</td>
  907. </tr>
  908. <tr class="hidden" parent="setSelection">
  909. <td class="midMethods">Returns: none</td>
  910. <td>Sets the selection, wich must be an object like this:
  911. <pre class="code">
  912. {
  913. nodes: [Array of nodeIds],
  914. edges: [Array of edgeIds]
  915. }</pre>
  916. You can also pass only <code>nodes</code> or <code>edges</code> in <code>selection</code> object.
  917. Available options are:
  918. <pre class="code">
  919. {
  920. unselectAll: Boolean,
  921. highlightEdges: Boolean
  922. }</pre>
  923. </td>
  924. </tr>
  925. <tr class="collapsible toggle" onclick="toggleTable('methodTable','unselectAll', this);">
  926. <td colspan="2"><span parent="unselectAll" class="right-caret" id="method_unselectAll"></span> unselectAll()</td>
  927. </tr>
  928. <tr class="hidden" parent="unselectAll">
  929. <td class="midMethods">Returns: none</td>
  930. <td>Unselect all objects. <i>Does not fire events</i>.</td>
  931. </tr>
  932. <tr id="methodViewport" class="subHeader">
  933. <td colspan="2">Methods to control the viewport for zoom and animation.</td>
  934. </tr>
  935. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getScale', this);">
  936. <td colspan="2"><span parent="getScale" class="right-caret" id="method_getScale"></span> getScale()</td>
  937. </tr>
  938. <tr class="hidden" parent="getScale">
  939. <td class="midMethods">Returns: Number</td>
  940. <td>Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.
  941. </td>
  942. </tr>
  943. <tr class="collapsible toggle" onclick="toggleTable('methodTable','clusterByHubsize', this);">
  944. <td colspan="2"><span parent="clusterByHubsize" class="right-caret" id="method_getViewPosition"></span> getViewPosition()</td>
  945. </tr>
  946. <tr class="hidden" parent="clusterByHubsize">
  947. <td class="midMethods">Returns: Object</td>
  948. <td>Returns the current central focus point of the view in the form: <code>{ x: {Number}, y: {Number} }</code></td>
  949. </tr>
  950. <tr class="collapsible toggle" onclick="toggleTable('methodTable','fit', this);">
  951. <td colspan="2"><span parent="fit" class="right-caret" id="method_fit"></span> fit(<code>[Object
  952. options]</code>)
  953. </td>
  954. </tr>
  955. <tr class="hidden" parent="fit">
  956. <td class="midMethods">Returns: none</td>
  957. <td>Zooms out so all nodes fit on the canvas. You can supply options to customize this:
  958. <pre class="code">
  959. {
  960. nodes:[Array of nodeIds],
  961. animation: { // -------------------> can be a boolean too!
  962. duration: Number
  963. easingFunction: String
  964. }
  965. }
  966. </pre>
  967. The nodes can be used to zoom to fit only specific nodes in the view. <br/><br/>
  968. The other options are explained in the <code>moveTo()</code> description below.
  969. All options are optional for the fit method.
  970. </td>
  971. </tr>
  972. <tr class="collapsible toggle" onclick="toggleTable('methodTable','focus', this);">
  973. <td colspan="2"><span parent="focus" class="right-caret" id="method_focus"></span> focus(
  974. <code>String nodeId</code>,
  975. <code>[Object options]</code>)
  976. </td>
  977. </tr>
  978. <tr class="hidden" parent="focus">
  979. <td class="midMethods">Returns: none</td>
  980. <td>You can focus on a node with this function. What that means is the view will lock onto that node, if
  981. it
  982. is moving, the view will also move accordingly. If the view is dragged by the user, the focus is
  983. broken.
  984. You can supply options to customize the effect:
  985. <pre class="code">
  986. {
  987. scale: Number,
  988. offset: {x:Number, y:Number}
  989. locked: boolean
  990. animation: { // -------------------> can be a boolean too!
  991. duration: Number
  992. easingFunction: String
  993. }
  994. }
  995. </pre>
  996. All options except for locked are explained in the <code>moveTo()</code> description below. Locked
  997. denotes whether or not the view remains locked to the node once the zoom-in animation is finished.
  998. Default value is true. The options object is optional in the focus method.
  999. </td>
  1000. </tr>
  1001. <tr class="collapsible toggle" onclick="toggleTable('methodTable','moveTo', this);">
  1002. <td colspan="2"><span parent="moveTo" class="right-caret" id="method_moveTo"></span> moveTo(<code>Object
  1003. options</code>)
  1004. </td>
  1005. </tr>
  1006. <tr class="hidden" parent="moveTo">
  1007. <td class="midMethods">Returns: none</td>
  1008. <td>You can animate or move the camera using the moveTo method. Options are:
  1009. <pre class="code">
  1010. {
  1011. position: {x:Number, y:Number},
  1012. scale: Number,
  1013. offset: {x:Number, y:Number}
  1014. animation: { // -------------------> can be a boolean too!
  1015. duration: Number
  1016. easingFunction: String
  1017. }
  1018. }
  1019. </pre>
  1020. The position (in canvas units!) is the position of the central focus point of the camera.
  1021. The scale is the target zoomlevel. Default value is 1.0.
  1022. The offset (in DOM units) is how many pixels from the center the view is focussed. Default value is
  1023. {x:0,y:0}.
  1024. For animation you can either use a Boolean to use it with the default options or disable it or you
  1025. can
  1026. define the duration (in milliseconds) and easing function manually. Available are:
  1027. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  1028. easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint</code>.
  1029. <i>You will have to define at least a scale, position or offset. Otherwise, there is nothing to move
  1030. to.</i>
  1031. </td>
  1032. </tr>
  1033. <tr class="collapsible toggle" onclick="toggleTable('methodTable','releaseNode', this);">
  1034. <td colspan="2"><span parent="releaseNode" class="right-caret" id="method_releaseNode"></span> releaseNode()</td>
  1035. </tr>
  1036. <tr class="hidden" parent="releaseNode">
  1037. <td class="midMethods">Returns: none</td>
  1038. <td>Programatically release the focussed node.</td>
  1039. </tr>
  1040. <tr id="methodConfigurator" class="subHeader">
  1041. <td colspan="2">Methods to use with the configurator module.</td>
  1042. </tr>
  1043. <tr class="collapsible toggle" onclick="toggleTable('methodTable','getOptionsFromConfigurator', this);">
  1044. <td colspan="2"><span parent="getOptionsFromConfigurator" class="right-caret" id="method_getOptionsFromConfigurator"></span> getOptionsFromConfigurator()</td>
  1045. </tr>
  1046. <tr class="hidden" parent="getOptionsFromConfigurator">
  1047. <td class="midMethods">Returns: Object</td>
  1048. <td>If you use the configurator, you can call this method to get an options object that contains all differences from the default options
  1049. caused by users interacting with the configurator.
  1050. </td>
  1051. </tr>
  1052. </table>
  1053. <br>
  1054. <br>
  1055. <h4 id="optionsObject">Cluster methods options object</h4>
  1056. <p>The options object supplied to the cluster functions can contain these properties:</p>
  1057. <table class="methods">
  1058. <tr>
  1059. <th>Name</th>
  1060. <th>Type</th>
  1061. <th>Description</th>
  1062. </tr>
  1063. <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>
  1064. <td>Function</td>
  1065. <td><i>Optional for all but the cluster method. </i> <br>
  1066. <code>clusterByConnection</code> is the only function that will pass 2 nodeOptions objects as arguments to the joinCondition callback.<br>
  1067. The cluster module loops over all nodes that are
  1068. selected to be in the cluster and calls this function with their data as argument.
  1069. If this function returns true, this node will be added to the cluster. You have access to all
  1070. options
  1071. (including the default)
  1072. as well as any custom fields you may have added to the node to determine whether or not to include
  1073. it in
  1074. the cluster. Example:
  1075. <pre class="prettyprint lang-js">
  1076. var nodes = [
  1077. {id: 4, label: 'Node 4'},
  1078. {id: 5, label: 'Node 5'},
  1079. {id: 6, label: 'Node 6', cid:1},
  1080. {id: 7, label: 'Node 7', cid:1}
  1081. ]
  1082. var options = {
  1083. joinCondition:function(nodeOptions) {
  1084. return nodeOptions.cid === 1;
  1085. }
  1086. }
  1087. network.clustering.cluster(options);
  1088. </pre>
  1089. <code>clusterByConnection</code><b> will pass 2 nodeOptions objects as arguments to the joinCondition callback.</b>
  1090. </td>
  1091. </tr>
  1092. <tr><td>processProperties(<br>&nbsp;&nbsp;<code>clusterOptions:&nbsp;Object</code>,<br>
  1093. &nbsp;&nbsp;<code>childNodesOptions:&nbsp;Array</code>,<br>
  1094. &nbsp;&nbsp;<code>childEdgesOptions:&nbsp;Array</code><br>)</td>
  1095. <td>Function</td>
  1096. <td><i>Optional. </i> Before creating the new cluster node, this (optional) function will be called with
  1097. the
  1098. properties supplied by you (<code>clusterNodeProperties</code>), all contained nodes and all
  1099. contained
  1100. edges. You can use this to update the
  1101. properties of the cluster based on which items it contains. The function should return the
  1102. properties to
  1103. create the cluster node. In the example below, we ensure preservation of mass and value when forming
  1104. the
  1105. cluster:
  1106. <pre class="prettyprint lang-js">
  1107. var options = {
  1108. processProperties: function (clusterOptions,
  1109. childNodes, childEdges) {
  1110. var totalMass = 0;
  1111. var totalValue = 0;
  1112. for (var i = 0; i < childNodes.length; i++) {
  1113. totalMass += childNodes[i].mass;
  1114. totalValue = childNodes[i].value
  1115. ? totalValue + childNodes[i].value
  1116. : totalValue;
  1117. }
  1118. clusterOptions.mass = totalMass;
  1119. if (totalValue > 0) {
  1120. clusterOptions.value = totalValue;
  1121. }
  1122. return clusterOptions;
  1123. },
  1124. }
  1125. </pre>
  1126. </td>
  1127. </tr>
  1128. <tr><td id="event_clusterNodeProperties">clusterNodeProperties</td>
  1129. <td>Object</td>
  1130. <td><i>Optional. </i> This is an object containing the options for the cluster node. All options
  1131. described
  1132. in the <a href="./nodes.html">nodes module</a> are allowed. This allows you to style your cluster
  1133. node
  1134. any way you want. This is also the style object that is provided in the processProperties function
  1135. for
  1136. fine tuning. If undefined, default node options will be used.<br/><br/>
  1137. 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.
  1138. <pre class="prettyprint lang-js">
  1139. clusterNodeProperties: {
  1140. allowSingleNodeCluster: true
  1141. }
  1142. </pre>
  1143. </td>
  1144. </tr>
  1145. <tr><td id="event_clusterEdgeProperties">clusterEdgeProperties</td>
  1146. <td>Object</td>
  1147. <td><i>Optional. </i> This is an object containing the options for the edges connected to the cluster.
  1148. All
  1149. options described in the <a href="./edges.html">edges module</a> are allowed. Using this, you can
  1150. style
  1151. the edges connecting to the cluster any way you want. If none are provided, the options from the
  1152. edges
  1153. that are replaced are used. If undefined, default edge options will be used.
  1154. </td>
  1155. </tr>
  1156. </table>
  1157. </div>
  1158. <br /><hr />
  1159. <div id="eventsDiv">
  1160. <h2 id="Events">Events</h2>
  1161. <p>This is a list of all the events in the public API. They are collected here from all individual modules.</p>
  1162. <p>These events are fired by the interaction module. They are related to user input.</p>
  1163. <table class="events">
  1164. <tr>
  1165. <th>Name</th>
  1166. <th>Properties</th>
  1167. <th>Description</th>
  1168. </tr>
  1169. <tr class="subHeader">
  1170. <td colspan="3">Events triggered by human interaction, selection, dragging etc.</td>
  1171. </tr>
  1172. <tr><td id="event_click">click</td>
  1173. <td>
  1174. Object
  1175. </td>
  1176. <td>Fired when the user clicks the mouse or taps on a touchscreen device. Passes an object with properties structured as:
  1177. <pre class="prettyprint lang-js">{
  1178. nodes: [Array of selected nodeIds],
  1179. edges: [Array of selected edgeIds],
  1180. event: [Object] original click event,
  1181. pointer: {
  1182. DOM: {x:pointer_x, y:pointer_y},
  1183. canvas: {x:canvas_x, y:canvas_y}
  1184. }
  1185. }
  1186. </pre>
  1187. This is the structure common to all events. Specifically for the click event, the following property is added:
  1188. <pre class="prettyprint lang-js">{
  1189. ...
  1190. items: [Array of click items],
  1191. }</pre>
  1192. Where the click items can be:
  1193. <pre class="prettyprint lang-js">
  1194. {nodeId:NodeId} // node with given id clicked on
  1195. {nodeId:NodeId labelId:0} // label of node with given id clicked on
  1196. {edgeId:EdgeId} // edge with given id clicked on
  1197. {edge:EdgeId, labelId:0} // label of edge with given id clicked on
  1198. </pre>
  1199. The order of the <code>items</code> array is descending in z-order.
  1200. Thus, to get the topmost item, get the value at index 0.
  1201. </td>
  1202. </tr>
  1203. <tr><td id="event_doubleClick">doubleClick</td>
  1204. <td>same as <code>click</code>.</td>
  1205. <td>Fired when the user double clicks the mouse or double taps on a touchscreen device. Since a double
  1206. click
  1207. is in fact 2 clicks, 2 click events are fired, followed by a double click event. If you do not want
  1208. to
  1209. use the click events if a double click event is fired, just check the time between click events
  1210. before
  1211. processing them.
  1212. </td>
  1213. </tr>
  1214. <tr><td id="event_oncontext">oncontext</td>
  1215. <td>same as <code>click</code>.</td>
  1216. <td>Fired when the user click on the canvas with the right mouse button. The right mouse button does not
  1217. select by default. You can use the method <code>getNodeAt</code> to select the node if you
  1218. want.
  1219. </td>
  1220. </tr>
  1221. <tr><td id="event_hold">hold</td>
  1222. <td>same as <code>click</code>.</td>
  1223. <td>Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device. A click
  1224. event
  1225. is also fired in this case.
  1226. </td>
  1227. </tr>
  1228. <tr><td id="event_release">release</td>
  1229. <td>same as <code>click</code>.</td>
  1230. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1231. </td>
  1232. </tr>
  1233. <tr><td id="event_select">select</td>
  1234. <td>same as <code>click</code>.</td>
  1235. <td>Fired when the selection has changed by user action. This means a node or edge has been selected,
  1236. added
  1237. to the selection or deselected. <b>All select events are only triggered on click and hold</b>.
  1238. </td>
  1239. </tr>
  1240. <tr><td id="event_selectNode">selectNode</td>
  1241. <td>same as <code>click</code>.</td>
  1242. <td>Fired when a node has been selected by the user.</td>
  1243. </tr>
  1244. <tr><td id="event_selectEdge">selectEdge</td>
  1245. <td>same as <code>click</code>.</td>
  1246. <td>Fired when a edge has been selected by the user.</td>
  1247. </tr>
  1248. <tr><td id="event_deselectNode">deselectNode</td>
  1249. <td>Object
  1250. </td>
  1251. <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:
  1252. <pre class="prettyprint lang-js">{
  1253. nodes: [Array of selected nodeIds],
  1254. edges: [Array of selected edgeIds],
  1255. event: [Object] original click event,
  1256. pointer: {
  1257. DOM: {x:pointer_x, y:pointer_y},
  1258. canvas: {x:canvas_x, y:canvas_y}
  1259. }
  1260. },
  1261. previousSelection: {
  1262. nodes: [Array of previously selected nodeIds],
  1263. edges: [Array of previously selected edgeIds]
  1264. }
  1265. }
  1266. </pre>
  1267. </td>
  1268. </tr>
  1269. <tr><td id="event_deselectEdge">deselectEdge</td>
  1270. <td>same as <code>deselectNode</code>.</td>
  1271. <td>Fired when a edge (or edges) has (or have) been deselected by the user. The previous selection is
  1272. the
  1273. list of nodes and edges that were selected before the last user event.
  1274. </td>
  1275. </tr>
  1276. <tr><td id="event_dragStart">dragStart</td>
  1277. <td>same as <code>click</code>.</td>
  1278. <td>Fired when starting a drag.</td>
  1279. </tr>
  1280. <tr><td id="event_dragging">dragging</td>
  1281. <td>same as <code>click</code>.</td>
  1282. <td>Fired when dragging node(s) or the view.</td>
  1283. </tr>
  1284. <tr><td id="event_dragEnd">dragEnd</td>
  1285. <td>same as <code>click</code>.</td>
  1286. <td>Fired when the drag has finished.</td>
  1287. </tr>
  1288. <tr><td id="event_hoverNode">hoverNode</td>
  1289. <td><code>{node: nodeId}</code></td>
  1290. <td>Fired if the option <code>interaction:{hover:true}</code> is enabled and the mouse hovers over a node.</td>
  1291. </tr>
  1292. <tr><td id="event_blurNode">blurNode</td>
  1293. <td><code>{node: nodeId}</code></td>
  1294. <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>
  1295. </tr>
  1296. <tr><td id="event_hoverEdge">hoverEdge</td>
  1297. <td><code>{edge: edgeId}</code></td>
  1298. <td>Fired if the option <code>interaction:{hover:true}</code> is enabled and the mouse hovers over an edge.</td>
  1299. </tr>
  1300. <tr><td id="event_blurEdge">blurEdge</td>
  1301. <td><code>{edge: edgeId}</code></td>
  1302. <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>
  1303. </tr>
  1304. <tr><td id="event_zoom">zoom</td>
  1305. <td>Object</td>
  1306. <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:
  1307. <pre class="prettyprint lang-js">{
  1308. direction: '+'/'-',
  1309. scale: Number,
  1310. pointer: {x:pointer_x, y:pointer_y}
  1311. }
  1312. </pre></td>
  1313. </tr>
  1314. <tr><td id="event_showPopup">showPopup</td>
  1315. <td><code>id of item corresponding to popup</code></td>
  1316. <td>Fired when the popup (tooltip) is shown.</td>
  1317. </tr>
  1318. <tr><td id="event_hidePopup">hidePopup</td>
  1319. <td>none</td>
  1320. <td>Fired when the popup (tooltip) is hidden.</td>
  1321. </tr>
  1322. <tr class="subHeader ">
  1323. <td colspan="3">Events triggered the physics simulation. Can be used to trigger GUI updates.</td>
  1324. </tr>
  1325. <tr><td id="event_startStabilizing">startStabilizing</td>
  1326. <td>none</td>
  1327. <td>Fired when stabilization starts. This is also the case when you drag a node and the physics
  1328. simulation
  1329. restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.
  1330. </td>
  1331. <tr><td id="event_stabilizationProgress">stabilizationProgress</td>
  1332. <td>Object</td>
  1333. <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:
  1334. <pre class="prettyprint lang-js">{
  1335. iterations: Number // iterations so far,
  1336. total: Number // total iterations in options
  1337. }</pre>
  1338. </td>
  1339. </tr>
  1340. <tr><td id="event_stabilizationIterationsDone">stabilizationIterationsDone</td>
  1341. <td>none</td>
  1342. <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.
  1343. </td>
  1344. <tr><td id="event_stabilized">stabilized</td>
  1345. <td>Object</td>
  1346. <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:
  1347. <pre class="prettyprint lang-js">{
  1348. iterations: Number // iterations it took
  1349. }</pre>
  1350. </td>
  1351. <tr class="subHeader">
  1352. <td colspan="3">Event triggered by the canvas.</td>
  1353. </tr>
  1354. <tr><td id="event_resize">resize</td>
  1355. <td>Object</td>
  1356. <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:
  1357. <pre class="prettyprint lang-js">
  1358. {
  1359. width: Number // the new width of the canvas
  1360. height: Number // the new height of the canvas
  1361. oldWidth: Number // the old width of the canvas
  1362. oldHeight: Number // the old height of the canvas
  1363. }
  1364. </pre>
  1365. </td>
  1366. </tr>
  1367. <tr class="subHeader ">
  1368. <td colspan="3">Events triggered by the rendering module. Can be used to draw custom elements on the
  1369. canvas.
  1370. </td>
  1371. </tr>
  1372. <tr><td id="event_initRedraw">initRedraw</td>
  1373. <td>none</td>
  1374. <td>Fired before the redrawing begins. The simulation step has completed at this point. Can be used to
  1375. move
  1376. custom elements before starting drawing the new frame.
  1377. </td>
  1378. <tr><td id="event_beforeDrawing">beforeDrawing</td>
  1379. <td><code>canvas context</code></td>
  1380. <td>Fired after the canvas has been cleared, scaled and translated to the viewing position but before
  1381. all
  1382. edges and nodes are drawn. Can be used to draw behind the network.
  1383. </td>
  1384. <tr><td id="event_afterDrawing">afterDrawing</td>
  1385. <td><code>canvas context</code></td>
  1386. <td>Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.
  1387. </td>
  1388. </tr>
  1389. <tr class="subHeader">
  1390. <td colspan="3">Event triggered by the view module.</td>
  1391. </tr>
  1392. <tr><td id="event_animationFinished">animationFinished</td>
  1393. <td>none</td>
  1394. <td>Fired when an animation is finished.</td>
  1395. </tr>
  1396. <tr class="subHeader">
  1397. <td colspan="3">Event triggered by the configuration module.</td>
  1398. </tr>
  1399. <tr><td id="event_configChange">configChange</td>
  1400. <td>Object</td>
  1401. <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().
  1402. You do not have to manually put the options into the network: this is done automatically. You can use the event
  1403. to store user options in the database.
  1404. </td>
  1405. </tr>
  1406. </table>
  1407. </div>
  1408. <br /><hr />
  1409. <div id="importDiv">
  1410. <h2 id="importing_data">Importing data</h2>
  1411. <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>
  1412. <h3 id="importGephi">Import data from Gephi</h3>
  1413. <p>
  1414. Network can import data straight from an exported json file from gephi. You can get the JSON exporter here:
  1415. <a href="https://marketplace.gephi.org/plugin/json-exporter/" target="_blank">https://marketplace.gephi.org/plugin/json-exporter/</a>.
  1416. An example exists showing how to get a JSON file into Vis:
  1417. </p>
  1418. <p>
  1419. Example usage:
  1420. </p>
  1421. <pre class="prettyprint lang-js">
  1422. // load the JSON file containing the Gephi network.
  1423. var gephiJSON = loadJSON("./datasources/WorldCup2014.json"); // code in <a href="http://visjs.org/examples/network/data/importingFromGephi.html">importing_from_gephi</a>.
  1424. // you can customize the result like with these options. These are explained below.
  1425. // These are the default options.
  1426. var parserOptions = {
  1427. edges: {
  1428. inheritColors: false
  1429. },
  1430. nodes: {
  1431. fixed: true,
  1432. parseColor: false
  1433. }
  1434. }
  1435. // parse the gephi file to receive an object
  1436. // containing nodes and edges in vis format.
  1437. var parsed = vis.network.convertGephi(gephiJSON, parserOptions);
  1438. // provide data in the normal fashion
  1439. var data = {
  1440. nodes: parsed.nodes,
  1441. edged: parsed.edges
  1442. };
  1443. // create a network
  1444. var network = new vis.Network(container, data);
  1445. </pre>
  1446. <br>
  1447. <h4>Gephi parser options</h4>
  1448. There are a few options you can use to tell Vis what to do with the data from Gephi.
  1449. <table class="options">
  1450. <tr>
  1451. <th>Name</th>
  1452. <th>Type</th>
  1453. <th>Default</th>
  1454. <th>Description</th>
  1455. </tr>
  1456. <tr><td>nodes.fixed</td>
  1457. <td>Boolean</td>
  1458. <td><code>true</code></td>
  1459. <td>When false, the nodes will move according to the physics model after import. If true, the nodes do
  1460. not move at all. If set to true, the node positions have to be defined to avoid infinite recursion
  1461. errors in the physics.
  1462. </td>
  1463. </tr>
  1464. <tr><td>nodes.parseColor</td>
  1465. <td>Boolean</td>
  1466. <td><code>false</code></td>
  1467. <td>If true, the color will be parsed by the vis parser, generating extra colors for the borders,
  1468. highlighs and hover. If false, the node will be the supplied color.
  1469. </td>
  1470. </tr>
  1471. <tr><td>edges.inheritColor</td>
  1472. <td>Boolean</td>
  1473. <td><code>false</code></td>
  1474. <td>When true, the color supplied by gephi is ignored and the inherit color mode is used with the global
  1475. setting.
  1476. </td>
  1477. </tr>
  1478. </table>
  1479. <h3 id="importDot">Import data in DOT language</h3>
  1480. <p>
  1481. Network supports data in the
  1482. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  1483. To use data in the DOT language, you can use the vis.network.convertDot converter to transform the DOT
  1484. language
  1485. into a vis.Network compatible nodes, edges and options objects. You can extend the options object with other
  1486. options if you'd like.
  1487. </p>
  1488. <p>
  1489. Example usage:
  1490. </p>
  1491. <pre class="prettyprint lang-js">
  1492. // provide data in the DOT language
  1493. var DOTstring = 'dinetwork {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }';
  1494. var parsedData = vis.network.convertDot(DOTstring);
  1495. var data = {
  1496. nodes: parsedData.nodes,
  1497. edges: parsedData.edges
  1498. }
  1499. var options = parsedData.options;
  1500. // you can extend the options like a normal JSON variable:
  1501. options.nodes = {
  1502. color: 'red'
  1503. }
  1504. // create a network
  1505. var network = new vis.Network(container, data, options);
  1506. </pre>
  1507. </div>
  1508. </div>
  1509. <?js= self.partial('tmpl/html-foot.tmpl') ?>