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.

2688 lines
90 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>vis.js | network documentation</title>
  5. <link href="css/prettify.css" type="text/css" rel="stylesheet" />
  6. <link href='css/style.css' type='text/css' rel='stylesheet'>
  7. <style>td.greenField {
  8. background-color: #c9ffc7;
  9. }</style>
  10. <script type="text/javascript" src="lib/prettify/prettify.js"></script>
  11. </head>
  12. <body onload="prettyPrint();">
  13. <div id="container">
  14. <h1>Network documentation</h1>
  15. <h2 id="Overview">Overview</h2>
  16. <p>
  17. Network is a visualization to display networks and networks consisting of nodes
  18. and edges. The visualization is easy to use and supports custom shapes,
  19. styles, colors, sizes, images, and more.
  20. </p>
  21. <p>
  22. The network visualization works smooth on any modern browser for up to a
  23. few thousand nodes and edges. To handle a larger amount of nodes, Network
  24. has <a href="#Clustering">clustering</a> support. Network uses
  25. <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Canvas">HTML canvas</a>
  26. for rendering.
  27. </p>
  28. <p>
  29. Every dataset is different. Nodes can have different sizes based on content, interconnectivity can be high or low etc. Because of this, network has a special option
  30. that the user can use to explore which settings may be good for you. Use configurePhysics as described in the <u><a href="#PhysicsConfiguration">Physics</a></u> section or by
  31. <u><a href="../examples/network/25_physics_configuration.html">example 25</a></u>.
  32. </p>
  33. <p>
  34. To get started with Network, install or download the
  35. <a href="http://visjs.org" target="_blank">vis.js</a> library.
  36. </p>
  37. <h2><a name="Contents"></a>Contents</h2>
  38. <ul>
  39. <li><a href="#Overview">Overview</a></li>
  40. <li><a href="#Example">Example</a></li>
  41. <li><a href="#Loading">Loading</a></li>
  42. <li>
  43. <a href="#Data_format">Data format</a>
  44. <ul>
  45. <li><a href="#Nodes">Nodes</a></li>
  46. <li><a href="#Edges">Edges</a></li>
  47. <li><a href="#DOT_language">DOT language</a></li>
  48. <li><a href="#Gephi_import">Gephi import</a></li>
  49. </ul>
  50. </li>
  51. <li>
  52. <a href="#Configuration_options">Configuration options</a>
  53. <ul>
  54. <li><a href="#Nodes_configuration">Nodes</a></li>
  55. <li><a href="#Edges_configuration">Edges</a></li>
  56. <li><a href="#Groups_configuration">Groups</a></li>
  57. <li><a href="#Physics">Physics</a></li>
  58. <li><a href="#Data_manipulation">Data manipulation</a></li>
  59. <li><a href="#Clustering">Clustering</a></li>
  60. <li><a href="#Navigation_controls">Navigation controls</a></li>
  61. <li><a href="#Keyboard_navigation">Keyboard navigation</a></li>
  62. <li><a href="#Hierarchical_layout">Hierarchical layout</a></li>
  63. <li><a href="#Localization">Localization</a></li>
  64. <li><a href="#Tooltips">Tooltips</a></li>
  65. </ul>
  66. </li>
  67. <li><a href="#Methods">Methods</a></li>
  68. <li><a href="#Events">Events</a></li>
  69. <li><a href="#Data_policy">Data policy</a></li>
  70. </ul>
  71. <h2 id="Example">Example</h2>
  72. <p>
  73. Here a basic network example. Note that unlike the
  74. <a href="timeline.html">Timeline</a>, the Network does not need the vis.css
  75. file.
  76. </p>
  77. <p>
  78. More examples can be found in the
  79. <a href="../examples" target="_blank">examples directory</a>.
  80. </p>
  81. <pre class="prettyprint lang-html">&lt;!doctype html&gt;
  82. &lt;html&gt;
  83. &lt;head&gt;
  84. &lt;title&gt;Network | Basic usage&lt;/title&gt;
  85. &lt;script type="text/javascript" src="../../dist/vis.js"&gt;&lt;/script&gt;
  86. &lt;/head&gt;
  87. &lt;body&gt;
  88. &lt;div id="mynetwork"&gt;&lt;/div&gt;
  89. &lt;script type="text/javascript"&gt;
  90. // create an array with nodes
  91. var nodes = [
  92. {id: 1, label: 'Node 1'},
  93. {id: 2, label: 'Node 2'},
  94. {id: 3, label: 'Node 3'},
  95. {id: 4, label: 'Node 4'},
  96. {id: 5, label: 'Node 5'}
  97. ];
  98. // create an array with edges
  99. var edges = [
  100. {from: 1, to: 2},
  101. {from: 1, to: 3},
  102. {from: 2, to: 4},
  103. {from: 2, to: 5}
  104. ];
  105. // create a network
  106. var container = document.getElementById('mynetwork');
  107. var data= {
  108. nodes: nodes,
  109. edges: edges,
  110. };
  111. var options = {
  112. width: '400px',
  113. height: '400px'
  114. };
  115. var network = new vis.Network(container, data, options);
  116. &lt;/script&gt;
  117. &lt;/body&gt;
  118. &lt;/html&gt;
  119. </pre>
  120. <h2 id="Loading">Loading</h2>
  121. <p>
  122. Install or download the <a href="http://visjs.org" target="_blank">vis.js</a> library.
  123. in a subfolder of your project. Include the library script in the head of your html code:
  124. </p>
  125. <pre class="prettyprint lang-html">
  126. &lt;script type="text/javascript" src="vis/dist/vis.js"&gt;&lt;/script&gt;
  127. </pre>
  128. The constructor of the Network is <code>vis.Network</code>.
  129. <pre class="prettyprint lang-js">var network = new vis.Network(container, data, options);</pre>
  130. The constructor accepts three parameters:
  131. <ul>
  132. <li>
  133. <code>container</code> is the DOM element in which to create the network.
  134. </li>
  135. <li>
  136. <code>data</code> is an Object containing properties <code>nodes</code> and
  137. <code>edges</code>, which both contain an array with objects.
  138. Optionally, data may contain an <code>options</code> object.
  139. The parameter <code>data</code> is optional, data can also be set using
  140. the method <code>setData</code>. Section <a href="#Data_Format">Data Format</a>
  141. describes the data object.
  142. </li>
  143. <li>
  144. <code>options</code> is an optional Object containing a name-value map
  145. with options. Options can also be set using the method
  146. <code>setOptions</code>.
  147. Section <a href="#Configuration_Options">Configuration Options</a>
  148. describes the available options.
  149. </li>
  150. </ul>
  151. <h2 id="Data_format">Data format</h2>
  152. <p>
  153. The <code>data</code> parameter of the Network constructor is an object
  154. which can contain different types of data.
  155. The following properties are supported in the <code>data</code> object:
  156. </p>
  157. <ul>
  158. <li>
  159. <span style="font-weight: bold;">A property pair <code>nodes</code> and <code>edges</code></span>,
  160. both containing an Array with objects. The data formats are described
  161. in the sections <a href="#Nodes">Nodes</a> and <a href="#Edges">Edges</a>.
  162. Example:
  163. <pre class="prettyprint lang-js">
  164. var data = {
  165. nodes: [...],
  166. edges: [...]
  167. };
  168. </pre>
  169. </li>
  170. <li>
  171. <span style="font-weight: bold;">A property <code>dot</code></span>,
  172. containing a string with data in the
  173. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  174. DOT support is described in section <a href="#DOT_language">DOT_language</a>.
  175. Example:
  176. <pre class="prettyprint lang-js">
  177. var data = {
  178. dot: '...'
  179. };
  180. </pre>
  181. </li>
  182. <li>
  183. <span style="font-weight: bold;">A property <code>options</code></span>,
  184. containing an object with global options.
  185. Options can be provided as third parameter in the network constructor
  186. as well. Section <a href="#Configuration_Options">Configuration Options</a>
  187. describes the available options.
  188. </li>
  189. </ul>
  190. <h3 id="Nodes">Nodes</h3>
  191. <p>
  192. Nodes typically have an <code>id</code> and <code>label</code>.
  193. A node must contain at least a property <code>id</code>.
  194. Nodes can have extra properties, used to define the shape and style of the
  195. nodes.
  196. </p>
  197. <p>
  198. A JavaScript Array with nodes is constructed like:
  199. </p>
  200. <pre class="prettyprint lang-js">
  201. var nodes = [
  202. {
  203. id: 1,
  204. label: 'Node 1'
  205. },
  206. // ... more nodes
  207. ];
  208. </pre>
  209. Alternatively, a vis DataSet can also be used:
  210. <pre class="prettyprint lang-js">
  211. var nodes = new vis.DataSet();
  212. nodes.add([
  213. {id: '1', label: 'Node 1'},
  214. {id: '2', label: 'Node 2'},
  215. {id: '3', label: 'Node 3'},
  216. {id: '4', label: 'Node 4'},
  217. // ... more nodes
  218. ]);
  219. </pre>
  220. When using a DataSet, the network is automatically updating to changes in the DataSet.
  221. <p>
  222. Nodes support the properties listed below. Each node can be configured individually using
  223. the properties highlighted in green over at the <a href="#Nodes_configuration">Nodes configuration</a>.
  224. </p>
  225. <table>
  226. <tr>
  227. <th>Name</th>
  228. <th>Type</th>
  229. <th>Required</th>
  230. <th>Description</th>
  231. </tr>
  232. <tr>
  233. <td>group</td>
  234. <td>Number | String</td>
  235. <td>no</td>
  236. <td>A group number or name. The type can be <code>number</code>,
  237. <code>string</code>, or an other type. All nodes with the same group get
  238. the same color schema.</td>
  239. </tr>
  240. <tr>
  241. <td>allowedToMoveX</td>
  242. <td>Boolean</td>
  243. <td>no</td>
  244. <td>If allowedToMoveX is false, then the node will not move in the X direction from its position.</td>
  245. </tr>
  246. <tr>
  247. <td>allowedToMoveY</td>
  248. <td>Boolean</td>
  249. <td>no</td>
  250. <td>If allowedToMoveY is false, then the node will not move in the Y direction from its position.</td>
  251. </tr>
  252. <tr>
  253. <td>id</td>
  254. <td>Number | String</td>
  255. <td>yes</td>
  256. <td>A unique id for this node.
  257. Nodes may not have duplicate id's.
  258. Id's do not need to be consecutive.
  259. An id is normally a number, but may be any type.</td>
  260. </tr>
  261. <tr>
  262. <td>level</td>
  263. <td>number</td>
  264. <td>no</td>
  265. <td>This level is used in the hierarchical layout. If this is not selected, the level does not do anything. This must be a postive number (min value: 0).
  266. Fractions are possible but only integers are supported.</td>
  267. </tr>
  268. <tr>
  269. <td>label</td>
  270. <td>string</td>
  271. <td>no</td>
  272. <td>Text label to be displayed in the node or under the image of the node.
  273. Multiple lines can be separated by a newline character <code>\n</code> .</td>
  274. </tr>
  275. <tr>
  276. <td>title</td>
  277. <td>string | function | Element</td>
  278. <td>no</td>
  279. <td>Title to be displayed when the user hovers over the node.
  280. The title can be an HTML element or a string containing plain text or HTML.
  281. When title is a function, the returned result is displayed as tooltip, and returning <code>undefined</code>
  282. will prevent the tooltip from being displayed.</td>
  283. </tr>
  284. <tr>
  285. <td>value</td>
  286. <td>number</td>
  287. <td>no</td>
  288. <td>A value for the node.
  289. The radius of the nodes will be scaled automatically from minimum to
  290. maximum value.
  291. Only applicable when the shape of the node is <code>dot</code>.
  292. If a <code>radius</code> is provided for the node too, it will override the
  293. radius calculated from the value.</td>
  294. </tr>
  295. <tr>
  296. <td>x</td>
  297. <td>number</td>
  298. <td>no</td>
  299. <td>Horizontal position in pixels.
  300. The horizontal position of the node will be fixed unless combined with the allowedToMoveX:true option.
  301. The vertical position y may remain undefined. This does not work with hierarchical layout.</td>
  302. </tr>
  303. <tr>
  304. <td>y</td>
  305. <td>number</td>
  306. <td>no</td>
  307. <td>Vertical position in pixels.
  308. The vertical position of the node will be fixed unless combined with the allowedToMoveY:true option.
  309. The horizontal position x may remain undefined. This does not work with hierarchical layout.</td>
  310. </tr>
  311. </table>
  312. <h3 id="Edges">Edges</h3>
  313. <p>
  314. Edges are connections between nodes.
  315. An edge must at least contain properties <code>from</code> and
  316. <code>to</code>, both referring to the <code>id</code> of a node.
  317. Edges can have extra properties, used to define the type and style.
  318. </p>
  319. <p>
  320. A JavaScript Array with edges is constructed as:
  321. </p>
  322. <pre class="prettyprint lang-js">
  323. var edges = [
  324. {
  325. from: 1,
  326. to: 3
  327. },
  328. // ... more edges
  329. ];
  330. </pre>
  331. Alternatively, a vis DataSet can also be used:
  332. <pre class="prettyprint lang-js">
  333. var edges = new vis.DataSet();
  334. edges.add([
  335. {from: '1', to: '2'},
  336. {from: '1', to: '3'},
  337. {from: '2', to: '4'},
  338. {from: '2', to: '5'},
  339. // ... more edges
  340. ]);
  341. </pre>
  342. When using a DataSet, the network is automatically updating to changes in the DataSet.
  343. <p>
  344. Edges support properties listed below. Each edge can be configured individually using
  345. the properties highlighted in green over at the <a href="#Edges_configuration">Edges configuration</a>.
  346. </p>
  347. <table>
  348. <tr>
  349. <th>Name</th>
  350. <th>Type</th>
  351. <th>Required</th>
  352. <th>Description</th>
  353. </tr>
  354. <tr>
  355. <td>from</td>
  356. <td>Number | String</td>
  357. <td>yes</td>
  358. <td>The id of a node where the edge starts. The type must correspond with
  359. the type of the node id's. This is normally a number, but can be any
  360. type.</td>
  361. </tr>
  362. <tr>
  363. <td>label</td>
  364. <td>string</td>
  365. <td>no</td>
  366. <td>Text label to be displayed halfway the edge.</td>
  367. </tr>
  368. <tr>
  369. <td>length</td>
  370. <td>number</td>
  371. <td>no</td>
  372. <td>The resting length of the edge when modeled as a spring. By default the springLength determined by the physics is used. By using this setting you can make certain edges have different resting lengths.</td>
  373. </tr>
  374. <tr>
  375. <td>title</td>
  376. <td>string | function</td>
  377. <td>no</td>
  378. <td>Title to be displayed when the user hovers over the edge.
  379. The title can be an HTML element or a string containing plain text or HTML.
  380. When title is a function, the returned result is displayed as tooltip, and returning <code>undefined</code>
  381. will prevent the tooltip from being displayed.</td>
  382. </tr>
  383. <tr>
  384. <td>to</td>
  385. <td>Number | String</td>
  386. <td>yes</td>
  387. <td>The id of a node where the edge ends. The type must correspond with
  388. the type of the node id's. This is normally a number, but can be any
  389. type.</td>
  390. </tr>
  391. <tr>
  392. <td>value</td>
  393. <td>number</td>
  394. <td>no</td>
  395. <td>A value for the edge.
  396. The width of the edges will be scaled automatically from minimum to
  397. maximum value.
  398. If a <code>width</code> is provided for the edge too, it will override the
  399. width calculated from the value.</td>
  400. </tr>
  401. </table>
  402. <h3 id="DOT_language">DOT language</h3>
  403. <p>
  404. Network supports data in the
  405. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  406. To provide data in the DOT language, the <code>data</code> object must contain
  407. a property <code>dot</code> with a String containing the data.
  408. </p>
  409. <p>
  410. Example usage:
  411. </p>
  412. <pre class="prettyprint lang-js">
  413. // provide data in the DOT language
  414. var data = {
  415. dot: 'dinetwork {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }'
  416. };
  417. // create a network
  418. var network = new vis.Network(container, data);
  419. </pre>
  420. <h3 id="Gephi_import">Gephi import (JSON)</h3>
  421. <p>
  422. network can import data straight from an exported json file from gephi. You can get the JSON exporter here:
  423. <a href="https://marketplace.gephi.org/plugin/json-exporter/" target="_blank">https://marketplace.gephi.org/plugin/json-exporter/</a>.
  424. An example exists showing how to get a JSON file into Vis: <a href="../examples/network/30_importing_from_gephi.html">30_importing_from_gephi</a>.
  425. </p>
  426. <p>
  427. Example usage:
  428. </p>
  429. <pre class="prettyprint lang-js">
  430. // load the JSON file containing the Gephi network.
  431. var gephiJSON = loadJSON("./data/WorldCup2014.json"); // code in example 30
  432. // create a data object with the gephi key:
  433. var data = {
  434. gephi: gephiJSON
  435. };
  436. // create a network
  437. var network = new vis.Network(container, data);
  438. </pre>
  439. Alternatively you can use the parser manually:
  440. <pre class="prettyprint lang-js">
  441. // load the JSON file containing the Gephi network.
  442. var gephiJSON = loadJSON("./data/WorldCup2014.json"); // code in example 30
  443. // parse the gephi file to receive an object
  444. // containing nodes and edges in vis format.
  445. var parsed = vis.network.gephiParser.parseGephi(gephiJSON);
  446. // provide data in the normal fashion
  447. var data = {
  448. nodes: parsed.nodes,
  449. edged: parsed.edges
  450. };
  451. // create a network
  452. var network = new vis.Network(container, data);
  453. </pre>
  454. <h4>Gephi parser options</h4>
  455. There are a few options you can use to tell Vis what to do with the data from Gephi.
  456. <pre class="prettyprint lang-js">
  457. var parserOptions = {
  458. allowedToMove: false,
  459. parseColor: false
  460. }
  461. var parsed = vis.network.gephiParser.parseGephi(gephiJSON, parserOptions);
  462. </pre>
  463. <table>
  464. <tr>
  465. <th>Name</th>
  466. <th>Type</th>
  467. <th>Default</th>
  468. <th>Description</th>
  469. </tr>
  470. <tr>
  471. <td>allowedToMove</td>
  472. <td>Boolean</td>
  473. <td>false</td>
  474. <td>
  475. If true, the nodes will move according to the physics model after import. If false, the nodes do not move at all.
  476. </td>
  477. </tr>
  478. <tr>
  479. <td>parseColor</td>
  480. <td>Boolean</td>
  481. <td>false</td>
  482. <td>
  483. If true, the color will be parsed by the vis parser, generating extra colors for the borders, highlighs and hover. If false, the node will be the supplied color.
  484. </td>
  485. </tr>
  486. </table>
  487. <h2 id="Configuration_options">Configuration options</h2>
  488. <p>
  489. Options can be used to customize the network. Options are defined as a JSON object.
  490. All options are optional.
  491. </p>
  492. <pre class="prettyprint lang-js">
  493. var options = {
  494. width: '100%',
  495. height: '400px',
  496. edges: {
  497. color: 'red',
  498. width: 2
  499. }
  500. };
  501. </pre>
  502. <p>
  503. The following options are available.
  504. </p>
  505. <table>
  506. <tr>
  507. <th>Name</th>
  508. <th>Type</th>
  509. <th>Default</th>
  510. <th>Description</th>
  511. </tr>
  512. <tr>
  513. <td>clickToUse</td>
  514. <td>boolean</td>
  515. <td>false</td>
  516. <td>When a Network is configured to be <code>clickToUse</code>, it will react to mouse, touch, and keyboard events only when active.
  517. 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.</td>
  518. </tr>
  519. <tr>
  520. <td><a href="#Physics">physics</a></td>
  521. <td>Object</td>
  522. <td>none</td>
  523. <td>
  524. Configuration of the physics system governing the simulation of the nodes and edges.
  525. Barnes-Hut nBody simulation is used by default. See section <a href="#Physics">Physics</a> for an overview of the available options.
  526. </td>
  527. </tr>
  528. <tr>
  529. <td><a href="#Physics">configurePhysics</a></td>
  530. <td>Boolean</td>
  531. <td>false</td>
  532. <td>
  533. Enabling this setting will create a physics configuration div above the network. You can use this to fine tune the physics system to suit your needs.
  534. Because of the many possible configurations, there is not a one-size-fits-all setting. By using this tool, you can adapt the physics to your dataset.
  535. </td>
  536. </tr>
  537. <tr>
  538. <td><a href="#Data_manipulation">dataManipulation</a></td>
  539. <td>Object</td>
  540. <td>none</td>
  541. <td>
  542. Settings for manipulating the Dataset. See section <a href="#Data_manipulation">Data manipulation</a> for an overview of the available options.
  543. </td>
  544. </tr>
  545. <tr>
  546. <td><a href="#Clustering">clustering</a></td>
  547. <td>Object</td>
  548. <td>none</td>
  549. <td>
  550. Clustering configuration. Clustering is turned off by default. See section <a href="#Clustering">Clustering</a> for an overview of the available options.
  551. </td>
  552. </tr>
  553. <tr>
  554. <td><a href="#Edges_configuration">edges</a></td>
  555. <td>Object</td>
  556. <td>none</td>
  557. <td>
  558. Configuration options applied to all edges. See section <a href="#Edges_configuration">Edges configuration</a> for an overview of the available options.
  559. </td>
  560. </tr>
  561. <tr>
  562. <td>freezeForStabilization</a></td>
  563. <td>Boolean</td>
  564. <td>false</td>
  565. <td>
  566. With the advent of the storePositions() function, the positions of the nodes can be saved after they are stabilized. The smoothCurves require support nodes and those positions are not stored. In order
  567. to speed up the initialization of the network by using storePositions() and loading the nodes with the stored positions, the freezeForStabilization option freezes all nodes that have been supplied with
  568. an x and y position in place during the stabilization. That way only the support nodes for the smooth curves have to stabilize, greatly speeding up the stabilization process with cached positions.
  569. </td>
  570. </tr>
  571. <tr>
  572. <td><a href="#Groups_configuration">groups</a></td>
  573. <td>Object</td>
  574. <td>none</td>
  575. <td>It is possible to specify custom styles for groups.
  576. Each node assigned a group gets the specified style.
  577. See <a href="#Groups_configuration">Groups configuration</a> for an overview of the available styles
  578. and an example.
  579. </td>
  580. </tr>
  581. <tr>
  582. <td>height</td>
  583. <td>String</td>
  584. <td>"400px"</td>
  585. <td>The height of the network in pixels or as a percentage.</td>
  586. </tr>
  587. <tr>
  588. <td>hover</td>
  589. <td>Boolean</td>
  590. <td>false</td>
  591. <td>Enabling the change of the colors of nodes and edges when the mouse hovers over them. Enabling this may have a minor impact on performance.</td>
  592. </tr>
  593. <tr>
  594. <td><a href="#Keyboard_navigation">keyboard</a></td>
  595. <td>Object</td>
  596. <td>none</td>
  597. <td>
  598. Configuration options for shortcuts keys. Shortcut keys are turned off by default. See section <a href="#Keyboard_navigation">Keyboard navigation</a> for an overview of the available options.
  599. </td>
  600. </tr>
  601. <tr>
  602. <td>dragNetwork</td>
  603. <td>Boolean</td>
  604. <td>true</td>
  605. <td>
  606. Toggle if the network can be dragged. This will not affect the dragging of nodes.
  607. </td>
  608. </tr>
  609. <tr>
  610. <td>dragNodes</td>
  611. <td>Boolean</td>
  612. <td>true</td>
  613. <td>
  614. Toggle if the nodes can be dragged. This will not affect the dragging of the network.
  615. </td>
  616. </tr>
  617. <tr>
  618. <td>hideNodesOnDrag</td>
  619. <td>Boolean</td>
  620. <td>false</td>
  621. <td>
  622. Toggle if the nodes are drawn during a drag. This can greatly improve performance if you have many nodes.
  623. </td>
  624. </tr>
  625. <tr>
  626. <td>hideEdgesOnDrag</td>
  627. <td>Boolean</td>
  628. <td>false</td>
  629. <td>
  630. Toggle if the edges are drawn during a drag. This can greatly improve performance if you have many edges.
  631. </td>
  632. </tr>
  633. <tr>
  634. <td><a href="#Navigation_controls">navigation</a></td>
  635. <td>Object</td>
  636. <td>none</td>
  637. <td>
  638. Configuration options for the navigation controls. See section <a href="#Navigation_controls">Navigation controls</a> for an overview of the available options.
  639. </td>
  640. </tr>
  641. <tr>
  642. <td><a href="#Nodes_configuration">nodes</a></td>
  643. <td>Object</td>
  644. <td>none</td>
  645. <td>
  646. Configuration options applied to all nodes. See section <a href="#Nodes_configuration">Nodes configuration</a> for an overview of the available options.
  647. </td>
  648. </tr>
  649. <tr>
  650. <td>smoothCurves</td>
  651. <td>Boolean || object</td>
  652. <td>object</td>
  653. <td>If true, edges are drawn as smooth curves. This is more computationally intensive since the edge now is a quadratic Bezier curve. This can be further configured by the options below.</td>
  654. </tr>
  655. <tr>
  656. <td>smoothCurves.dynamic</td>
  657. <td>Boolean</td>
  658. <td>true</td>
  659. <td>By default, the edges are dynamic. This means there are support nodes placed in the middle of the edge. This support node is also handed by the physics simulation. If false, the smoothness will be based on the
  660. relative positions of the to and from nodes. This is computationally cheaper but there is no self organisation.</td>
  661. </tr>
  662. <tr>
  663. <td>smoothCurves.type</td>
  664. <td>String</td>
  665. <td>"continuous"</td>
  666. <td>This option only affects NONdynamic smooth curves. The supported types are: <code>continuous, discrete, diagonalCross, straightCross, horizontal, vertical</code>. The effects of these types
  667. are shown in examples <a href="../examples/network/26_staticSmoothCurves.html">26</a> and <a href="../examples/network/27_world_cup_network.html">27</a></td>
  668. </tr>
  669. <tr>
  670. <td>smoothCurves.roundness</td>
  671. <td>Number</td>
  672. <td>0.5</td>
  673. <td>This only affects NONdynamic smooth curves. The roundness can be tweaked with the parameter. The value range is from 0 to 1 with a maximum roundness at 0.5.</td>
  674. </tr>
  675. <tr>
  676. <td>selectable</td>
  677. <td>Boolean</td>
  678. <td>true</td>
  679. <td>If true, nodes in the network can be selected by clicking them.
  680. Long press can be used to select multiple nodes.</td>
  681. </tr>
  682. <tr>
  683. <td>stabilize</td>
  684. <td>Boolean</td>
  685. <td>true</td>
  686. <td>If true, the network is stabilized before displaying it. If false,
  687. the nodes move to a stabe position visibly in an animated way.</td>
  688. </tr>
  689. <tr>
  690. <td>stabilizationIterations</td>
  691. <td>Number</td>
  692. <td>1000</td>
  693. <td>If stabilize is set to true, this number is the (maximum) amount of physics steps the stabilization process takes
  694. before showing the result. If your simulation takes too long to stabilize, this number can be reduced. On the other hand, if your network is not stabilized after loading, this number can be increased.</td>
  695. </tr>
  696. <tr>
  697. <td>zoomExtentOnStabilize</td>
  698. <td>Boolean</td>
  699. <td>true</td>
  700. <td>When the internal stabilize function is called because the stabilize option is set to true OR the hierarchical system (re)initializes, a call to zoomExtent is done by default. By setting this to false, you can avoid this call.</td>
  701. </tr>
  702. <tr>
  703. <td>width</td>
  704. <td>String</td>
  705. <td>"400px"</td>
  706. <td>The width of the network in pixels or as a percentage.</td>
  707. </tr>
  708. <tr>
  709. <td>zoomable</td>
  710. <td>Boolean</td>
  711. <td>true</td>
  712. <td>
  713. Toggle if the network can be zoomed.
  714. </td>
  715. </tr>
  716. </table>
  717. <br>
  718. <h3 id="Nodes_configuration">Nodes configuration</h3>
  719. <p>
  720. Nodes can be configured with different styles and shapes. To configure nodes, provide an object named <code>nodes</code> in the <code>options</code> for the Network.
  721. </p>
  722. <p>
  723. For example to give the nodes a custom color, shape, and size:
  724. </p>
  725. <pre class="prettyprint lang-js">
  726. var options = {
  727. // ...
  728. nodes: {
  729. color: {
  730. background: 'white',
  731. border: 'red',
  732. highlight: {
  733. background: 'pink',
  734. border: 'red'
  735. }
  736. },
  737. shape: 'star',
  738. radius: 24
  739. }
  740. };
  741. </pre>
  742. <p>
  743. The following options are available for nodes. These options must be created
  744. inside an object <code>nodes</code> in the networks options object.</p> All options in green boxes can be defined per-node as well.
  745. All options defined per-node override these global settings.
  746. <table>
  747. <tr>
  748. <th>Name</th>
  749. <th>Type</th>
  750. <th>Default</th>
  751. <th>Description</th>
  752. </tr>
  753. <tr>
  754. <td class="greenField">borderWidth</td>
  755. <td>Number</td>
  756. <td>1</td>
  757. <td>The width of the border of the node when it is not selected, automatically limited by the width of the node.</td>
  758. </tr>
  759. <tr>
  760. <td class="greenField">borderWidthSelected</td>
  761. <td>Number</td>
  762. <td>undefined</td>
  763. <td>The width of the border of the node when it is selected. If left at undefined, double the borderWidth will be used.</td>
  764. </tr>
  765. <tr>
  766. <td>customScalingFunction</td>
  767. <td>Function</td>
  768. <td>Function</td>
  769. <td>This is a function you can override to make the nodes scale the way you want them based on their values. The default function is this: <br>
  770. <pre class="prettyprint lang-js">
  771. function (min,max,total,value) {
  772. if (max == min) {
  773. return 0.5;
  774. }
  775. else {
  776. var scale = 1 / (max - min);
  777. return Math.max(0,(value - min)*scale);
  778. }
  779. };
  780. </pre>
  781. The function receives the minimum value of the set, the maximum value, the total sum of all values and finally the value of the node or edge it works on. It has to return a value between 0 and 1.
  782. The nodes and edges then calculate their size as follows:
  783. <pre class="prettyprint lang-js">
  784. var scale = customScalingFunction(min,max,total,value);
  785. var diff = maxSize - minSize;
  786. mySize = minSize + diff * scale;</pre>
  787. </td>
  788. </tr>
  789. <tr>
  790. <td class="greenField">color</td>
  791. <td>String | Object</td>
  792. <td>Object</td>
  793. <td>Color for the node.</td>
  794. </tr>
  795. <tr>
  796. <td class="greenField">color.background</td>
  797. <td>String</td>
  798. <td>#97C2FC</td>
  799. <td>Background color for the node.</td>
  800. </tr>
  801. <tr>
  802. <td class="greenField">color.border</td>
  803. <td>String</td>
  804. <td>#2B7CE9</td>
  805. <td>Border color for the node.</td>
  806. </tr>
  807. <tr>
  808. <td class="greenField">color.highlight</td>
  809. <td>String | Object</td>
  810. <td>Object</td>
  811. <td>Color of the node when selected.</td>
  812. </tr>
  813. <tr>
  814. <td class="greenField">color.highlight.background</td>
  815. <td>String</td>
  816. <td>#D2E5FF</td>
  817. <td>Background color of the node when selected.</td>
  818. </tr>
  819. <tr>
  820. <td class="greenField">color.highlight.border</td>
  821. <td>String</td>
  822. <td>#2B7CE9</td>
  823. <td>Border color of the node when selected.</td>
  824. </tr>
  825. <tr>
  826. <td class="greenField">color.hover.background</td>
  827. <td>String</td>
  828. <td>#D2E5FF</td>
  829. <td>Background color of the node when the node is hovered over and the hover option is enabled.</td>
  830. </tr>
  831. <tr>
  832. <td class="greenField">color.hover.border</td>
  833. <td>String</td>
  834. <td>#2B7CE9</td>
  835. <td>Border color of the node when the node is hovered over and the hover option is enabled.</td>
  836. </tr>
  837. <tr>
  838. <td class="greenField">fontColor</td>
  839. <td>String</td>
  840. <td>black</td>
  841. <td>Font color for label in the node.</td>
  842. </tr>
  843. <tr>
  844. <td class="greenField">fontFace</td>
  845. <td>String</td>
  846. <td>verdana</td>
  847. <td>Font face for label in the node, for example "verdana" or "arial".</td>
  848. </tr>
  849. <tr>
  850. <td class="greenField">fontSize</td>
  851. <td>Number</td>
  852. <td>14</td>
  853. <td>Font size in pixels for label in the node.</td>
  854. </tr>
  855. <tr>
  856. <td>scaleFontWithValue</td>
  857. <td>Boolean</td>
  858. <td>false</td>
  859. <td>When using values, you can let the font scale with the size of the nodes if you enable the this option.</td>
  860. </tr>
  861. <tr>
  862. <td>fontSizeMin</td>
  863. <td>Number</td>
  864. <td>14</td>
  865. <td>When using values, you can let the font scale with the size of the nodes if you enable the scaleFontWithValue option. This is the minimum value of the fontSize.</td>
  866. </tr>
  867. <tr>
  868. <td></td>fontSizeMax</td>
  869. <td>Number</td>
  870. <td>30</td>
  871. <td>When using values, you can let the font scale with the size of the nodes if you enable the scaleFontWithValue option. This is the maximum value of the fontSize.</td>
  872. </tr>
  873. <tr>
  874. <td>fontSizeMaxVisible</td>
  875. <td>Number</td>
  876. <td>30</td>
  877. <td>When using values, you can let the font scale with the size of the nodes if you enable the scaleFontWithValue option. If you have a wide distribution of values and have a large max fontSize,
  878. the text will become huge if you zoom in on it. This option limits the percieved fontSize to avoid this. If you set it to 20, no label will be larger than fontsize 20 (at scale = 1) regardless of the scale.</td>
  879. </tr>
  880. <tr>
  881. <td>fontDrawThreshold</td>
  882. <td>Number</td>
  883. <td>3</td>
  884. <td>When zooming out, the text becomes smaller. This option sets the minimum size of the label before not being drawn. Just like the fontSizeMaxVisible option, this is the relative fontSize (fontSize * scale).
  885. You can combine this with the min and max values to have the labels of influential nodes show earlier when zooming in.</td>
  886. </tr>
  887. <tr>
  888. <td class="greenField">fontFill</td>
  889. <td>String</td>
  890. <td>undefined</td>
  891. <td>If a color is supplied, there will be a background color behind the label. If left undefined, no background color is shown.</td>
  892. </tr>
  893. <tr>
  894. <td class="greenField">fontStrokeWidth</td>
  895. <td>Number</td>
  896. <td>0</td>
  897. <td>The width of the label stroke (border around label's text) in pixels.</td>
  898. </tr>
  899. <tr>
  900. <td class="greenField">fontStrokeColor</td>
  901. <td>String</td>
  902. <td>'white'</td>
  903. <td>The color of the label stroke.</td>
  904. </tr>
  905. <tr>
  906. <td class="greenField">shape</td>
  907. <td>string</td>
  908. <td>'ellipse'</td>
  909. <td>Define the shape for the node.
  910. Choose from
  911. <code>ellipse</code> (default), <code>circle</code>, <code>box</code>,
  912. <code>database</code>, <code>image</code>, <code>circularImage</code>, <code>label</code>, <code>dot</code>,
  913. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and <code>icon</code>.
  914. <br><br>
  915. In case of <code>image</code> and <code>circularImage</code>, a property with name <code>image</code> must
  916. be provided, containing image urls.
  917. <br><br>
  918. The shapes <code>dot</code>, <code>star</code>, <code>triangle</code>,
  919. <code>triangleDown</code>, and <code>square</code>, are scalable.
  920. The size is determined by the properties <code>radius</code> or
  921. <code>value</code>.
  922. <br><br>
  923. When a property <code>label</code> is provided,
  924. this label will be displayed inside the shape in case of shapes
  925. <code>box</code>, <code>circle</code>, <code>ellipse</code>,
  926. and <code>database</code>.
  927. For all other shapes, the label will be displayed right below the shape.
  928. This shape can be overridden by a group shape, or by a shape of an individual node.
  929. </td>
  930. </tr>
  931. <tr>
  932. <td class="greenField">image</td>
  933. <td>String</td>
  934. <td>undefined</td>
  935. <td>Default image url for the nodes. only applicable to shape <code>image</code>.</td>
  936. </tr>
  937. <tr>
  938. <td class="greenField">brokenImage</td>
  939. <td>String</td>
  940. <td>undefined</td>
  941. <td>Image url to use in the event that the url specified in the <code>image</code> property fails to load. only applicable to shape <code>image</code>.</td>
  942. </tr>
  943. <tr>
  944. <td class="greenField">mass</td>
  945. <td>number</td>
  946. <td>1</td>
  947. <td>When using the Barnes Hut simulation method (which is selected by default),
  948. the mass of a node determines the gravitational repulsion during the simulation. Higher mass will push other nodes further away. Preferably use the physics configuration to
  949. alter the simulation.</td>
  950. </tr>
  951. <tr>
  952. <td>widthMin</td>
  953. <td>Number</td>
  954. <td>16</td>
  955. <td>The minimum width for a scaled image. Only applicable to shape <code>image</code>. This only does something if you supply a value.</td>
  956. </tr>
  957. <tr>
  958. <td>widthMax</td>
  959. <td>Number</td>
  960. <td>64</td>
  961. <td>The maximum width for a scaled image. Only applicable to shape <code>image</code>. This only does something if you supply a value.</td>
  962. </tr>
  963. <tr>
  964. <td class="greenField">radius</td>
  965. <td>Number</td>
  966. <td>10</td>
  967. <td>The default radius for a node. Only applicable to shapes <code>dot</code>,
  968. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.</td>
  969. </tr>
  970. <tr>
  971. <td>radiusMin</td>
  972. <td>Number</td>
  973. <td>10</td>
  974. <td>The minimum radius for a scaled node. Only applicable to shapes <code>dot</code>,
  975. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>. This only does something if you supply a value.</td>
  976. </tr>
  977. <tr>
  978. <td>radiusMax</td>
  979. <td>Number</td>
  980. <td>30</td>
  981. <td>The maximum radius for a scaled node. Only applicable to shapes <code>dot</code>,
  982. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>. This only does something if you supply a value.</td>
  983. </tr>
  984. <tr>
  985. <td class="greenField">iconFontFace</td>
  986. <td>String</td>
  987. <td>undefined</td>
  988. <td>Font face for icons, for example <code>FontAwesome</code> or <code>Ionicon</code>.<br /><em>You have to link to the css defining the font by yourself (see Examples)</em></td>
  989. </tr>
  990. <tr>
  991. <td class="greenField">icon</td>
  992. <td>String</td>
  993. <td>undefined</td>
  994. <td>Unicode of the icon f.e. <code>\uf0c0</code> (user-icon in FontAwesome)</td>
  995. </tr>
  996. <tr>
  997. <td class="greenField">iconSize</td>
  998. <td>Number</td>
  999. <td>50</td>
  1000. <td>Size of the icon</td>
  1001. </tr>
  1002. <tr>
  1003. <td class="greenField">color</td>
  1004. <td>String</td>
  1005. <td>black</td>
  1006. <td>Color of the icon</td>
  1007. </tr>
  1008. </table>
  1009. <h3 id="Edges_configuration">Edges configuration</h3>
  1010. <p>
  1011. Edges can be configured with different length and styling. To configure edges, provide an object named <code>edges</code> in the <code>options</code> for the Network.
  1012. Because the length of an edge is a property of the physics simulation, you can change the length of the edge by changing the springLength in your selected physics solver.
  1013. To change the edge length of individual edges, you can use the <code>length</code> property in the <a href="#Edges">edge definition</a>.
  1014. </p>
  1015. <p>
  1016. For example to set the width of all edges to 2 pixels and give them a red color:
  1017. </p>
  1018. <pre class="prettyprint lang-js">
  1019. var options = {
  1020. // ...
  1021. edges: {
  1022. color: 'red',
  1023. width: 2
  1024. }
  1025. };
  1026. </pre>
  1027. <p>
  1028. The following options are available for edges. These options must be created
  1029. inside an object <code>edges</code> in the networks options object. All options in green boxes can be defined per-edge as well.
  1030. All options defined per-edge override these global settings.
  1031. </p>
  1032. <table>
  1033. <tr>
  1034. <th>Name</th>
  1035. <th>Type</th>
  1036. <th>Default</th>
  1037. <th>Description</th>
  1038. </tr>
  1039. <tr>
  1040. <td class="greenField">arrowScaleFactor</td>
  1041. <td>Number</td>
  1042. <td>1</td>
  1043. <td>If you are using arrows, this will scale the arrow. Values < 1 give smaller arrows, > 1 larger arrows. Default: 1.</td>
  1044. </tr>
  1045. <tr>
  1046. <td class="greenField">color</td>
  1047. <td>String | Object</td>
  1048. <td>Object</td>
  1049. <td>Color for the edge.</td>
  1050. </tr>
  1051. <tr>
  1052. <td class="greenField">color.color</td>
  1053. <td>String</td>
  1054. <td>#848484</td>
  1055. <td>Color of the edge when not selected.</td>
  1056. </tr>
  1057. <tr>
  1058. <td class="greenField">color.highlight</td>
  1059. <td>String</td>
  1060. <td>#848484</td>
  1061. <td>Color of the edge when selected.</td>
  1062. </tr>
  1063. <tr>
  1064. <td class="greenField">color.hover</td>
  1065. <td>String</td>
  1066. <td>#848484</td>
  1067. <td>Color of the edge when the edge is hovered over and the hover option is enabled.</td>
  1068. </tr>
  1069. <tr>
  1070. <td class="greenField">hoverWidth</td>
  1071. <td>Number</td>
  1072. <td>1.5</td>
  1073. <td>This determines the thickness of the edge if it is hovered over. This will only manifest when the hover option is enabled.</td>
  1074. </tr>
  1075. <tr>
  1076. <td class="greenField">dash</td>
  1077. <td>Object</td>
  1078. <td>Object</td>
  1079. <td>
  1080. Object containing properties for dashed lines.
  1081. Available properties: <code>length</code>, <code>gap</code>,
  1082. <code>altLength</code>.
  1083. </td>
  1084. </tr>
  1085. <tr>
  1086. <td class="greenField">dash.altLength</td>
  1087. <td>number</td>
  1088. <td>undefined</td>
  1089. <td>Length of the alternated dash in pixels on a dashed line.
  1090. Specifying <code>dash.altLength</code> allows for creating
  1091. a dashed line with a dash-dot style, for example when
  1092. <code>dash.length=10</code> and <code>dash.altLength=5</code>.
  1093. See also the option <code>dahs.length</code>.
  1094. Only applicable when the line style is <code>dash-line</code>.</td>
  1095. </tr>
  1096. <tr>
  1097. <td class="greenField">dash.length</td>
  1098. <td>number</td>
  1099. <td>10</td>
  1100. <td>Length of a dash in pixels on a dashed line.
  1101. Only applicable when the line style is <code>dash-line</code>.</td>
  1102. </tr>
  1103. <tr>
  1104. <td class="greenField">dash.gap</td>
  1105. <td>number</td>
  1106. <td>5</td>
  1107. <td>Length of a gap in pixels on a dashed line.
  1108. Only applicable when the line style is <code>dash-line</code>.</td>
  1109. </tr>
  1110. <tr>
  1111. <td class="greenField">fontColor</td>
  1112. <td>String</td>
  1113. <td>#343434</td>
  1114. <td>Font color for the text label of the edge.
  1115. Only applicable when property <code>label</code> is defined.</td>
  1116. </tr>
  1117. <tr>
  1118. <td class="greenField">fontFace</td>
  1119. <td>String</td>
  1120. <td>arial</td>
  1121. <td>Font face for the text label of the edge,
  1122. for example "verdana" or "arial".
  1123. Only applicable when property <code>label</code> is defined.</td>
  1124. </tr>
  1125. <tr>
  1126. <td class="greenField">fontSize</td>
  1127. <td>Number</td>
  1128. <td>14</td>
  1129. <td>Font size in pixels for the text label of the edge.
  1130. Only applicable when property <code>label</code> is defined.</td>
  1131. </tr>
  1132. <tr>
  1133. <td class="greenField">fontFill</td>
  1134. <td>string</td>
  1135. <td>white</td>
  1136. <td>Font fill for the background color of the text label of the edge.
  1137. Only applicable when property <code>label</code> is defined.</td>
  1138. </tr>
  1139. <tr>
  1140. <td class="greenField">fontStrokeWidth</td>
  1141. <td>Number</td>
  1142. <td>0</td>
  1143. <td>The width of the label stroke (border around label's text) in pixels.
  1144. Only applicable when property <code>label</code> is defined.</td>
  1145. </tr>
  1146. <tr>
  1147. <td class="greenField">fontStrokeColor</td>
  1148. <td>String</td>
  1149. <td>'white'</td>
  1150. <td>The color of the label stroke.
  1151. Only applicable when property <code>label</code> is defined.</td>
  1152. </tr>
  1153. <tr>
  1154. <td class="greenField">inheritColor</td>
  1155. <td>String | Boolean</td>
  1156. <td>from</td>
  1157. <td>Possible values: <code>"to","from", true, false</code>. If this value is set to false, the edge color information is used. If the value is set to true or "from",
  1158. the color data from the borders of the "from" node is used. If this value is "to", the color data from the borders of the "to" node is used.</td>
  1159. </tr>
  1160. <tr>
  1161. <td class="greenField">labelAlignment</td>
  1162. <td>String</td>
  1163. <td>horizontal</td>
  1164. <td>Possible values: <code>"line-above", "line-center", "line-below"</code>. The alignment of the label when drawn on the edge.
  1165. If <code>horizontal</code> it will align the label absolute horizontial.</td>
  1166. </tr>
  1167. <tr>
  1168. <td class="greenField">opacity</td>
  1169. <td>Number</td>
  1170. <td>1.0</td>
  1171. <td>Possible values: <code>[0 .. 1]</code>. This opacity value is added on top of the color information. This only happens for the unselected state.</td>
  1172. </tr>
  1173. <tr>
  1174. <td class="greenField">style</td>
  1175. <td>string</td>
  1176. <td>line</td>
  1177. <td>Define a line style for the edge.
  1178. Choose from <code>line</code> (default), <code>arrow</code>,
  1179. <code>arrow-center</code>, or <code>dash-line</code>.
  1180. </td>
  1181. </tr>
  1182. <tr>
  1183. <td class="greenField">width</td>
  1184. <td>number</td>
  1185. <td>1</td>
  1186. <td>Width of the line in pixels. The <code>width</code> will
  1187. override a specified <code>value</code>, if a <code>value</code> is
  1188. specified too.</td>
  1189. </tr>
  1190. <tr>
  1191. <td class="greenField">widthSelectionMultiplier</td>
  1192. <td>Number</td>
  1193. <td>2</td>
  1194. <td>Determines the thickness scaling of an selected edge. This is applied when an edge, or a node connected to it, is selected.</td>
  1195. </tr>
  1196. <tr>
  1197. <td>widthMin</td>
  1198. <td>Number</td>
  1199. <td>1</td>
  1200. <td>The minimum thickness of the line when using per-edge defined values. This does nothing if you have not defined a value.</td>
  1201. </tr>
  1202. <tr>
  1203. <td>widthMax</td>
  1204. <td>Number</td>
  1205. <td>15</td>
  1206. <td>The maximum thickness of the line when using per-edge defined values. This does nothing if you have not defined a value.</td>
  1207. </tr>
  1208. </table>
  1209. <h3 id="Groups_configuration">Groups configuration</h3>
  1210. <p>It is possible to specify custom styles for groups of nodes.
  1211. Each node having assigned to this group gets the specified style.
  1212. The options <code>groups</code> is an object containing one or multiple groups,
  1213. identified by a unique string, the groupname.
  1214. </p>
  1215. <p>
  1216. A group can have the following styles:
  1217. </p>
  1218. <pre class="prettyprint lang-js">
  1219. var options = {
  1220. // ...
  1221. groups: {
  1222. mygroup: {
  1223. shape: 'circle',
  1224. color: {
  1225. border: 'black',
  1226. background: 'white',
  1227. highlight: {
  1228. border: 'yellow',
  1229. background: 'orange'
  1230. }
  1231. }
  1232. fontColor: 'red',
  1233. fontSize: 18
  1234. }
  1235. // add more groups here
  1236. }
  1237. };
  1238. var nodes = [
  1239. {id: 1, label: 'Node 1'}, // will get the default style
  1240. {id: 2, label: 'Node 2', group: 'mygroup'}, // will get the style from 'mygroup'
  1241. // ... more nodes
  1242. ];
  1243. </pre>
  1244. <p>The following styles are available for groups:</p>
  1245. <table>
  1246. <tr>
  1247. <th>Name</th>
  1248. <th>Type</th>
  1249. <th>Default</th>
  1250. <th>Description</th>
  1251. </tr>
  1252. <tr>
  1253. <td>color</td>
  1254. <td>String | Object</td>
  1255. <td>Object</td>
  1256. <td>Color of the node</td>
  1257. </tr>
  1258. <tr>
  1259. <td>color.border</td>
  1260. <td>String</td>
  1261. <td>"#2B7CE9"</td>
  1262. <td>Border color of the node</td>
  1263. </tr>
  1264. <tr>
  1265. <td>color.background</td>
  1266. <td>String</td>
  1267. <td>"#97C2FC"</td>
  1268. <td>Background color of the node</td>
  1269. </tr>
  1270. <tr>
  1271. <td>color.highlight</td>
  1272. <td>String | Object</td>
  1273. <td>"#D2E5FF"</td>
  1274. <td>Default color of the node when the node is selected. In case of a string, the color is applied to
  1275. both border and background of the node.</td>
  1276. </tr>
  1277. <tr>
  1278. <td>color.highlight.background</td>
  1279. <td>String</td>
  1280. <td>"#D2E5FF"</td>
  1281. <td>Background color of the node when selected.</td>
  1282. </tr>
  1283. <tr>
  1284. <td>color.highlight.border</td>
  1285. <td>String</td>
  1286. <td>"#D2E5FF"</td>
  1287. <td>Border color of the node when selected.</td>
  1288. </tr>
  1289. <tr>
  1290. <td>image</td>
  1291. <td>String</td>
  1292. <td>none</td>
  1293. <td>Default image for the nodes. Only applicable in combination with
  1294. shape <code>image</code>.</td>
  1295. </tr>
  1296. <tr>
  1297. <td>fontColor</td>
  1298. <td>String</td>
  1299. <td>"black"</td>
  1300. <td>Font color of the node.</td>
  1301. </tr>
  1302. <tr>
  1303. <td>fontFace</td>
  1304. <td>String</td>
  1305. <td>"sans"</td>
  1306. <td>Font name of the node, for example "verdana" or "arial".</td>
  1307. </tr>
  1308. <tr>
  1309. <td>fontSize</td>
  1310. <td>Number</td>
  1311. <td>14</td>
  1312. <td>Font size for the node in pixels.</td>
  1313. </tr>
  1314. <tr>
  1315. <td>fontStrokeWidth</td>
  1316. <td>Number</td>
  1317. <td>0</td>
  1318. <td>The width of the label stroke (border around label's text) in pixels.</td>
  1319. </tr>
  1320. <tr>
  1321. <td>fontStrokeColor</td>
  1322. <td>String</td>
  1323. <td>"white"</td>
  1324. <td>The color of the label stroke.</td>
  1325. </tr>
  1326. <tr>
  1327. <td>shape</td>
  1328. <td>String</td>
  1329. <td>"ellipse"</td>
  1330. <td>Choose from
  1331. <code>ellipse</code> (default), <code>circle</code>, <code>box</code>,
  1332. <code>database</code>, <code>image</code>, <code>label</code>, <code>dot</code>,
  1333. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.
  1334. In case of image, a property with name image must be provided, containing
  1335. image urls.</td>
  1336. </tr>
  1337. <tr>
  1338. <td>radius</td>
  1339. <td>Number</td>
  1340. <td>5</td>
  1341. <td>Default radius for the node. Only applicable in combination with
  1342. shapes <code>box</code> and <code>dot</code>.</td>
  1343. </tr>
  1344. </table>
  1345. <h3 id="Physics">Physics</h3>
  1346. <p>
  1347. The original simulation method was based on particel physics with a repulsion field (potential) around each node,
  1348. and the edges were modelled as springs. The new system employed the <a href="http://en.wikipedia.org/wiki/Barnes%E2%80%93Hut_simulation">Barnes-Hut</a> gravitational simulation model. The edges are still modelled as springs.
  1349. To unify the physics system, the damping, repulsion distance and edge length have been combined in an physics option. To retain good behaviour, both the old repulsion model and the Barnes-Hut model have their own parameters.
  1350. If no options for the physics system are supplied, the Barnes-Hut method will be used with the default parameters. If you want to customize the physics system easily, you can use the configurePhysics option. <br/>
  1351. When using the hierarchical display option, hierarchicalRepulsion is automatically used as the physics solver. Similarly, if you use the hierarchicalRepulsion physics option, hierarchical display is automatically turned on with default settings.
  1352. <p class="important_note">Note: if the behaviour of your network is not the way you want it, use configurePhysics as described <u><a href="#PhysicsConfiguration">below</a></u> or by <u><a href="../examples/network/25_physics_configuration.html">example 25</a></u>.</p>
  1353. </p>
  1354. <pre class="prettyprint">
  1355. // These variables must be defined in an options object named physics.
  1356. // If a variable is not supplied, the default value is used.
  1357. var options = {
  1358. physics: {
  1359. barnesHut: {
  1360. enabled: true,
  1361. gravitationalConstant: -2000,
  1362. centralGravity: 0.1,
  1363. springLength: 95,
  1364. springConstant: 0.04,
  1365. damping: 0.09
  1366. },
  1367. repulsion: {
  1368. centralGravity: 0.1,
  1369. springLength: 50,
  1370. springConstant: 0.05,
  1371. nodeDistance: 100,
  1372. damping: 0.09
  1373. },
  1374. hierarchicalRepulsion: {
  1375. centralGravity: 0.5,
  1376. springLength: 150,
  1377. springConstant: 0.01,
  1378. nodeDistance: 60,
  1379. damping: 0.09
  1380. }
  1381. }
  1382. </pre>
  1383. <h5>barnesHut:</h5>
  1384. <table>
  1385. <tr>
  1386. <th>Name</th>
  1387. <th>Type</th>
  1388. <th>Default</th>
  1389. <th>Description</th>
  1390. </tr>
  1391. <tr>
  1392. <td>enabled</td>
  1393. <td>Boolean</td>
  1394. <td>true</td>
  1395. <td>This switches the Barnes-Hut simulation on or off. If it is turned off, the old repulsion model is used. Barnes-Hut is generally faster and yields better results.</td>
  1396. </tr>
  1397. <tr>
  1398. <td>gravitationalConstant</td>
  1399. <td>Number</td>
  1400. <td>-2000</td>
  1401. <td>This is the gravitational constand used to calculate the gravity forces. More information is available <a href="http://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation" target="_blank">here</a>.</td>
  1402. </tr>
  1403. <tr>
  1404. <td>centralGravity</td>
  1405. <td>Number</td>
  1406. <td>0.1</td>
  1407. <td>The central gravity is a force that pulls all nodes to the center. This ensures independent groups do not float apart.</td>
  1408. </tr>
  1409. <tr>
  1410. <td>springLength</td>
  1411. <td>Number</td>
  1412. <td>95</td>
  1413. <td>In the previous versions this was a property of the edges, called length. This is the length of the springs when they are at rest. During the simulation they will be streched by the gravitational fields.
  1414. To greatly reduce the edge length, the gravitationalConstant has to be reduced as well.</td>
  1415. </tr>
  1416. <tr>
  1417. <td>springConstant</td>
  1418. <td>Number</td>
  1419. <td>0.04</td>
  1420. <td>This is the spring constant used to calculate the spring forces based on Hooke&prime;s Law. More information is available <a href="http://en.wikipedia.org/wiki/Hooke's_law" target="_blank">here</a>.</td>
  1421. </tr>
  1422. <tr>
  1423. <td>damping</td>
  1424. <td>Number</td>
  1425. <td>0.09</td>
  1426. <td>This is the damping constant. It is used to dissipate energy from the system to have it settle in an equilibrium. More information is available <a href="http://en.wikipedia.org/wiki/Damping" target="_blank">here</a>.</td>
  1427. </tr>
  1428. </table>
  1429. <h5>repulsion:</h5>
  1430. <table>
  1431. <tr>
  1432. <th>Name</th>
  1433. <th>Type</th>
  1434. <th>Default</th>
  1435. <th>Description</th>
  1436. </tr>
  1437. <tr>
  1438. <td>centralGravity</td>
  1439. <td>Number</td>
  1440. <td>0.1</td>
  1441. <td>The central gravity is a force that pulls all nodes to the center. This ensures independent groups do not float apart.</td>
  1442. </tr>
  1443. <tr>
  1444. <td>nodeDistance</td>
  1445. <td>Number</td>
  1446. <td>100</td>
  1447. <td>This parameter is used to define the distance of influence of the repulsion field of the nodes. Below half this distance, the repulsion is maximal and beyond twice this distance the repulsion is zero.</td>
  1448. </tr>
  1449. <tr>
  1450. <td>springLength</td>
  1451. <td>Number</td>
  1452. <td>50</td>
  1453. <td>In the previous versions this was a property of the edges, called length. This is the length of the springs when they are at rest. During the simulation they will be streched by the gravitational fields.
  1454. To greatly reduce the edge length, the gravitationalConstant has to be reduced as well.</td>
  1455. </tr>
  1456. <tr>
  1457. <td>springConstant</td>
  1458. <td>Number</td>
  1459. <td>0.05</td>
  1460. <td>This is the spring constant used to calculate the spring forces based on Hooke&prime;s Law. More information is available <a href="http://en.wikipedia.org/wiki/Hooke's_law" target="_blank">here</a>.</td>
  1461. </tr>
  1462. <tr>
  1463. <td>damping</td>
  1464. <td>Number</td>
  1465. <td>0.09</td>
  1466. <td>This is the damping constant. It is used to dissipate energy from the system to have it settle in an equilibrium. More information is available <a href="http://en.wikipedia.org/wiki/Damping" target="_blank">here</a>.</td>
  1467. </tr>
  1468. </table>
  1469. <h5>hierarchicalRepulsion:</h5>
  1470. <table>
  1471. <tr>
  1472. <th>Name</th>
  1473. <th>Type</th>
  1474. <th>Default</th>
  1475. <th>Description</th>
  1476. </tr>
  1477. <tr>
  1478. <td>centralGravity</td>
  1479. <td>Number</td>
  1480. <td>0.5</td>
  1481. <td>The central gravity is a force that pulls all nodes to the center. This ensures independent groups do not float apart.</td>
  1482. </tr>
  1483. <tr>
  1484. <td>nodeDistance</td>
  1485. <td>Number</td>
  1486. <td>60</td>
  1487. <td>This parameter is used to define the distance of influence of the repulsion field of the nodes. Below half this distance, the repulsion is maximal and beyond twice this distance the repulsion is zero.</td>
  1488. </tr>
  1489. <tr>
  1490. <td>springLength</td>
  1491. <td>Number</td>
  1492. <td>100</td>
  1493. <td>In the previous versions this was a property of the edges, called length. This is the length of the springs when they are at rest. During the simulation they will be streched by the gravitational fields.
  1494. To greatly reduce the edge length, the gravitationalConstant has to be reduced as well.</td>
  1495. </tr>
  1496. <tr>
  1497. <td>springConstant</td>
  1498. <td>Number</td>
  1499. <td>0.01</td>
  1500. <td>This is the spring constant used to calculate the spring forces based on Hooke&prime;s Law. More information is available <a href="http://en.wikipedia.org/wiki/Hooke's_law" target="_blank">here</a>.</td>
  1501. </tr>
  1502. <tr>
  1503. <td>damping</td>
  1504. <td>Number</td>
  1505. <td>0.09</td>
  1506. <td>This is the damping constant. It is used to dissipate energy from the system to have it settle in an equilibrium. More information is available <a href="http://en.wikipedia.org/wiki/Damping" target="_blank">here</a>.</td>
  1507. </tr>
  1508. </table>
  1509. <h4 id="PhysicsConfiguration">Configuration:</h4>
  1510. Every dataset is different. Nodes can have different sizes based on content, interconnectivity can be high or low etc. Because of this, network has a special option
  1511. that the user can use to explore which settings may be good for him or her. This is ment to be used during the development phase when you are implementing vis.js. Once you have found
  1512. settings you are happy with, you can supply them to network using the physics options as described above.
  1513. On start, the default settings will be loaded. Keep in mind that selecting the hierarchical simulation mode <b>disables</b> smooth curves. These will not be enabled again afterwards.
  1514. <pre class="prettyprint">
  1515. var options = {
  1516. configurePhysics:true
  1517. }
  1518. </pre>
  1519. <h3 id="Data_manipulation">Data manipulation</h3>
  1520. <p>
  1521. By using the data manipulation feature of the network you can dynamically create nodes, connect nodes with edges, edit nodes or delete nodes and edges.
  1522. The toolbar is fully HTML and CSS so the user can style this to their preference. To control the behaviour of the data manipulation, users can insert custom functions
  1523. into the data manipulation process. For example, an injected function can show an detailed pop-up when a user wants to add a node. In <a href="../examples/network/21_data_manipulation.html">example 21</a>,
  1524. two functions have been injected into the add and edit functionality. This is described in more detail in the next subsection. To correctly display the manipulation icons, the <b>vis.css</b> file must be included.
  1525. The user is free to alter or overload the CSS classes but without them the navigation icons are not visible.
  1526. </p>
  1527. <pre class="prettyprint">
  1528. // These variables must be defined in an options object named dataManipulation.
  1529. // If a variable is not supplied, the default value is used.
  1530. var options = {
  1531. dataManipulation: {
  1532. enabled: false,
  1533. initiallyVisible: false
  1534. }
  1535. }
  1536. // OR to just load the module with default values:
  1537. var options = {
  1538. dataManipulation: true
  1539. }
  1540. </pre>
  1541. <table>
  1542. <tr>
  1543. <th>Name</th>
  1544. <th>Type</th>
  1545. <th>Default</th>
  1546. <th>Description</th>
  1547. </tr>
  1548. <tr>
  1549. <td>enabled</td>
  1550. <td>Boolean</td>
  1551. <td>false</td>
  1552. <td>Enabling or disabling of the data manipulation toolbar. If it is initially hidden, an edit button appears in the top left corner.</td>
  1553. </tr>
  1554. <tr>
  1555. <td>initiallyVisible</td>
  1556. <td>Boolean</td>
  1557. <td>false</td>
  1558. <td>Initially hide or show the data manipulation toolbar.</td>
  1559. </tr>
  1560. </table>
  1561. <h4 id="Data_manipulation_custom">Data manipulation: custom functionality</h4>
  1562. <p>
  1563. Users can insert custom functions into the add node, edit node, connect nodes, and delete selected operations. This is done by supplying them in the options.
  1564. If the callback is NOT called, nothing happens. <a href="../examples/network/21_data_manipulation.html">Example 21</a> has two working examples
  1565. for the add and edit functions. The data the user is supplied with in these functions has been described in the code below.
  1566. For the add data, you can add any and all options that are accepted for node creation as described above. The same goes for edit, however only the fields described
  1567. in the code below contain information on the selected node. The callback for connect accepts any options that are used for edge creation. Only the callback for delete selected
  1568. requires the same data structure that is supplied to the user. <br /><br />
  1569. <b>If there is no injected function supplied for the edit operation, the button will not be shown in the toolbar.</b>
  1570. </p>
  1571. <pre class="prettyprint">
  1572. // If a variable is not supplied, the default value is used.
  1573. var options = {
  1574. dataManipulation: true,
  1575. onAdd: function(data,callback) {
  1576. /** data = {id: random unique id,
  1577. * label: new,
  1578. * x: x position of click (canvas space),
  1579. * y: y position of click (canvas space),
  1580. * allowedToMoveX: true,
  1581. * allowedToMoveY: true
  1582. * };
  1583. */
  1584. var newData = {..}; // alter the data as you want.
  1585. // all fields normally accepted by a node can be used.
  1586. callback(newData); // call the callback to add a node.
  1587. },
  1588. onEdit: function(data,callback) {
  1589. /** data = {id:...,
  1590. * label: ...,
  1591. * group: ...,
  1592. * shape: ...,
  1593. * color: {
  1594. * background:...,
  1595. * border:...,
  1596. * highlight: {
  1597. * background:...,
  1598. * border:...
  1599. * }
  1600. * }
  1601. * };
  1602. */
  1603. var newData = {..}; // alter the data as you want.
  1604. // all fields normally accepted by a node can be used.
  1605. callback(newData); // call the callback with the new data to edit the node.
  1606. }
  1607. onEditEdge: function(data,callback) {
  1608. /** data = {id: edgeID,
  1609. * from: nodeId1,
  1610. * to: nodeId2,
  1611. * };
  1612. */
  1613. var newData = {..}; // alter the data as you want, except for the ID.
  1614. // all fields normally accepted by an edge can be used.
  1615. callback(newData); // call the callback with the new data to edit the edge.
  1616. }
  1617. onConnect: function(data,callback) {
  1618. // data = {from: nodeId1, to: nodeId2};
  1619. var newData = {..}; // check or alter data as you see fit.
  1620. callback(newData); // call the callback to connect the nodes.
  1621. },
  1622. onDelete: function(data,callback) {
  1623. // data = {nodes: [selectedNodeIds], edges: [selectedEdgeIds]};
  1624. var newData = {..}; // alter the data as you want.
  1625. // the same data structure is required.
  1626. callback(newData); // call the callback to delete the objects.
  1627. }
  1628. };
  1629. </pre>
  1630. <p>
  1631. Because the interface elements are CSS and HTML, the user will have to correct for size changes of the canvas. To facilitate this, a new event has been added called resize.
  1632. A function can be bound to this event. This function is supplied with the new widht and height of the canvas. The CSS can then be updated accordingly.
  1633. An code snippet from example 21 is shown below.
  1634. </p>
  1635. <pre class="prettyprint">
  1636. network.on("resize", function(params) {console.log(params.width,params.height)});
  1637. </pre>
  1638. <h3 id="Clustering">Clustering</h3>
  1639. <p>
  1640. The network now supports dynamic clustering of nodes. This allows a user to view a very large dataset (> 50.000 nodes) without
  1641. sacrificing performance. When loading a large dataset, the nodes are clustered initially (this may take a small while) to have a
  1642. responsive visualization to work with. The clustering is both outside-in and inside-out. Outside-in means that nodes with only one
  1643. connection will be contained, or clustered, in the node it is connected to. Inside-out clustering first determines which nodes are hubs.
  1644. Hubs are defined as the nodes with the top 3% highest amount of connections (assuming normal distribution). These hubs then "grow", meaning
  1645. they contain the nodes they are connected to within themselves. The edges that were connected to the nodes that are absorbed will be reconnected to the cluster.
  1646. <br />
  1647. <br />
  1648. A cluster is just a node that has references to the nodes and edges it contains. It has an internal counter to keep track of its size, which is then used
  1649. to calculate the required forces. The contained nodes are removed from the global nodes index, greatly speeding up the system.
  1650. <br />
  1651. <br />
  1652. The clustering has the following user-configurable settings. The default values have been tested with the Network examples and work well.
  1653. The default state for clustering is <b>off</b>.
  1654. </p>
  1655. <pre class="prettyprint">
  1656. // These variables must be defined in an options object named clustering.
  1657. // If a variable is not supplied, the default value is used.
  1658. var options = {
  1659. clustering: {
  1660. initialMaxNodes: 100,
  1661. clusterThreshold:500,
  1662. reduceToNodes:300,
  1663. chainThreshold: 0.4,
  1664. clusterEdgeThreshold: 20,
  1665. sectorThreshold: 100,
  1666. screenSizeThreshold: 0.2,
  1667. fontSizeMultiplier: 4.0,
  1668. maxFontSize: 1000,
  1669. forceAmplification: 0.1,
  1670. distanceAmplification: 0.1,
  1671. edgeGrowth: 20,
  1672. nodeScaling: {width: 1,
  1673. height: 1,
  1674. radius: 1},
  1675. maxNodeSizeIncrements: 600,
  1676. activeAreaBoxSize: 100,
  1677. clusterLevelDifference: 2,
  1678. clusterByZoom: true
  1679. }
  1680. }
  1681. // OR to just load the module with default values:
  1682. var options = {
  1683. clustering: true
  1684. }
  1685. </pre>
  1686. <table>
  1687. <tr>
  1688. <th>Name</th>
  1689. <th>Type</th>
  1690. <th>Default</th>
  1691. <th>Description</th>
  1692. </tr>
  1693. <tr>
  1694. <td>initialMaxNodes</td>
  1695. <td>Number</td>
  1696. <td>100</td>
  1697. <td>If the initial amount of nodes is larger than this value, clustering starts until the total number of nodes is less than this value.</td>
  1698. </tr>
  1699. <tr>
  1700. <td>clusterThreshold</td>
  1701. <td>Number</td>
  1702. <td>500</td>
  1703. <td>While zooming in and out, clusters can open up. Once there are more than <code>absoluteMaxNumberOfNodes</code> nodes,
  1704. clustering starts until <code>reduceToMaxNumberOfNodes</code> nodes are left. This is done to ensure performance is continuously fluid.</td>
  1705. </tr>
  1706. <tr>
  1707. <td>reduceToNodes</td>
  1708. <td>Number</td>
  1709. <td>300</td>
  1710. <td>While zooming in and out, clusters can open up. Once there are more than <code>absoluteMaxNumberOfNodes</code> nodes,
  1711. clustering starts until <code>reduceToMaxNumberOfNodes</code> nodes are left. This is done to ensure performance is continiously fluid.</td>
  1712. </tr>
  1713. <tr>
  1714. <td>chainThreshold</td>
  1715. <td>Number</td>
  1716. <td>0.4</td>
  1717. <td>Because of the clustering methods used, long chains of nodes can be formed. To reduce these chains, this threshold is used.
  1718. A <code>chainThreshold</code> of 0.4 means that no more than 40% of all nodes are allowed to be a chain node (two connections).
  1719. If there are more, they are clustered together.</td>
  1720. </tr>
  1721. <tr>
  1722. <td>clusterEdgeThreshold</td>
  1723. <td>Number</td>
  1724. <td>20</td>
  1725. <td>This is the absolute edge length threshold in pixels. If the edge is smaller on screen (that means zooming out reduces this length)
  1726. the node will be clustered. This is triggered when zooming out.</td>
  1727. </tr>
  1728. <tr>
  1729. <td>sectorThreshold</td>
  1730. <td>Integer</td>
  1731. <td>50</td>
  1732. <td>If a cluster larger than <code>sectorThreshold</code> is opened, a seperate instance called a sector, will be created. All the simulation of
  1733. nodes outside of this instance will be paused. This is to maintain performance and clarity when examining large clusters.
  1734. A sector is collapsed when zooming out far enough. Also, when opening a cluster, if this cluster is smaller than this value, it is fully unpacked.</td>
  1735. </tr>
  1736. <tr>
  1737. <td>screenSizeThreshold</td>
  1738. <td>Number</td>
  1739. <td>0.2</td>
  1740. <td>When zooming in, the clusters become bigger. A <code>screenSizeThreshold</code> of 0.2 means that if the width or height of this cluster
  1741. becomes bigger than 20% of the width or height of the canvas, the cluster is opened. If a sector has been created, if the sector is smaller than
  1742. 20%, we collapse this sector.</td>
  1743. </tr>
  1744. <tr>
  1745. <td>fontSizeMultiplier</td>
  1746. <td>Number</td>
  1747. <td>4.0</td>
  1748. <td>This parameter denotes the increase in fontSize of the cluster when a single node is added to it.</td>
  1749. </tr>
  1750. <tr>
  1751. <td>maxFontSize</td>
  1752. <td>Number</td>
  1753. <td>1000</td>
  1754. <td>This parameter denotes the largest allowed font size. If the font becomes too large, some browsers experience problems displaying this.</td>
  1755. </tr>
  1756. <tr>
  1757. <td>forceAmplification</td>
  1758. <td>Number</td>
  1759. <td>0.6</td>
  1760. <td>This factor is used to calculate the increase of the repulsive force of a cluster. It is calculated by the following
  1761. formula: <code>repulsingForce *= 1 + (clusterSize * forceAmplification)</code>.</td>
  1762. </tr>
  1763. <tr>
  1764. <td>distanceAmplification</td>
  1765. <td>Number</td>
  1766. <td>0.2</td>
  1767. <td>This factor is used to calculate the increase in effective range of the repulsive force of the cluster.
  1768. A larger cluster has a longer range. It is calculated by the following
  1769. formula: <code>minDistance *= 1 + (clusterSize * distanceAmplification)</code>.</td>
  1770. </tr>
  1771. <tr>
  1772. <td>edgeGrowth</td>
  1773. <td>Number</td>
  1774. <td>20</td>
  1775. <td>This factor determines the elongation of edges connected to a cluster.</td>
  1776. </tr>
  1777. <tr>
  1778. <td>nodeScaling.width</td>
  1779. <td>Number</td>
  1780. <td>10</td>
  1781. <td>This factor determines how much the width of a cluster increases in pixels per added node.</td>
  1782. </tr>
  1783. <tr>
  1784. <td>nodeScaling.height</td>
  1785. <td>Number</td>
  1786. <td>10</td>
  1787. <td>This factor determines how much the height of a cluster increases in pixels per added node.</td>
  1788. </tr>
  1789. <tr>
  1790. <td>nodeScaling.radius</td>
  1791. <td>Number</td>
  1792. <td>10</td>
  1793. <td>This factor determines how much the radius of a cluster increases in pixels per added node.</td>
  1794. </tr>
  1795. <tr>
  1796. <td>maxNodeSizeIncrements</td>
  1797. <td>Number</td>
  1798. <td>600</td>
  1799. <td>This limits the size clusters can grow to. The default value, 600, implies that if a cluster contains more than 600 nodes, it will no longer grow.</td>
  1800. </tr>
  1801. <tr>
  1802. <td>activeAreaBoxSize</td>
  1803. <td>Number</td>
  1804. <td>100</td>
  1805. <td>Imagine a square with an edge length of <code>activeAreaBoxSize</code> pixels around your cursor.
  1806. If a cluster is in this box as you zoom in, the cluster can be opened in a seperate sector.
  1807. This is regardless of the zoom level.</td>
  1808. </tr>
  1809. <tr>
  1810. <td>clusterLevelDifference</td>
  1811. <td>Number</td>
  1812. <td>2</td>
  1813. <td>At every clustering session, Network will check if the difference between cluster levels is
  1814. acceptable. When a cluster is formed when zooming out, that is one cluster level.
  1815. If you zoom out further and it encompasses more nodes, that is another level. For example:
  1816. If the highest level of your network at any given time is 3, nodes that have not clustered or
  1817. have clustered only once will join their neighbour with the lowest cluster level.</td>
  1818. </tr>
  1819. <tr>
  1820. <td>clusterByZoom</td>
  1821. <td>Boolean</td>
  1822. <td>true</td>
  1823. <td>You can toggle the clustering by zoom level using this option.</td>
  1824. </tr>
  1825. </table>
  1826. <h3 id="Navigation_controls">Navigation controls</h3>
  1827. <p>
  1828. Network has a menu with navigation controls, which is disabled by default.
  1829. It can be configured with the following settings. To correctly display the navigation icons, the <b>vis.css</b> file must be included.
  1830. The user is free to alter or overload the CSS classes but without them the navigation icons are not visible.
  1831. </p>
  1832. <pre class="prettyprint">
  1833. // use of navigation controls
  1834. var options = {
  1835. navigation: true
  1836. }
  1837. </pre>
  1838. <h3 id="Keyboard_navigation">Keyboard navigation</h3>
  1839. <p>
  1840. The network can be navigated using shortcut keys.
  1841. The default state for the keyboard navigation is <b>off</b>. The predefined keys can be found in the example <a href="../examples/network/20_navigation.html">20_navigation.html</a>.
  1842. </p>
  1843. <pre class="prettyprint">
  1844. // simple use of keyboard controls
  1845. var options = {
  1846. keyboard: true
  1847. }
  1848. // advanced configuration for keyboard controls
  1849. var options = {
  1850. keyboard: {
  1851. speed: {
  1852. x: 10,
  1853. y: 10,
  1854. zoom: 0.02
  1855. },
  1856. bindToWindow: true
  1857. }
  1858. }
  1859. </pre>
  1860. <table>
  1861. <tr>
  1862. <th>Name</th>
  1863. <th>Type</th>
  1864. <th>Default</th>
  1865. <th>Description</th>
  1866. </tr>
  1867. <tr>
  1868. <td>speed.x</td>
  1869. <td>Number</td>
  1870. <td>10</td>
  1871. <td>This defines the speed of the camera movement in the x direction when using the keyboard navigation.
  1872. </td>
  1873. </tr>
  1874. <tr>
  1875. <td>speed.y</td>
  1876. <td>Number</td>
  1877. <td>10</td>
  1878. <td>This defines the speed of the camera movement in the y direction when using the keyboard navigation.</td>
  1879. </tr>
  1880. <tr>
  1881. <td>speed.zoom</td>
  1882. <td>Number</td>
  1883. <td>0.02</td>
  1884. <td>This defines the zoomspeed when using the keyboard navigation.</td>
  1885. </tr>
  1886. <tr>
  1887. <td>bindToWindow</td>
  1888. <td>Boolean</td>
  1889. <td>true</td>
  1890. <td>If this is true, global keyboard events will be used. If it is false, the keyboard events are only used when the network is active. It is activated on mouseOver automatically.</td>
  1891. </tr>
  1892. </table>
  1893. <h3 id="Hierarchical_layout">Hierarchical layout</h3>
  1894. <p>
  1895. The network can be used to display nodes in a hierarchical way. This can be determined automatically, based on the amount of edges connected to each node, or defined by the user.
  1896. If the user wants to manually determine the hierarchy, each node has to be supplied with a level (from 0 being heighest to n). The automatic method
  1897. is shown in <a href="../examples/network/23_hierarchical_layout.html">example 23</a> and the user-defined method is shown in <a href="../examples/network/24_hierarchical_layout_userdefined.html">example 24</a>.
  1898. This layout method does not support smooth curves or clustering. It automatically turns these features off.
  1899. </p>
  1900. <pre class="prettyprint">
  1901. // simple use of the hierarchical layout
  1902. var options = {
  1903. hierarchicalLayout: true
  1904. }
  1905. // advanced configuration for hierarchical layout
  1906. var options = {
  1907. hierarchicalLayout: {
  1908. enabled:false,
  1909. levelSeparation: 150,
  1910. nodeSpacing: 100,
  1911. direction: "UD",
  1912. layout: "hubsize"
  1913. }
  1914. }
  1915. // partial configuration automatically sets enabled to true
  1916. var options = {
  1917. hierarchicalLayout: {
  1918. nodeSpacing: 100,
  1919. direction: "UD"
  1920. }
  1921. }
  1922. </pre>
  1923. <table>
  1924. <tr>
  1925. <th>Name</th>
  1926. <th>Type</th>
  1927. <th>Default</th>
  1928. <th>Description</th>
  1929. </tr>
  1930. <tr>
  1931. <td>enabled</td>
  1932. <td>Boolean</td>
  1933. <td>false</td>
  1934. <td>Enable or disable the hierarchical layout.
  1935. </td>
  1936. </tr>
  1937. <tr>
  1938. <td>levelSeparation</td>
  1939. <td>Number</td>
  1940. <td>150</td>
  1941. <td>This defines the space between levels (in the Y-direction, considering UP-DOWN direction).</td>
  1942. </tr>
  1943. <tr>
  1944. <td>nodeSpacing</td>
  1945. <td>Number</td>
  1946. <td>100</td>
  1947. <td>This defines the space between nodes in the same level (in the X-direction, considering UP-DOWN direction).
  1948. This is only relevant during the initial placing of nodes.</td>
  1949. </tr>
  1950. <tr>
  1951. <td>direction</td>
  1952. <td>String</td>
  1953. <td>UD</td>
  1954. <td>This defines the direction the network is drawn in. The supported directions are: Up-Down (UD), Down-Up (DU), Left-Right (LR) and Right-Left (RL).
  1955. These need to be supplied by the acronyms in parentheses.</td>
  1956. </tr>
  1957. <tr>
  1958. <td>layout</td>
  1959. <td>String</td>
  1960. <td>hubsize</td>
  1961. <td>This defines the way the nodes are distributed. Available options are <code>hubsize</code> and <code>direction</code>. The default value is hubsize, meaning the node with the most edges connected to it (largest hub) is on top.
  1962. Alternatively, direction arranges the nodes based on the direction of the edges. See <a href="../examples/network/32_hierarchicaLayoutMethods.html">example 32</a> for more information.</td>
  1963. </tr>
  1964. </table>
  1965. <h3 id="Localization">Localization</h3>
  1966. <p>
  1967. When using vis.js in other languages, one can use the localization option to get a localized data manipulation interface.
  1968. </p>
  1969. <table>
  1970. <tr>
  1971. <th>Name</th>
  1972. <th>Type</th>
  1973. <th>Default</th>
  1974. <th>Description</th>
  1975. </tr>
  1976. <tr>
  1977. <td>locale</td>
  1978. <td>String</td>
  1979. <td>none</td>
  1980. <td>Select a locale for the Network.</td>
  1981. </tr>
  1982. <tr>
  1983. <td>locales</td>
  1984. <td>Object</td>
  1985. <td>none</td>
  1986. <td>A map with i18n locales.</td>
  1987. </tr>
  1988. </table>
  1989. <p>
  1990. To set a locale for the Network, specify the option <code>locale</code>:
  1991. </p>
  1992. <pre class="prettyprint lang-js">var options = {
  1993. locale: 'nl'
  1994. };
  1995. </pre>
  1996. <h4>Create a new locale</h4>
  1997. To load a locale into the Timeline not supported by default, one can add a new locale to the option <code>locales</code>:
  1998. <pre class="prettyprint lang-js">var options = {
  1999. locales: {
  2000. // create a new locale (text strings should be replaced with localized strings)
  2001. mylocale: {
  2002. edit: 'Edit',
  2003. del: 'Delete selected',
  2004. back: 'Back',
  2005. addNode: 'Add Node',
  2006. addEdge: 'Add Edge',
  2007. editNode: 'Edit Node',
  2008. editEdge: 'Edit Edge',
  2009. addDescription: 'Click in an empty space to place a new node.',
  2010. edgeDescription: 'Click on a node and drag the edge to another node to connect them.',
  2011. editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
  2012. createEdgeError: 'Cannot link edges to a cluster.',
  2013. deleteClusterError: 'Clusters cannot be deleted.'
  2014. }
  2015. },
  2016. // use the new locale
  2017. locale: 'mylocale'
  2018. };
  2019. </pre>
  2020. <h4 id="available-locales">Available locales</h4>
  2021. <p>
  2022. Network comes with support for the following locales:
  2023. </p>
  2024. <table>
  2025. <tr><th>Language</th><th>Code</th></tr>
  2026. <tr>
  2027. <td>English</td>
  2028. <td>
  2029. <code>en</code><br>
  2030. <code>en_EN</code><br>
  2031. <code>en_US</code>
  2032. </td>
  2033. </tr>
  2034. <tr>
  2035. <td>Dutch</td>
  2036. <td>
  2037. <code>nl</code><br>
  2038. <code>nl_NL</code><br>
  2039. <code>nl_BE</code>
  2040. </td>
  2041. </tr>
  2042. </table>
  2043. <h3 id="Tooltips">Tooltips</h3>
  2044. <p>
  2045. The behaviour and style of the tooltips used to display node and edge title attributes can be customized.
  2046. </p>
  2047. <pre class="prettyprint">
  2048. // tooltip behaviour and style options
  2049. var options = {
  2050. tooltip: {
  2051. delay: 300,
  2052. fontColor: "black",
  2053. fontSize: 14, // px
  2054. fontFace: "verdana",
  2055. color: {
  2056. border: "#666",
  2057. background: "#FFFFC6"
  2058. }
  2059. }
  2060. }
  2061. </pre>
  2062. <table>
  2063. <tr>
  2064. <th>Name</th>
  2065. <th>Type</th>
  2066. <th>Default</th>
  2067. <th>Description</th>
  2068. </tr>
  2069. <tr>
  2070. <td>delay</td>
  2071. <td>Number</td>
  2072. <td>300</td>
  2073. <td>Time in milliseconds a user must hover over a node or edge before a tooltip appears.</td>
  2074. </tr>
  2075. <tr>
  2076. <td>fontColor</td>
  2077. <td>String</td>
  2078. <td>"black"</td>
  2079. <td>Default color for tooltip text.</td>
  2080. </tr>
  2081. <tr>
  2082. <td>fontSize</td>
  2083. <td>Number</td>
  2084. <td>14</td>
  2085. <td>Size in pixels of tooltip text.</td>
  2086. </tr>
  2087. <tr>
  2088. <td>fontFace</td>
  2089. <td>String</td>
  2090. <td>"verdana"</td>
  2091. <td>Font family to used for tooltip text.</td>
  2092. </tr>
  2093. <tr>
  2094. <td>color.background</td>
  2095. <td>String</td>
  2096. <td>"#FFFFC6"</td>
  2097. <td>Background color for the node.</td>
  2098. </tr>
  2099. <tr>
  2100. <td>color.border</td>
  2101. <td>String</td>
  2102. <td>"#666"</td>
  2103. <td>Border color for the node.</td>
  2104. </tr>
  2105. </table>
  2106. <h2 id="Methods">Methods</h2>
  2107. <p>
  2108. Network supports the following methods.
  2109. </p>
  2110. <table>
  2111. <tr>
  2112. <th>Method</th>
  2113. <th>Return Type</th>
  2114. <th>Description</th>
  2115. </tr>
  2116. <tr>
  2117. <td>getScale()</td>
  2118. <td>Number</td>
  2119. <td>Returns the scale of the network. This can be for animation. This scale is like a percentage, 1.0 = 100%.
  2120. Zooming in is > 1.0, zooming out is < 0. Scale cannot be smaller or equal to 0.
  2121. </td>
  2122. </tr>
  2123. <tr>
  2124. <td>getCenterCoordinates()</td>
  2125. <td>Number</td>
  2126. <td>Returns the x and y coodinates of the center of the screen (in canvas space).
  2127. </td>
  2128. </tr>
  2129. <tr>
  2130. <td>getBoundingBox(nodeId)</td>
  2131. <td>Object</td>
  2132. <td>Returns a bounding box for the node including label in the format: {top:Number,left:Number,right:Number,bottom:Number}. These values are in canvas space.
  2133. </td>
  2134. </tr>
  2135. <tr>
  2136. <td>getConnectedNodes(nodeId)</td>
  2137. <td>Array</td>
  2138. <td>Returns an array with nodeIds of nodes that are connected to this node. Network keeps track of the connected nodes so this function allows you
  2139. to quickly get them without iterating over all edges manually. This is a lot faster for cases with many edges.
  2140. </td>
  2141. </tr>
  2142. <tr>
  2143. <td>getSelection()</td>
  2144. <td>Array of ids</td>
  2145. <td>Returns an array with the ids of the selected nodes.
  2146. Returns an empty array if no nodes are selected.
  2147. The selections are not ordered.
  2148. </td>
  2149. </tr>
  2150. <tr>
  2151. <td>focusOnNode(nodeId, [options])</td>
  2152. <td>none</td>
  2153. <td>This function will move the view to center on the specified node. An optional options object can submitted where you can define the animation properties. <br />
  2154. The options that can be defined are:<br />
  2155. <b><code>scale:Number</code></b><br /> - to zoom to that scale,<br />
  2156. <b><code>offset:{x:Number, y:Number}</code></b><br /> - to offset the position from the center of the canvas (in pixels),<br />
  2157. <b><code>locked: boolean</code></b><br /> - if true, the view remains locked on this node until either another focusOnNode, moveTo, releaseNode or drag is done <br />
  2158. <b><code>animation: Object || Boolean</code></b><br /> - to define the specifics of the animation. True is animated with default settings, false is not animated.<br />
  2159. <br />
  2160. The animation object can consist of:<br />
  2161. <b><code>duration: Number</code></b><br /> - the duration of the animation in milliseconds,<br />
  2162. <b><code>easingFunction: String</code></b><br /> - the easing function of the animation, available are:<br />
  2163. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  2164. easeInQuart, easeOutQuart, easeInOutQuart,
  2165. easeInQuint, easeOutQuint, easeInOutQuint </code> <br /><br />
  2166. </td>
  2167. </tr>
  2168. <tr>
  2169. <td>freezeSimulation(Boolean)</td>
  2170. <td>none</td>
  2171. <td>Calling freezeSimulation(true) immmediately stops the simulation and triggerst the stabilized event. This does not mean that the network
  2172. is physically stabilized but the nodes are not moving anymore. To continue the simulation call freezeSimulation(false).
  2173. </td>
  2174. </tr>
  2175. <tr>
  2176. <td>releaseNode()</td>
  2177. <td>none</td>
  2178. <td>When locked on to a node, this function releases it again. If the view is not locked onto a node due to the focusOnNode locked option, nothing happens.
  2179. </td>
  2180. </tr>
  2181. <tr>
  2182. <td>DOMtoCanvas(pos)</td>
  2183. <td>object</td>
  2184. <td>This function converts DOM coordinates to coordinates on the canvas. Input and output are in the form of {x:xpos,y:ypos}. The DOM values are relative to the network container.
  2185. </td>
  2186. </tr>
  2187. <tr>
  2188. <td>canvasToDOM(pos)</td>
  2189. <td>object</td>
  2190. <td>This function converts canvas coordinates to coordinates on the DOM. Input and output are in the form of {x:xpos,y:ypos}. The DOM values are relative to the network container.
  2191. </td>
  2192. </tr>
  2193. <tr>
  2194. <td>moveTo(options)</td>
  2195. <td>object</td>
  2196. <td>This function allows you to programmatically move the view. The options that can be defined are:<br />
  2197. <b><code>position:{x:Number, y:Number}</code></b><br /> - to move to that position (in canvas units), <br />
  2198. <b><code>scale:Number</code></b><br /> - to zoom to that scale,<br />
  2199. <b><code>offset:{x:Number, y:Number}</code></b><br /> - to offset the position from the center of the canvas (in DOM units),<br />
  2200. <b><code>animation: Object || Boolean</code></b><br /> - to define the specifics of the animation.<br />
  2201. <br />
  2202. The animation object can consist of:<br />
  2203. <b><code>duration: Number</code></b><br /> - the duration of the animation in milliseconds,<br />
  2204. <b><code>easingFunction: String</code></b><br /> - the easing function of the animation, available are:<br />
  2205. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  2206. easeInQuart, easeOutQuart, easeInOutQuart,
  2207. easeInQuint, easeOutQuint, easeInOutQuint </code> <br /><br />
  2208. <i>You will have to define at least a scale or a position. Otherwise, there is nothing to move to.</i>
  2209. </td>
  2210. </tr>
  2211. <tr>
  2212. <td>on(event, callback)</td>
  2213. <td>none</td>
  2214. <td>Create an event listener. The callback function is invoked every time the event is triggered. Avialable events: <code>select</code>. The callback function is invoked as <code>callback(properties)</code>, where <code>properties</code> is an object containing event specific properties. See section <a href="#Events">Events</a> for more information.</td>
  2215. </tr>
  2216. <tr>
  2217. <td>off(event, callback)</td>
  2218. <td>none</td>
  2219. <td>Remove an event listener created before via function <code>on(event, callback)</code>. See section <a href="#Events">Events</a> for more information.</td>
  2220. </tr>
  2221. <tr>
  2222. <td>destroy()</td>
  2223. <td>none</td>
  2224. <td>Remove all bindings and clean up after the Network.</td>
  2225. </tr>
  2226. <tr>
  2227. <td>redraw()</td>
  2228. <td>none</td>
  2229. <td>Redraw the network. Useful when the layout of the webpage changed.</td>
  2230. </tr>
  2231. <tr>
  2232. <td>setData(data,[disableStart])</td>
  2233. <td>none</td>
  2234. <td>Loads data. Parameter <code>data</code> is an object containing
  2235. nodes, edges, and options. Parameters nodes, edges are an Array.
  2236. Options is a name-value map and is optional. Parameter <code>disableStart</code> is
  2237. an optional Boolean and can disable the start of the simulation that would begin at the end
  2238. of this function by default.
  2239. </td>
  2240. </tr>
  2241. <tr>
  2242. <td>setOptions(options)</td>
  2243. <td>none</td>
  2244. <td>Set options for the network. The available options are described in
  2245. the section <a href="#Configuration_options">Configuration Options</a>.
  2246. </td>
  2247. </tr>
  2248. <tr>
  2249. <td>selectNodes(selection, [highlightEdges])</td>
  2250. <td>none</td>
  2251. <td>Select nodes.
  2252. <code>selection</code> is an array with ids of nodes to be selected.
  2253. The array <code>selection</code> can contain zero or multiple ids.
  2254. Example usage: <code>network.selectNodes([3, 5]);</code> will select
  2255. nodes with id 3 and 5. The highlisghEdges boolean can be used to automatically select the edges connected to the node.
  2256. </td>
  2257. </tr>
  2258. <tr>
  2259. <td>getConnectedNodes(nodeId)</td>
  2260. <td>Array</td>
  2261. <td>Get an array of (unique) nodeIds that are directly connected to this node.
  2262. </td>
  2263. </tr>
  2264. <tr>
  2265. <td>selectEdges(selection)</td>
  2266. <td>none</td>
  2267. <td>Select Edges.
  2268. <code>selection</code> is an array with ids of edges to be selected.
  2269. The array <code>selection</code> can contain zero or multiple ids.
  2270. Example usage: <code>network.selectEdges([3, 5]);</code> will select
  2271. edges with id 3 and 5.
  2272. </td>
  2273. </tr>
  2274. <tr>
  2275. <td>setSize(width, height)</td>
  2276. <td>none</td>
  2277. <td>Parameters <code>width</code> and <code>height</code> are strings,
  2278. containing a new size for the visualization. Size can be provided in pixels
  2279. or in percentages.</td>
  2280. </tr>
  2281. <tr>
  2282. <td>getPositions([nodeIds])</td>
  2283. <td>Object</td>
  2284. <td>This will return an object of all nodes' positions. Data can be accessed with object[nodeId].x and .y. You can optionally supply an id as string or number or an array of ids. If no id or array of ids have been supplied, all positions are returned.
  2285. </td>
  2286. </tr>
  2287. <tr>
  2288. <td>storePositions()</td>
  2289. <td>none</td>
  2290. <td>When using the vis.DataSet to load your nodes into the network, this method will put the X and Y positions of all nodes into that dataset. It will also include allowedToMoveX and allowedToMoveY with the correct values.
  2291. If you're loading your nodes from a database and have this dynamically coupled with the DataSet, you can use this
  2292. to stablize your network once, then save the positions in that database through the DataSet so the next time you load the nodes, stabilization will be near instantaneous.
  2293. If the nodes are still moving and you're using dynamic smooth edges (which is on by default), you can use the option freezeForStabilization to improve initialization time.
  2294. <br><br><i><code>NOTE:</code>This method does not work with the hierarchical layout because the hierarchical algorithm is assigning X Y positions on load, regardless of the ones you supply it with.</i>
  2295. </td>
  2296. </tr>
  2297. <tr>
  2298. <td>zoomExtent([options])</td>
  2299. <td>none</td>
  2300. <td>Scales the network so all the nodes are in center view. Optionally you can supply options for animation. These
  2301. options can just be a boolean. When true, the zoom is animated, when false there is no animation.
  2302. Alternatively, you can supply an object.
  2303. <br /><br /> The object can consist of:<br />
  2304. <b><code>nodes: [nodeIds]</code></b><br /> - an optional subset of nodes to zoom in on,<br />
  2305. <b><code>duration: Number</code></b><br /> - the duration of the animation in milliseconds,<br />
  2306. <b><code>easingFunction: String</code></b><br /> - the easing function of the animation, available are:<br />
  2307. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  2308. easeInQuart, easeOutQuart, easeInOutQuart,
  2309. easeInQuint, easeOutQuint, easeInOutQuint </code>
  2310. </td>
  2311. </tr>
  2312. </table>
  2313. <h2 id="Events">Events</h2>
  2314. <p>
  2315. Network fires events after one or multiple nodes are selected or deselected.
  2316. The event can be catched by creating a listener.
  2317. </p>
  2318. <p>
  2319. Here an example on how to catch a <code>select</code> event.
  2320. </p>
  2321. <pre class="prettyprint lang-js">
  2322. network.on('select', function (properties) {
  2323. alert('selected nodes: ' + properties.nodes);
  2324. });
  2325. </pre>
  2326. <p>
  2327. A listener can be removed via the function <code>off</code>:
  2328. </p>
  2329. <pre class="prettyprint lang-js">
  2330. function onSelect (properties) {
  2331. alert('selected nodes: ' + properties.nodes);
  2332. }
  2333. // add event listener
  2334. network.on('select', onSelect);
  2335. // do stuff...
  2336. // remove event listener
  2337. network.off('select', onSelect);
  2338. </pre>
  2339. <p>
  2340. The following events are available.
  2341. </p>
  2342. <table>
  2343. <tr>
  2344. <th>name</th>
  2345. <th>Description</th>
  2346. <th>Properties</th>
  2347. </tr>
  2348. <tr>
  2349. <td>animationFinished</td>
  2350. <td>Fired after an animation is finished.
  2351. </td>
  2352. <td>
  2353. none
  2354. </td>
  2355. </tr>
  2356. <tr>
  2357. <td>select</td>
  2358. <td>Fired after the user selects or deselects a node by clicking it.
  2359. Not fired when the method <code>setSelection</code>is executed.
  2360. </td>
  2361. <td>
  2362. <ul>
  2363. <li><code>nodes</code>: an array with the ids of the selected nodes</li>
  2364. <li><code>edges</code>: an array with the ids of the selected edges</li>
  2365. </ul>
  2366. </td>
  2367. </tr>
  2368. <tr>
  2369. <td>click</td>
  2370. <td>Fired after the user clicks or taps on a touchscreen.</td>
  2371. <td>
  2372. <ul>
  2373. <li><code>nodes</code>: an array with the ids of the selected nodes</li>
  2374. <li><code>edges</code>: an array with the ids of the selected edges</li>
  2375. <li><code>pointer.DOM</code>:object containing XY coordinates in the DOM</li>
  2376. <li><code>pointer.canvas</code>:object containing XY coordinates in the canvas</li>
  2377. </ul>
  2378. </td>
  2379. </tr>
  2380. <tr>
  2381. <td>doubleClick</td>
  2382. <td>Fired after the user double clicks or double taps on a touchscreen.</td>
  2383. <td>
  2384. <ul>
  2385. <li><code>nodes</code>: an array with the ids of the selected nodes</li>
  2386. <li><code>edges</code>: an array with the ids of the selected edges</li>
  2387. <li><code>pointer.DOM</code>:object containing XY coordinates in the DOM</li>
  2388. <li><code>pointer.canvas</code>:object containing XY coordinates in the canvas</li>
  2389. </ul>
  2390. </td>
  2391. </tr>
  2392. <tr>
  2393. <tr>
  2394. <td>hoverNode</td>
  2395. <td>Fired when the mouse is moved over a node (assuming the hover option is enabled).</td>
  2396. <td>
  2397. <ul>
  2398. <li><code>node</code>: an object with the id of the hovered node.</li>
  2399. </ul>
  2400. </td>
  2401. </tr>
  2402. <tr>
  2403. <tr>
  2404. <td>blurNode</td>
  2405. <td>Fired when the mouse is moved off a node (assuming the hover option is enabled).</td>
  2406. <td>
  2407. <ul>
  2408. <li><code>node</code>: an object with the id of the hovered node.</li>
  2409. </ul>
  2410. </td>
  2411. </tr>
  2412. <tr>
  2413. <td>resize</td>
  2414. <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.</td>
  2415. <td>
  2416. <ul>
  2417. <li><code>width</code>: the new width of the canvas</li>
  2418. <li><code>height</code>: the new height of the canvas</li>
  2419. <li><code>oldWidth</code>: the old width of the canvas</li>
  2420. <li><code>oldHeight</code>: the old height of the canvas</li>
  2421. </ul>
  2422. </td>
  2423. </tr>
  2424. <tr>
  2425. <td>dragStart</td>
  2426. <td>Fired when a node is being dragged.</td>
  2427. <td>
  2428. <ul>
  2429. <li><code>nodeIds</code>: Array of ids of the nodes that are being dragged</li>
  2430. </ul>
  2431. </td>
  2432. </tr>
  2433. <tr>
  2434. <td>dragEnd</td>
  2435. <td>Fired when the dragging of a node(s) has ended.</td>
  2436. <td>
  2437. <ul>
  2438. <li><code>nodeIds</code>: Array of ids of the nodes that were being dragged</li>
  2439. </ul>
  2440. </td>
  2441. </tr>
  2442. <tr>
  2443. <td>startStabilization</td>
  2444. <td>Fired once when the network starts the physics calculation. This ends with the stabilized event.
  2445. <td>
  2446. none
  2447. </td>
  2448. </tr>
  2449. <tr>
  2450. <td>stabilized</td>
  2451. <td>Fired every time the network has been stabilized. This event can be used to trigger the .storePositions() function after stabilization. Fired with an object having the following properties:</td>
  2452. <td>
  2453. <ul>
  2454. <li><code>iterations</code>: number of iterations used to stabilize</li>
  2455. </ul>
  2456. </td>
  2457. </tr>
  2458. <tr>
  2459. <td>viewChanged</td>
  2460. <td>Fired when the view has changed. This is when the network has moved or zoomed.</td>
  2461. <td>
  2462. none
  2463. </td>
  2464. </tr>
  2465. <tr>
  2466. <td>zoom</td>
  2467. <td>Fired when the network has zoomed. This event can be used to trigger the .storePositions() function after stabilization.</td>
  2468. <td>
  2469. <ul>
  2470. <li><code>direction: </code> "+" or "-" </li>
  2471. </ul>
  2472. </td>
  2473. </tr>
  2474. </table>
  2475. <h2 id="Data_policy">Data policy</h2>
  2476. <p>
  2477. All code and data is processed and rendered in the browser.
  2478. No data is sent to any server.
  2479. </p>
  2480. </div>
  2481. </body>
  2482. </html>