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.

2702 lines
90 KiB

9 years ago
9 years ago
9 years ago
10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 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. This does not do anything in hierarchical views.</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. This does not do anything in hierarchical views.</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>useDefaultGroups</td>
  521. <td>boolean</td>
  522. <td>true</td>
  523. <td>If true, the default groups are used when groups are used. If you have defined your own groups those will be used. If you have an item with a group that is NOT in your own group list,
  524. setting useDefaultGroups true will iterate over the default groups for unknown groups. If it is set to false, it will iterate over your own groups for unknown groups.
  525. </td>
  526. </tr>
  527. <tr>
  528. <td><a href="#Physics">physics</a></td>
  529. <td>Object</td>
  530. <td>none</td>
  531. <td>
  532. Configuration of the physics system governing the simulation of the nodes and edges.
  533. Barnes-Hut nBody simulation is used by default. See section <a href="#Physics">Physics</a> for an overview of the available options.
  534. </td>
  535. </tr>
  536. <tr>
  537. <td><a href="#Physics">configurePhysics</a></td>
  538. <td>Boolean</td>
  539. <td>false</td>
  540. <td>
  541. 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.
  542. 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.
  543. </td>
  544. </tr>
  545. <tr>
  546. <td><a href="#Data_manipulation">dataManipulation</a></td>
  547. <td>Object</td>
  548. <td>none</td>
  549. <td>
  550. Settings for manipulating the Dataset. See section <a href="#Data_manipulation">Data manipulation</a> for an overview of the available options.
  551. </td>
  552. </tr>
  553. <tr>
  554. <td><a href="#Clustering">clustering</a></td>
  555. <td>Object</td>
  556. <td>none</td>
  557. <td>
  558. Clustering configuration. Clustering is turned off by default. See section <a href="#Clustering">Clustering</a> for an overview of the available options.
  559. </td>
  560. </tr>
  561. <tr>
  562. <td><a href="#Edges_configuration">edges</a></td>
  563. <td>Object</td>
  564. <td>none</td>
  565. <td>
  566. Configuration options applied to all edges. See section <a href="#Edges_configuration">Edges configuration</a> for an overview of the available options.
  567. </td>
  568. </tr>
  569. <tr>
  570. <td>freezeForStabilization</td>
  571. <td>Boolean</td>
  572. <td>false</td>
  573. <td>
  574. 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
  575. 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
  576. 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.
  577. </td>
  578. </tr>
  579. <tr>
  580. <td><a href="#Groups_configuration">groups</a></td>
  581. <td>Object</td>
  582. <td>none</td>
  583. <td>It is possible to specify custom styles for groups.
  584. Each node assigned a group gets the specified style.
  585. See <a href="#Groups_configuration">Groups configuration</a> for an overview of the available styles
  586. and an example.
  587. </td>
  588. </tr>
  589. <tr>
  590. <td>height</td>
  591. <td>String</td>
  592. <td>"400px"</td>
  593. <td>The height of the network in pixels or as a percentage.</td>
  594. </tr>
  595. <tr>
  596. <td>hover</td>
  597. <td>Boolean</td>
  598. <td>false</td>
  599. <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>
  600. </tr>
  601. <tr>
  602. <td><a href="#Keyboard_navigation">keyboard</a></td>
  603. <td>Object</td>
  604. <td>none</td>
  605. <td>
  606. 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.
  607. </td>
  608. </tr>
  609. <tr>
  610. <td>dragNetwork</td>
  611. <td>Boolean</td>
  612. <td>true</td>
  613. <td>
  614. Toggle if the network can be dragged. This will not affect the dragging of nodes.
  615. </td>
  616. </tr>
  617. <tr>
  618. <td>dragNodes</td>
  619. <td>Boolean</td>
  620. <td>true</td>
  621. <td>
  622. Toggle if the nodes can be dragged. This will not affect the dragging of the network.
  623. </td>
  624. </tr>
  625. <tr>
  626. <td>hideNodesOnDrag</td>
  627. <td>Boolean</td>
  628. <td>false</td>
  629. <td>
  630. Toggle if the nodes are drawn during a drag. This can greatly improve performance if you have many nodes.
  631. </td>
  632. </tr>
  633. <tr>
  634. <td>hideEdgesOnDrag</td>
  635. <td>Boolean</td>
  636. <td>false</td>
  637. <td>
  638. Toggle if the edges are drawn during a drag. This can greatly improve performance if you have many edges.
  639. </td>
  640. </tr>
  641. <tr>
  642. <td><a href="#Navigation_controls">navigation</a></td>
  643. <td>Object</td>
  644. <td>none</td>
  645. <td>
  646. Configuration options for the navigation controls. See section <a href="#Navigation_controls">Navigation controls</a> for an overview of the available options.
  647. </td>
  648. </tr>
  649. <tr>
  650. <td><a href="#Nodes_configuration">nodes</a></td>
  651. <td>Object</td>
  652. <td>none</td>
  653. <td>
  654. Configuration options applied to all nodes. See section <a href="#Nodes_configuration">Nodes configuration</a> for an overview of the available options.
  655. </td>
  656. </tr>
  657. <tr>
  658. <td>smoothCurves</td>
  659. <td>Boolean || object</td>
  660. <td>object</td>
  661. <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>
  662. </tr>
  663. <tr>
  664. <td>smoothCurves.dynamic</td>
  665. <td>Boolean</td>
  666. <td>true</td>
  667. <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
  668. relative positions of the to and from nodes. This is computationally cheaper but there is no self organisation.</td>
  669. </tr>
  670. <tr>
  671. <td>smoothCurves.type</td>
  672. <td>String</td>
  673. <td>"continuous"</td>
  674. <td>This option only affects NONdynamic smooth curves. The supported types are: <code>continuous, discrete, diagonalCross, straightCross, horizontal, vertical, curvedCW, curvedCCW</code>. The effects of these types
  675. 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>
  676. </tr>
  677. <tr>
  678. <td>smoothCurves.roundness</td>
  679. <td>Number</td>
  680. <td>0.5</td>
  681. <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>
  682. </tr>
  683. <tr>
  684. <td>selectable</td>
  685. <td>Boolean</td>
  686. <td>true</td>
  687. <td>If true, nodes in the network can be selected by clicking them.
  688. Long press can be used to select multiple nodes.</td>
  689. </tr>
  690. <tr>
  691. <td>stabilize</td>
  692. <td>Boolean</td>
  693. <td>true</td>
  694. <td>If true, the network is stabilized before displaying it. If false,
  695. the nodes move to a stabe position visibly in an animated way.</td>
  696. </tr>
  697. <tr>
  698. <td>stabilizationIterations</td>
  699. <td>Number</td>
  700. <td>1000</td>
  701. <td>If stabilize is set to true, this number is the (maximum) amount of physics steps the stabilization process takes
  702. 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>
  703. </tr>
  704. <tr>
  705. <td>zoomExtentOnStabilize</td>
  706. <td>Boolean</td>
  707. <td>true</td>
  708. <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>
  709. </tr>
  710. <tr>
  711. <td>width</td>
  712. <td>String</td>
  713. <td>"400px"</td>
  714. <td>The width of the network in pixels or as a percentage.</td>
  715. </tr>
  716. <tr>
  717. <td>zoomable</td>
  718. <td>Boolean</td>
  719. <td>true</td>
  720. <td>
  721. Toggle if the network can be zoomed.
  722. </td>
  723. </tr>
  724. </table>
  725. <br>
  726. <h3 id="Nodes_configuration">Nodes configuration</h3>
  727. <p>
  728. 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.
  729. </p>
  730. <p>
  731. For example to give the nodes a custom color, shape, and size:
  732. </p>
  733. <pre class="prettyprint lang-js">
  734. var options = {
  735. // ...
  736. nodes: {
  737. color: {
  738. background: 'white',
  739. border: 'red',
  740. highlight: {
  741. background: 'pink',
  742. border: 'red'
  743. }
  744. },
  745. shape: 'star',
  746. radius: 24
  747. }
  748. };
  749. </pre>
  750. <p>
  751. The following options are available for nodes. These options must be created
  752. inside an object <code>nodes</code> in the networks options object.</p> All options in green boxes can be defined per-node as well.
  753. All options defined per-node override these global settings.
  754. <table>
  755. <tr>
  756. <th>Name</th>
  757. <th>Type</th>
  758. <th>Default</th>
  759. <th>Description</th>
  760. </tr>
  761. <tr>
  762. <td class="greenField">borderWidth</td>
  763. <td>Number</td>
  764. <td>1</td>
  765. <td>The width of the border of the node when it is not selected, automatically limited by the width of the node.</td>
  766. </tr>
  767. <tr>
  768. <td class="greenField">borderWidthSelected</td>
  769. <td>Number</td>
  770. <td>undefined</td>
  771. <td>The width of the border of the node when it is selected. If left at undefined, double the borderWidth will be used.</td>
  772. </tr>
  773. <tr>
  774. <td>customScalingFunction</td>
  775. <td>Function</td>
  776. <td>Function</td>
  777. <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>
  778. <pre class="prettyprint lang-js">
  779. function (min,max,total,value) {
  780. if (max == min) {
  781. return 0.5;
  782. }
  783. else {
  784. var scale = 1 / (max - min);
  785. return Math.max(0,(value - min)*scale);
  786. }
  787. };
  788. </pre>
  789. 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.
  790. The nodes and edges then calculate their size as follows:
  791. <pre class="prettyprint lang-js">
  792. var scale = customScalingFunction(min,max,total,value);
  793. var diff = maxSize - minSize;
  794. mySize = minSize + diff * scale;</pre>
  795. </td>
  796. </tr>
  797. <tr>
  798. <td class="greenField">color</td>
  799. <td>String | Object</td>
  800. <td>Object</td>
  801. <td>Color for the node.</td>
  802. </tr>
  803. <tr>
  804. <td class="greenField">color.background</td>
  805. <td>String</td>
  806. <td>#97C2FC</td>
  807. <td>Background color for the node.</td>
  808. </tr>
  809. <tr>
  810. <td class="greenField">color.border</td>
  811. <td>String</td>
  812. <td>#2B7CE9</td>
  813. <td>Border color for the node.</td>
  814. </tr>
  815. <tr>
  816. <td class="greenField">color.highlight</td>
  817. <td>String | Object</td>
  818. <td>Object</td>
  819. <td>Color of the node when selected.</td>
  820. </tr>
  821. <tr>
  822. <td class="greenField">color.highlight.background</td>
  823. <td>String</td>
  824. <td>#D2E5FF</td>
  825. <td>Background color of the node when selected.</td>
  826. </tr>
  827. <tr>
  828. <td class="greenField">color.highlight.border</td>
  829. <td>String</td>
  830. <td>#2B7CE9</td>
  831. <td>Border color of the node when selected.</td>
  832. </tr>
  833. <tr>
  834. <td class="greenField">color.hover.background</td>
  835. <td>String</td>
  836. <td>#D2E5FF</td>
  837. <td>Background color of the node when the node is hovered over and the hover option is enabled.</td>
  838. </tr>
  839. <tr>
  840. <td class="greenField">color.hover.border</td>
  841. <td>String</td>
  842. <td>#2B7CE9</td>
  843. <td>Border color of the node when the node is hovered over and the hover option is enabled.</td>
  844. </tr>
  845. <tr>
  846. <td class="greenField">fontColor</td>
  847. <td>String</td>
  848. <td>black</td>
  849. <td>Font color for label in the node.</td>
  850. </tr>
  851. <tr>
  852. <td class="greenField">fontFace</td>
  853. <td>String</td>
  854. <td>verdana</td>
  855. <td>Font face for label in the node, for example "verdana" or "arial".</td>
  856. </tr>
  857. <tr>
  858. <td class="greenField">fontSize</td>
  859. <td>Number</td>
  860. <td>14</td>
  861. <td>Font size in pixels for label in the node.</td>
  862. </tr>
  863. <tr>
  864. <td>scaleFontWithValue</td>
  865. <td>Boolean</td>
  866. <td>false</td>
  867. <td>When using values, you can let the font scale with the size of the nodes if you enable the this option.</td>
  868. </tr>
  869. <tr>
  870. <td>fontSizeMin</td>
  871. <td>Number</td>
  872. <td>14</td>
  873. <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>
  874. </tr>
  875. <tr>
  876. <td>fontSizeMax</td>
  877. <td>Number</td>
  878. <td>30</td>
  879. <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>
  880. </tr>
  881. <tr>
  882. <td>fontSizeMaxVisible</td>
  883. <td>Number</td>
  884. <td>30</td>
  885. <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,
  886. 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>
  887. </tr>
  888. <tr>
  889. <td>fontDrawThreshold</td>
  890. <td>Number</td>
  891. <td>3</td>
  892. <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).
  893. You can combine this with the min and max values to have the labels of influential nodes show earlier when zooming in.</td>
  894. </tr>
  895. <tr>
  896. <td class="greenField">fontFill</td>
  897. <td>String</td>
  898. <td>undefined</td>
  899. <td>If a color is supplied, there will be a background color behind the label. If left undefined, no background color is shown.</td>
  900. </tr>
  901. <tr>
  902. <td class="greenField">fontStrokeWidth</td>
  903. <td>Number</td>
  904. <td>0</td>
  905. <td>The width of the label stroke (border around label's text) in pixels.</td>
  906. </tr>
  907. <tr>
  908. <td class="greenField">fontStrokeColor</td>
  909. <td>String</td>
  910. <td>'white'</td>
  911. <td>The color of the label stroke.</td>
  912. </tr>
  913. <tr>
  914. <td class="greenField">shape</td>
  915. <td>string</td>
  916. <td>'ellipse'</td>
  917. <td>Define the shape for the node.
  918. Choose from
  919. <code>ellipse</code> (default), <code>circle</code>, <code>box</code>,
  920. <code>database</code>, <code>image</code>, <code>circularImage</code>, <code>label</code>, <code>dot</code>,
  921. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and <code>icon</code>.
  922. <br><br>
  923. In case of <code>image</code> and <code>circularImage</code>, a property with name <code>image</code> must
  924. be provided, containing image urls.
  925. <br><br>
  926. The shapes <code>dot</code>, <code>star</code>, <code>triangle</code>,
  927. <code>triangleDown</code>, and <code>square</code>, are scalable.
  928. The size is determined by the properties <code>radius</code> or
  929. <code>value</code>.
  930. <br><br>
  931. When a property <code>label</code> is provided,
  932. this label will be displayed inside the shape in case of shapes
  933. <code>box</code>, <code>circle</code>, <code>ellipse</code>,
  934. and <code>database</code>.
  935. For all other shapes, the label will be displayed right below the shape.
  936. This shape can be overridden by a group shape, or by a shape of an individual node.
  937. </td>
  938. </tr>
  939. <tr>
  940. <td class="greenField">image</td>
  941. <td>String</td>
  942. <td>undefined</td>
  943. <td>Default image url for the nodes. only applicable to shape <code>image</code>.</td>
  944. </tr>
  945. <tr>
  946. <td class="greenField">brokenImage</td>
  947. <td>String</td>
  948. <td>undefined</td>
  949. <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>
  950. </tr>
  951. <tr>
  952. <td class="greenField">mass</td>
  953. <td>number</td>
  954. <td>1</td>
  955. <td>When using the Barnes Hut simulation method (which is selected by default),
  956. 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
  957. alter the simulation.</td>
  958. </tr>
  959. <tr>
  960. <td>widthMin</td>
  961. <td>Number</td>
  962. <td>16</td>
  963. <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>
  964. </tr>
  965. <tr>
  966. <td>widthMax</td>
  967. <td>Number</td>
  968. <td>64</td>
  969. <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>
  970. </tr>
  971. <tr>
  972. <td class="greenField">radius</td>
  973. <td>Number</td>
  974. <td>10</td>
  975. <td>The default radius for a node. Only applicable to shapes <code>dot</code>,
  976. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.</td>
  977. </tr>
  978. <tr>
  979. <td>radiusMin</td>
  980. <td>Number</td>
  981. <td>10</td>
  982. <td>The minimum radius for a scaled node. Only applicable to shapes <code>dot</code>,
  983. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>. This only does something if you supply a value.</td>
  984. </tr>
  985. <tr>
  986. <td>radiusMax</td>
  987. <td>Number</td>
  988. <td>30</td>
  989. <td>The maximum radius for a scaled node. Only applicable to shapes <code>dot</code>,
  990. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>. This only does something if you supply a value.</td>
  991. </tr>
  992. <tr>
  993. <td class="greenField">iconFontFace</td>
  994. <td>String</td>
  995. <td>undefined</td>
  996. <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>
  997. </tr>
  998. <tr>
  999. <td class="greenField">icon</td>
  1000. <td>String</td>
  1001. <td>undefined</td>
  1002. <td>Unicode of the icon f.e. <code>\uf0c0</code> (user-icon in FontAwesome)</td>
  1003. </tr>
  1004. <tr>
  1005. <td class="greenField">iconSize</td>
  1006. <td>Number</td>
  1007. <td>50</td>
  1008. <td>Size of the icon</td>
  1009. </tr>
  1010. <tr>
  1011. <td class="greenField">color</td>
  1012. <td>String</td>
  1013. <td>black</td>
  1014. <td>Color of the icon</td>
  1015. </tr>
  1016. </table>
  1017. <h3 id="Edges_configuration">Edges configuration</h3>
  1018. <p>
  1019. 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.
  1020. 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.
  1021. To change the edge length of individual edges, you can use the <code>length</code> property in the <a href="#Edges">edge definition</a>.
  1022. </p>
  1023. <p>
  1024. For example to set the width of all edges to 2 pixels and give them a red color:
  1025. </p>
  1026. <pre class="prettyprint lang-js">
  1027. var options = {
  1028. // ...
  1029. edges: {
  1030. color: 'red',
  1031. width: 2
  1032. }
  1033. };
  1034. </pre>
  1035. <p>
  1036. The following options are available for edges. These options must be created
  1037. inside an object <code>edges</code> in the networks options object. All options in green boxes can be defined per-edge as well.
  1038. All options defined per-edge override these global settings.
  1039. </p>
  1040. <table>
  1041. <tr>
  1042. <th>Name</th>
  1043. <th>Type</th>
  1044. <th>Default</th>
  1045. <th>Description</th>
  1046. </tr>
  1047. <tr>
  1048. <td class="greenField">arrowScaleFactor</td>
  1049. <td>Number</td>
  1050. <td>1</td>
  1051. <td>If you are using arrows, this will scale the arrow. Values < 1 give smaller arrows, > 1 larger arrows. Default: 1.</td>
  1052. </tr>
  1053. <tr>
  1054. <td class="greenField">color</td>
  1055. <td>String | Object</td>
  1056. <td>Object</td>
  1057. <td>Color for the edge.</td>
  1058. </tr>
  1059. <tr>
  1060. <td class="greenField">color.color</td>
  1061. <td>String</td>
  1062. <td>#848484</td>
  1063. <td>Color of the edge when not selected.</td>
  1064. </tr>
  1065. <tr>
  1066. <td class="greenField">color.highlight</td>
  1067. <td>String</td>
  1068. <td>#848484</td>
  1069. <td>Color of the edge when selected.</td>
  1070. </tr>
  1071. <tr>
  1072. <td class="greenField">color.hover</td>
  1073. <td>String</td>
  1074. <td>#848484</td>
  1075. <td>Color of the edge when the edge is hovered over and the hover option is enabled.</td>
  1076. </tr>
  1077. <tr>
  1078. <td class="greenField">hoverWidth</td>
  1079. <td>Number</td>
  1080. <td>1.5</td>
  1081. <td>This determines the thickness of the edge if it is hovered over. This will only manifest when the hover option is enabled.</td>
  1082. </tr>
  1083. <tr>
  1084. <td class="greenField">dash</td>
  1085. <td>Object</td>
  1086. <td>Object</td>
  1087. <td>
  1088. Object containing properties for dashed lines.
  1089. Available properties: <code>length</code>, <code>gap</code>,
  1090. <code>altLength</code>.
  1091. </td>
  1092. </tr>
  1093. <tr>
  1094. <td class="greenField">dash.altLength</td>
  1095. <td>number</td>
  1096. <td>undefined</td>
  1097. <td>Length of the alternated dash in pixels on a dashed line.
  1098. Specifying <code>dash.altLength</code> allows for creating
  1099. a dashed line with a dash-dot style, for example when
  1100. <code>dash.length=10</code> and <code>dash.altLength=5</code>.
  1101. See also the option <code>dahs.length</code>.
  1102. Only applicable when the line style is <code>dash-line</code>.</td>
  1103. </tr>
  1104. <tr>
  1105. <td class="greenField">dash.length</td>
  1106. <td>number</td>
  1107. <td>10</td>
  1108. <td>Length of a dash in pixels on a dashed line.
  1109. Only applicable when the line style is <code>dash-line</code>.</td>
  1110. </tr>
  1111. <tr>
  1112. <td class="greenField">dash.gap</td>
  1113. <td>number</td>
  1114. <td>5</td>
  1115. <td>Length of a gap in pixels on a dashed line.
  1116. Only applicable when the line style is <code>dash-line</code>.</td>
  1117. </tr>
  1118. <tr>
  1119. <td class="greenField">fontColor</td>
  1120. <td>String</td>
  1121. <td>#343434</td>
  1122. <td>Font color for the text label of the edge.
  1123. Only applicable when property <code>label</code> is defined.</td>
  1124. </tr>
  1125. <tr>
  1126. <td class="greenField">fontFace</td>
  1127. <td>String</td>
  1128. <td>arial</td>
  1129. <td>Font face for the text label of the edge,
  1130. for example "verdana" or "arial".
  1131. Only applicable when property <code>label</code> is defined.</td>
  1132. </tr>
  1133. <tr>
  1134. <td class="greenField">fontSize</td>
  1135. <td>Number</td>
  1136. <td>14</td>
  1137. <td>Font size in pixels for the text label of the edge.
  1138. Only applicable when property <code>label</code> is defined.</td>
  1139. </tr>
  1140. <tr>
  1141. <td class="greenField">fontFill</td>
  1142. <td>string</td>
  1143. <td>white</td>
  1144. <td>Font fill for the background color of the text label of the edge.
  1145. Only applicable when property <code>label</code> is defined.</td>
  1146. </tr>
  1147. <tr>
  1148. <td class="greenField">fontStrokeWidth</td>
  1149. <td>Number</td>
  1150. <td>0</td>
  1151. <td>The width of the label stroke (border around label's text) in pixels.
  1152. Only applicable when property <code>label</code> is defined.</td>
  1153. </tr>
  1154. <tr>
  1155. <td class="greenField">fontStrokeColor</td>
  1156. <td>String</td>
  1157. <td>'white'</td>
  1158. <td>The color of the label stroke.
  1159. Only applicable when property <code>label</code> is defined.</td>
  1160. </tr>
  1161. <tr>
  1162. <td class="greenField">inheritColor</td>
  1163. <td>String | Boolean</td>
  1164. <td>from</td>
  1165. <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",
  1166. 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>
  1167. </tr>
  1168. <tr>
  1169. <td class="greenField">labelAlignment</td>
  1170. <td>String</td>
  1171. <td>horizontal</td>
  1172. <td>Possible values: <code>"line-above", "line-center", "line-below"</code>. The alignment of the label when drawn on the edge.
  1173. If <code>horizontal</code> it will align the label absolute horizontial.</td>
  1174. </tr>
  1175. <tr>
  1176. <td class="greenField">opacity</td>
  1177. <td>Number</td>
  1178. <td>1.0</td>
  1179. <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>
  1180. </tr>
  1181. <tr>
  1182. <td class="greenField">style</td>
  1183. <td>string</td>
  1184. <td>line</td>
  1185. <td>Define a line style for the edge.
  1186. Choose from <code>line</code> (default), <code>arrow</code>,
  1187. <code>arrow-center</code>, or <code>dash-line</code>.
  1188. </td>
  1189. </tr>
  1190. <tr>
  1191. <td class="greenField">width</td>
  1192. <td>number</td>
  1193. <td>1</td>
  1194. <td>Width of the line in pixels. The <code>width</code> will
  1195. override a specified <code>value</code>, if a <code>value</code> is
  1196. specified too.</td>
  1197. </tr>
  1198. <tr>
  1199. <td class="greenField">widthSelectionMultiplier</td>
  1200. <td>Number</td>
  1201. <td>2</td>
  1202. <td>Determines the thickness scaling of an selected edge. This is applied when an edge, or a node connected to it, is selected.</td>
  1203. </tr>
  1204. <tr>
  1205. <td>widthMin</td>
  1206. <td>Number</td>
  1207. <td>1</td>
  1208. <td>The minimum thickness of the line when using per-edge defined values. This does nothing if you have not defined a value.</td>
  1209. </tr>
  1210. <tr>
  1211. <td>widthMax</td>
  1212. <td>Number</td>
  1213. <td>15</td>
  1214. <td>The maximum thickness of the line when using per-edge defined values. This does nothing if you have not defined a value.</td>
  1215. </tr>
  1216. </table>
  1217. <h3 id="Groups_configuration">Groups configuration</h3>
  1218. <p>It is possible to specify custom styles for groups of nodes.
  1219. Each node having assigned to this group gets the specified style.
  1220. The options <code>groups</code> is an object containing one or multiple groups,
  1221. identified by a unique string, the groupname.
  1222. </p>
  1223. <p>
  1224. A group can have the following styles:
  1225. </p>
  1226. <pre class="prettyprint lang-js">
  1227. var options = {
  1228. // ...
  1229. groups: {
  1230. mygroup: {
  1231. shape: 'circle',
  1232. color: {
  1233. border: 'black',
  1234. background: 'white',
  1235. highlight: {
  1236. border: 'yellow',
  1237. background: 'orange'
  1238. }
  1239. }
  1240. fontColor: 'red',
  1241. fontSize: 18
  1242. }
  1243. // add more groups here
  1244. }
  1245. };
  1246. var nodes = [
  1247. {id: 1, label: 'Node 1'}, // will get the default style
  1248. {id: 2, label: 'Node 2', group: 'mygroup'}, // will get the style from 'mygroup'
  1249. // ... more nodes
  1250. ];
  1251. </pre>
  1252. <p>The following styles are available for groups:</p>
  1253. <table>
  1254. <tr>
  1255. <th>Name</th>
  1256. <th>Type</th>
  1257. <th>Default</th>
  1258. <th>Description</th>
  1259. </tr>
  1260. <tr>
  1261. <td>color</td>
  1262. <td>String | Object</td>
  1263. <td>Object</td>
  1264. <td>Color of the node</td>
  1265. </tr>
  1266. <tr>
  1267. <td>color.border</td>
  1268. <td>String</td>
  1269. <td>"#2B7CE9"</td>
  1270. <td>Border color of the node</td>
  1271. </tr>
  1272. <tr>
  1273. <td>color.background</td>
  1274. <td>String</td>
  1275. <td>"#97C2FC"</td>
  1276. <td>Background color of the node</td>
  1277. </tr>
  1278. <tr>
  1279. <td>color.highlight</td>
  1280. <td>String | Object</td>
  1281. <td>"#D2E5FF"</td>
  1282. <td>Default color of the node when the node is selected. In case of a string, the color is applied to
  1283. both border and background of the node.</td>
  1284. </tr>
  1285. <tr>
  1286. <td>color.highlight.background</td>
  1287. <td>String</td>
  1288. <td>"#D2E5FF"</td>
  1289. <td>Background color of the node when selected.</td>
  1290. </tr>
  1291. <tr>
  1292. <td>color.highlight.border</td>
  1293. <td>String</td>
  1294. <td>"#D2E5FF"</td>
  1295. <td>Border color of the node when selected.</td>
  1296. </tr>
  1297. <tr>
  1298. <td>image</td>
  1299. <td>String</td>
  1300. <td>none</td>
  1301. <td>Default image for the nodes. Only applicable in combination with
  1302. shape <code>image</code>.</td>
  1303. </tr>
  1304. <tr>
  1305. <td>fontColor</td>
  1306. <td>String</td>
  1307. <td>"black"</td>
  1308. <td>Font color of the node.</td>
  1309. </tr>
  1310. <tr>
  1311. <td>fontFace</td>
  1312. <td>String</td>
  1313. <td>"sans"</td>
  1314. <td>Font name of the node, for example "verdana" or "arial".</td>
  1315. </tr>
  1316. <tr>
  1317. <td>fontSize</td>
  1318. <td>Number</td>
  1319. <td>14</td>
  1320. <td>Font size for the node in pixels.</td>
  1321. </tr>
  1322. <tr>
  1323. <td>fontStrokeWidth</td>
  1324. <td>Number</td>
  1325. <td>0</td>
  1326. <td>The width of the label stroke (border around label's text) in pixels.</td>
  1327. </tr>
  1328. <tr>
  1329. <td>fontStrokeColor</td>
  1330. <td>String</td>
  1331. <td>"white"</td>
  1332. <td>The color of the label stroke.</td>
  1333. </tr>
  1334. <tr>
  1335. <td>shape</td>
  1336. <td>String</td>
  1337. <td>"ellipse"</td>
  1338. <td>Choose from
  1339. <code>ellipse</code> (default), <code>circle</code>, <code>box</code>,
  1340. <code>database</code>, <code>image</code>, <code>label</code>, <code>dot</code>,
  1341. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.
  1342. In case of image, a property with name image must be provided, containing
  1343. image urls.</td>
  1344. </tr>
  1345. <tr>
  1346. <td>radius</td>
  1347. <td>Number</td>
  1348. <td>5</td>
  1349. <td>Default radius for the node. Only applicable in combination with
  1350. shapes <code>box</code> and <code>dot</code>.</td>
  1351. </tr>
  1352. </table>
  1353. <h3 id="Physics">Physics</h3>
  1354. <p>
  1355. The original simulation method was based on particel physics with a repulsion field (potential) around each node,
  1356. 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.
  1357. 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.
  1358. 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/>
  1359. 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.
  1360. <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>.
  1361. </p>
  1362. <pre class="prettyprint">
  1363. // These variables must be defined in an options object named physics.
  1364. // If a variable is not supplied, the default value is used.
  1365. var options = {
  1366. physics: {
  1367. barnesHut: {
  1368. enabled: true,
  1369. gravitationalConstant: -2000,
  1370. centralGravity: 0.1,
  1371. springLength: 95,
  1372. springConstant: 0.04,
  1373. damping: 0.09
  1374. },
  1375. repulsion: {
  1376. centralGravity: 0.1,
  1377. springLength: 50,
  1378. springConstant: 0.05,
  1379. nodeDistance: 100,
  1380. damping: 0.09
  1381. },
  1382. hierarchicalRepulsion: {
  1383. centralGravity: 0.5,
  1384. springLength: 150,
  1385. springConstant: 0.01,
  1386. nodeDistance: 60,
  1387. damping: 0.09
  1388. }
  1389. }
  1390. </pre>
  1391. <h5>barnesHut:</h5>
  1392. <table>
  1393. <tr>
  1394. <th>Name</th>
  1395. <th>Type</th>
  1396. <th>Default</th>
  1397. <th>Description</th>
  1398. </tr>
  1399. <tr>
  1400. <td>enabled</td>
  1401. <td>Boolean</td>
  1402. <td>true</td>
  1403. <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>
  1404. </tr>
  1405. <tr>
  1406. <td>gravitationalConstant</td>
  1407. <td>Number</td>
  1408. <td>-2000</td>
  1409. <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>
  1410. </tr>
  1411. <tr>
  1412. <td>centralGravity</td>
  1413. <td>Number</td>
  1414. <td>0.1</td>
  1415. <td>The central gravity is a force that pulls all nodes to the center. This ensures independent groups do not float apart.</td>
  1416. </tr>
  1417. <tr>
  1418. <td>springLength</td>
  1419. <td>Number</td>
  1420. <td>95</td>
  1421. <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.
  1422. To greatly reduce the edge length, the gravitationalConstant has to be reduced as well.</td>
  1423. </tr>
  1424. <tr>
  1425. <td>springConstant</td>
  1426. <td>Number</td>
  1427. <td>0.04</td>
  1428. <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>
  1429. </tr>
  1430. <tr>
  1431. <td>damping</td>
  1432. <td>Number</td>
  1433. <td>0.09</td>
  1434. <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>
  1435. </tr>
  1436. </table>
  1437. <h5>repulsion:</h5>
  1438. <table>
  1439. <tr>
  1440. <th>Name</th>
  1441. <th>Type</th>
  1442. <th>Default</th>
  1443. <th>Description</th>
  1444. </tr>
  1445. <tr>
  1446. <td>centralGravity</td>
  1447. <td>Number</td>
  1448. <td>0.1</td>
  1449. <td>The central gravity is a force that pulls all nodes to the center. This ensures independent groups do not float apart.</td>
  1450. </tr>
  1451. <tr>
  1452. <td>nodeDistance</td>
  1453. <td>Number</td>
  1454. <td>100</td>
  1455. <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>
  1456. </tr>
  1457. <tr>
  1458. <td>springLength</td>
  1459. <td>Number</td>
  1460. <td>50</td>
  1461. <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.
  1462. To greatly reduce the edge length, the gravitationalConstant has to be reduced as well.</td>
  1463. </tr>
  1464. <tr>
  1465. <td>springConstant</td>
  1466. <td>Number</td>
  1467. <td>0.05</td>
  1468. <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>
  1469. </tr>
  1470. <tr>
  1471. <td>damping</td>
  1472. <td>Number</td>
  1473. <td>0.09</td>
  1474. <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>
  1475. </tr>
  1476. </table>
  1477. <h5>hierarchicalRepulsion:</h5>
  1478. <table>
  1479. <tr>
  1480. <th>Name</th>
  1481. <th>Type</th>
  1482. <th>Default</th>
  1483. <th>Description</th>
  1484. </tr>
  1485. <tr>
  1486. <td>centralGravity</td>
  1487. <td>Number</td>
  1488. <td>0.5</td>
  1489. <td>The central gravity is a force that pulls all nodes to the center. This ensures independent groups do not float apart.</td>
  1490. </tr>
  1491. <tr>
  1492. <td>nodeDistance</td>
  1493. <td>Number</td>
  1494. <td>60</td>
  1495. <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>
  1496. </tr>
  1497. <tr>
  1498. <td>springLength</td>
  1499. <td>Number</td>
  1500. <td>100</td>
  1501. <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.
  1502. To greatly reduce the edge length, the gravitationalConstant has to be reduced as well.</td>
  1503. </tr>
  1504. <tr>
  1505. <td>springConstant</td>
  1506. <td>Number</td>
  1507. <td>0.01</td>
  1508. <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>
  1509. </tr>
  1510. <tr>
  1511. <td>damping</td>
  1512. <td>Number</td>
  1513. <td>0.09</td>
  1514. <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>
  1515. </tr>
  1516. </table>
  1517. <h4 id="PhysicsConfiguration">Configuration:</h4>
  1518. 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
  1519. 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
  1520. settings you are happy with, you can supply them to network using the physics options as described above.
  1521. 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.
  1522. <pre class="prettyprint">
  1523. var options = {
  1524. configurePhysics:true
  1525. }
  1526. </pre>
  1527. <h3 id="Data_manipulation">Data manipulation</h3>
  1528. <p>
  1529. 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.
  1530. 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
  1531. 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>,
  1532. 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.
  1533. The user is free to alter or overload the CSS classes but without them the navigation icons are not visible.
  1534. </p>
  1535. <pre class="prettyprint">
  1536. // These variables must be defined in an options object named dataManipulation.
  1537. // If a variable is not supplied, the default value is used.
  1538. var options = {
  1539. dataManipulation: {
  1540. enabled: false,
  1541. initiallyVisible: false
  1542. }
  1543. }
  1544. // OR to just load the module with default values:
  1545. var options = {
  1546. dataManipulation: true
  1547. }
  1548. </pre>
  1549. <table>
  1550. <tr>
  1551. <th>Name</th>
  1552. <th>Type</th>
  1553. <th>Default</th>
  1554. <th>Description</th>
  1555. </tr>
  1556. <tr>
  1557. <td>enabled</td>
  1558. <td>Boolean</td>
  1559. <td>false</td>
  1560. <td>Enabling or disabling of the data manipulation toolbar. If it is initially hidden, an edit button appears in the top left corner.</td>
  1561. </tr>
  1562. <tr>
  1563. <td>initiallyVisible</td>
  1564. <td>Boolean</td>
  1565. <td>false</td>
  1566. <td>Initially hide or show the data manipulation toolbar.</td>
  1567. </tr>
  1568. </table>
  1569. <h4 id="Data_manipulation_custom">Data manipulation: custom functionality</h4>
  1570. <p>
  1571. 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.
  1572. If the callback is NOT called, nothing happens. <a href="../examples/network/21_data_manipulation.html">Example 21</a> has two working examples
  1573. for the add and edit functions. The data the user is supplied with in these functions has been described in the code below.
  1574. 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
  1575. 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
  1576. requires the same data structure that is supplied to the user. <br /><br />
  1577. <b>If there is no injected function supplied for the edit operation, the button will not be shown in the toolbar.</b>
  1578. </p>
  1579. <pre class="prettyprint">
  1580. // If a variable is not supplied, the default value is used.
  1581. var options = {
  1582. dataManipulation: true,
  1583. onAdd: function(data,callback) {
  1584. /** data = {id: random unique id,
  1585. * label: new,
  1586. * x: x position of click (canvas space),
  1587. * y: y position of click (canvas space),
  1588. * allowedToMoveX: true,
  1589. * allowedToMoveY: true
  1590. * };
  1591. */
  1592. var newData = {..}; // alter the data as you want.
  1593. // all fields normally accepted by a node can be used.
  1594. callback(newData); // call the callback to add a node.
  1595. },
  1596. onEdit: function(data,callback) {
  1597. /** data = {id:...,
  1598. * label: ...,
  1599. * group: ...,
  1600. * shape: ...,
  1601. * color: {
  1602. * background:...,
  1603. * border:...,
  1604. * highlight: {
  1605. * background:...,
  1606. * border:...
  1607. * }
  1608. * }
  1609. * };
  1610. */
  1611. var newData = {..}; // alter the data as you want.
  1612. // all fields normally accepted by a node can be used.
  1613. callback(newData); // call the callback with the new data to edit the node.
  1614. }
  1615. onEditEdge: function(data,callback) {
  1616. /** data = {id: edgeID,
  1617. * from: nodeId1,
  1618. * to: nodeId2,
  1619. * };
  1620. */
  1621. var newData = {..}; // alter the data as you want, except for the ID.
  1622. // all fields normally accepted by an edge can be used.
  1623. callback(newData); // call the callback with the new data to edit the edge.
  1624. }
  1625. onConnect: function(data,callback) {
  1626. // data = {from: nodeId1, to: nodeId2};
  1627. var newData = {..}; // check or alter data as you see fit.
  1628. callback(newData); // call the callback to connect the nodes.
  1629. },
  1630. onDelete: function(data,callback) {
  1631. // data = {nodes: [selectedNodeIds], edges: [selectedEdgeIds]};
  1632. var newData = {..}; // alter the data as you want.
  1633. // the same data structure is required.
  1634. callback(newData); // call the callback to delete the objects.
  1635. }
  1636. };
  1637. </pre>
  1638. <p>
  1639. 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.
  1640. 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.
  1641. An code snippet from example 21 is shown below.
  1642. </p>
  1643. <pre class="prettyprint">
  1644. network.on("resize", function(params) {console.log(params.width,params.height)});
  1645. </pre>
  1646. <h3 id="Clustering">Clustering</h3>
  1647. <p>
  1648. The network now supports dynamic clustering of nodes. This allows a user to view a very large dataset (> 50.000 nodes) without
  1649. sacrificing performance. When loading a large dataset, the nodes are clustered initially (this may take a small while) to have a
  1650. responsive visualization to work with. The clustering is both outside-in and inside-out. Outside-in means that nodes with only one
  1651. connection will be contained, or clustered, in the node it is connected to. Inside-out clustering first determines which nodes are hubs.
  1652. Hubs are defined as the nodes with the top 3% highest amount of connections (assuming normal distribution). These hubs then "grow", meaning
  1653. 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.
  1654. <br />
  1655. <br />
  1656. 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
  1657. to calculate the required forces. The contained nodes are removed from the global nodes index, greatly speeding up the system.
  1658. <br />
  1659. <br />
  1660. The clustering has the following user-configurable settings. The default values have been tested with the Network examples and work well.
  1661. The default state for clustering is <b>off</b>.
  1662. </p>
  1663. <pre class="prettyprint">
  1664. // These variables must be defined in an options object named clustering.
  1665. // If a variable is not supplied, the default value is used.
  1666. var options = {
  1667. clustering: {
  1668. initialMaxNodes: 100,
  1669. clusterThreshold:500,
  1670. reduceToNodes:300,
  1671. chainThreshold: 0.4,
  1672. clusterEdgeThreshold: 20,
  1673. sectorThreshold: 100,
  1674. screenSizeThreshold: 0.2,
  1675. fontSizeMultiplier: 4.0,
  1676. maxFontSize: 1000,
  1677. forceAmplification: 0.1,
  1678. distanceAmplification: 0.1,
  1679. edgeGrowth: 20,
  1680. nodeScaling: {width: 1,
  1681. height: 1,
  1682. radius: 1},
  1683. maxNodeSizeIncrements: 600,
  1684. activeAreaBoxSize: 100,
  1685. clusterLevelDifference: 2,
  1686. clusterByZoom: true
  1687. }
  1688. }
  1689. // OR to just load the module with default values:
  1690. var options = {
  1691. clustering: true
  1692. }
  1693. </pre>
  1694. <table>
  1695. <tr>
  1696. <th>Name</th>
  1697. <th>Type</th>
  1698. <th>Default</th>
  1699. <th>Description</th>
  1700. </tr>
  1701. <tr>
  1702. <td>initialMaxNodes</td>
  1703. <td>Number</td>
  1704. <td>100</td>
  1705. <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>
  1706. </tr>
  1707. <tr>
  1708. <td>clusterThreshold</td>
  1709. <td>Number</td>
  1710. <td>500</td>
  1711. <td>While zooming in and out, clusters can open up. Once there are more than <code>absoluteMaxNumberOfNodes</code> nodes,
  1712. clustering starts until <code>reduceToMaxNumberOfNodes</code> nodes are left. This is done to ensure performance is continuously fluid.</td>
  1713. </tr>
  1714. <tr>
  1715. <td>reduceToNodes</td>
  1716. <td>Number</td>
  1717. <td>300</td>
  1718. <td>While zooming in and out, clusters can open up. Once there are more than <code>absoluteMaxNumberOfNodes</code> nodes,
  1719. clustering starts until <code>reduceToMaxNumberOfNodes</code> nodes are left. This is done to ensure performance is continiously fluid.</td>
  1720. </tr>
  1721. <tr>
  1722. <td>chainThreshold</td>
  1723. <td>Number</td>
  1724. <td>0.4</td>
  1725. <td>Because of the clustering methods used, long chains of nodes can be formed. To reduce these chains, this threshold is used.
  1726. 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).
  1727. If there are more, they are clustered together.</td>
  1728. </tr>
  1729. <tr>
  1730. <td>clusterEdgeThreshold</td>
  1731. <td>Number</td>
  1732. <td>20</td>
  1733. <td>This is the absolute edge length threshold in pixels. If the edge is smaller on screen (that means zooming out reduces this length)
  1734. the node will be clustered. This is triggered when zooming out.</td>
  1735. </tr>
  1736. <tr>
  1737. <td>sectorThreshold</td>
  1738. <td>Integer</td>
  1739. <td>50</td>
  1740. <td>If a cluster larger than <code>sectorThreshold</code> is opened, a seperate instance called a sector, will be created. All the simulation of
  1741. nodes outside of this instance will be paused. This is to maintain performance and clarity when examining large clusters.
  1742. 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>
  1743. </tr>
  1744. <tr>
  1745. <td>screenSizeThreshold</td>
  1746. <td>Number</td>
  1747. <td>0.2</td>
  1748. <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
  1749. 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
  1750. 20%, we collapse this sector.</td>
  1751. </tr>
  1752. <tr>
  1753. <td>fontSizeMultiplier</td>
  1754. <td>Number</td>
  1755. <td>4.0</td>
  1756. <td>This parameter denotes the increase in fontSize of the cluster when a single node is added to it.</td>
  1757. </tr>
  1758. <tr>
  1759. <td>maxFontSize</td>
  1760. <td>Number</td>
  1761. <td>1000</td>
  1762. <td>This parameter denotes the largest allowed font size. If the font becomes too large, some browsers experience problems displaying this.</td>
  1763. </tr>
  1764. <tr>
  1765. <td>forceAmplification</td>
  1766. <td>Number</td>
  1767. <td>0.6</td>
  1768. <td>This factor is used to calculate the increase of the repulsive force of a cluster. It is calculated by the following
  1769. formula: <code>repulsingForce *= 1 + (clusterSize * forceAmplification)</code>.</td>
  1770. </tr>
  1771. <tr>
  1772. <td>distanceAmplification</td>
  1773. <td>Number</td>
  1774. <td>0.2</td>
  1775. <td>This factor is used to calculate the increase in effective range of the repulsive force of the cluster.
  1776. A larger cluster has a longer range. It is calculated by the following
  1777. formula: <code>minDistance *= 1 + (clusterSize * distanceAmplification)</code>.</td>
  1778. </tr>
  1779. <tr>
  1780. <td>edgeGrowth</td>
  1781. <td>Number</td>
  1782. <td>20</td>
  1783. <td>This factor determines the elongation of edges connected to a cluster.</td>
  1784. </tr>
  1785. <tr>
  1786. <td>nodeScaling.width</td>
  1787. <td>Number</td>
  1788. <td>10</td>
  1789. <td>This factor determines how much the width of a cluster increases in pixels per added node.</td>
  1790. </tr>
  1791. <tr>
  1792. <td>nodeScaling.height</td>
  1793. <td>Number</td>
  1794. <td>10</td>
  1795. <td>This factor determines how much the height of a cluster increases in pixels per added node.</td>
  1796. </tr>
  1797. <tr>
  1798. <td>nodeScaling.radius</td>
  1799. <td>Number</td>
  1800. <td>10</td>
  1801. <td>This factor determines how much the radius of a cluster increases in pixels per added node.</td>
  1802. </tr>
  1803. <tr>
  1804. <td>maxNodeSizeIncrements</td>
  1805. <td>Number</td>
  1806. <td>600</td>
  1807. <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>
  1808. </tr>
  1809. <tr>
  1810. <td>activeAreaBoxSize</td>
  1811. <td>Number</td>
  1812. <td>100</td>
  1813. <td>Imagine a square with an edge length of <code>activeAreaBoxSize</code> pixels around your cursor.
  1814. If a cluster is in this box as you zoom in, the cluster can be opened in a seperate sector.
  1815. This is regardless of the zoom level.</td>
  1816. </tr>
  1817. <tr>
  1818. <td>clusterLevelDifference</td>
  1819. <td>Number</td>
  1820. <td>2</td>
  1821. <td>At every clustering session, Network will check if the difference between cluster levels is
  1822. acceptable. When a cluster is formed when zooming out, that is one cluster level.
  1823. If you zoom out further and it encompasses more nodes, that is another level. For example:
  1824. If the highest level of your network at any given time is 3, nodes that have not clustered or
  1825. have clustered only once will join their neighbour with the lowest cluster level.</td>
  1826. </tr>
  1827. <tr>
  1828. <td>clusterByZoom</td>
  1829. <td>Boolean</td>
  1830. <td>true</td>
  1831. <td>You can toggle the clustering by zoom level using this option.</td>
  1832. </tr>
  1833. </table>
  1834. <h3 id="Navigation_controls">Navigation controls</h3>
  1835. <p>
  1836. Network has a menu with navigation controls, which is disabled by default.
  1837. It can be configured with the following settings. To correctly display the navigation icons, the <b>vis.css</b> file must be included.
  1838. The user is free to alter or overload the CSS classes but without them the navigation icons are not visible.
  1839. </p>
  1840. <pre class="prettyprint">
  1841. // use of navigation controls
  1842. var options = {
  1843. navigation: true
  1844. }
  1845. </pre>
  1846. <h3 id="Keyboard_navigation">Keyboard navigation</h3>
  1847. <p>
  1848. The network can be navigated using shortcut keys.
  1849. 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>.
  1850. </p>
  1851. <pre class="prettyprint">
  1852. // simple use of keyboard controls
  1853. var options = {
  1854. keyboard: true
  1855. }
  1856. // advanced configuration for keyboard controls
  1857. var options = {
  1858. keyboard: {
  1859. speed: {
  1860. x: 10,
  1861. y: 10,
  1862. zoom: 0.02
  1863. },
  1864. bindToWindow: true
  1865. }
  1866. }
  1867. </pre>
  1868. <table>
  1869. <tr>
  1870. <th>Name</th>
  1871. <th>Type</th>
  1872. <th>Default</th>
  1873. <th>Description</th>
  1874. </tr>
  1875. <tr>
  1876. <td>speed.x</td>
  1877. <td>Number</td>
  1878. <td>10</td>
  1879. <td>This defines the speed of the camera movement in the x direction when using the keyboard navigation.
  1880. </td>
  1881. </tr>
  1882. <tr>
  1883. <td>speed.y</td>
  1884. <td>Number</td>
  1885. <td>10</td>
  1886. <td>This defines the speed of the camera movement in the y direction when using the keyboard navigation.</td>
  1887. </tr>
  1888. <tr>
  1889. <td>speed.zoom</td>
  1890. <td>Number</td>
  1891. <td>0.02</td>
  1892. <td>This defines the zoomspeed when using the keyboard navigation.</td>
  1893. </tr>
  1894. <tr>
  1895. <td>bindToWindow</td>
  1896. <td>Boolean</td>
  1897. <td>true</td>
  1898. <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>
  1899. </tr>
  1900. </table>
  1901. <h3 id="Hierarchical_layout">Hierarchical layout</h3>
  1902. <p>
  1903. 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.
  1904. 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
  1905. 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>.
  1906. This layout method does not support smooth curves or clustering. It automatically turns these features off.
  1907. </p>
  1908. <pre class="prettyprint">
  1909. // simple use of the hierarchical layout
  1910. var options = {
  1911. hierarchicalLayout: true
  1912. }
  1913. // advanced configuration for hierarchical layout
  1914. var options = {
  1915. hierarchicalLayout: {
  1916. enabled:false,
  1917. levelSeparation: 150,
  1918. nodeSpacing: 100,
  1919. direction: "UD",
  1920. layout: "hubsize"
  1921. }
  1922. }
  1923. // partial configuration automatically sets enabled to true
  1924. var options = {
  1925. hierarchicalLayout: {
  1926. nodeSpacing: 100,
  1927. direction: "UD"
  1928. }
  1929. }
  1930. </pre>
  1931. <table>
  1932. <tr>
  1933. <th>Name</th>
  1934. <th>Type</th>
  1935. <th>Default</th>
  1936. <th>Description</th>
  1937. </tr>
  1938. <tr>
  1939. <td>enabled</td>
  1940. <td>Boolean</td>
  1941. <td>false</td>
  1942. <td>Enable or disable the hierarchical layout.
  1943. </td>
  1944. </tr>
  1945. <tr>
  1946. <td>levelSeparation</td>
  1947. <td>Number</td>
  1948. <td>150</td>
  1949. <td>This defines the space between levels (in the Y-direction, considering UP-DOWN direction).</td>
  1950. </tr>
  1951. <tr>
  1952. <td>nodeSpacing</td>
  1953. <td>Number</td>
  1954. <td>100</td>
  1955. <td>This defines the space between nodes in the same level (in the X-direction, considering UP-DOWN direction).
  1956. This is only relevant during the initial placing of nodes.</td>
  1957. </tr>
  1958. <tr>
  1959. <td>direction</td>
  1960. <td>String</td>
  1961. <td>UD</td>
  1962. <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).
  1963. These need to be supplied by the acronyms in parentheses.</td>
  1964. </tr>
  1965. <tr>
  1966. <td>layout</td>
  1967. <td>String</td>
  1968. <td>hubsize</td>
  1969. <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.
  1970. 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>
  1971. </tr>
  1972. </table>
  1973. <h3 id="Localization">Localization</h3>
  1974. <p>
  1975. When using vis.js in other languages, one can use the localization option to get a localized data manipulation interface.
  1976. </p>
  1977. <table>
  1978. <tr>
  1979. <th>Name</th>
  1980. <th>Type</th>
  1981. <th>Default</th>
  1982. <th>Description</th>
  1983. </tr>
  1984. <tr>
  1985. <td>locale</td>
  1986. <td>String</td>
  1987. <td>none</td>
  1988. <td>Select a locale for the Network.</td>
  1989. </tr>
  1990. <tr>
  1991. <td>locales</td>
  1992. <td>Object</td>
  1993. <td>none</td>
  1994. <td>A map with i18n locales.</td>
  1995. </tr>
  1996. </table>
  1997. <p>
  1998. To set a locale for the Network, specify the option <code>locale</code>:
  1999. </p>
  2000. <pre class="prettyprint lang-js">var options = {
  2001. locale: 'nl'
  2002. };
  2003. </pre>
  2004. <h4>Create a new locale</h4>
  2005. To load a locale into the Timeline not supported by default, one can add a new locale to the option <code>locales</code>:
  2006. <pre class="prettyprint lang-js">var options = {
  2007. locales: {
  2008. // create a new locale (text strings should be replaced with localized strings)
  2009. mylocale: {
  2010. edit: 'Edit',
  2011. del: 'Delete selected',
  2012. back: 'Back',
  2013. addNode: 'Add Node',
  2014. addEdge: 'Add Edge',
  2015. editNode: 'Edit Node',
  2016. editEdge: 'Edit Edge',
  2017. addDescription: 'Click in an empty space to place a new node.',
  2018. edgeDescription: 'Click on a node and drag the edge to another node to connect them.',
  2019. editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
  2020. createEdgeError: 'Cannot link edges to a cluster.',
  2021. deleteClusterError: 'Clusters cannot be deleted.'
  2022. }
  2023. },
  2024. // use the new locale
  2025. locale: 'mylocale'
  2026. };
  2027. </pre>
  2028. <h4 id="available-locales">Available locales</h4>
  2029. <p>
  2030. Network comes with support for the following locales:
  2031. </p>
  2032. <table>
  2033. <tr><th>Language</th><th>Code</th></tr>
  2034. <tr>
  2035. <td>English</td>
  2036. <td>
  2037. <code>en</code><br>
  2038. <code>en_EN</code><br>
  2039. <code>en_US</code>
  2040. </td>
  2041. </tr>
  2042. <tr>
  2043. <td>Dutch</td>
  2044. <td>
  2045. <code>nl</code><br>
  2046. <code>nl_NL</code><br>
  2047. <code>nl_BE</code>
  2048. </td>
  2049. </tr>
  2050. </table>
  2051. <h3 id="Tooltips">Tooltips</h3>
  2052. <p>
  2053. The behaviour and style of the tooltips used to display node and edge title attributes can be customized.
  2054. </p>
  2055. <pre class="prettyprint">
  2056. // tooltip behaviour and style options
  2057. var options = {
  2058. tooltip: {
  2059. delay: 300,
  2060. fontColor: "black",
  2061. fontSize: 14, // px
  2062. fontFace: "verdana",
  2063. color: {
  2064. border: "#666",
  2065. background: "#FFFFC6"
  2066. }
  2067. }
  2068. }
  2069. </pre>
  2070. <table>
  2071. <tr>
  2072. <th>Name</th>
  2073. <th>Type</th>
  2074. <th>Default</th>
  2075. <th>Description</th>
  2076. </tr>
  2077. <tr>
  2078. <td>delay</td>
  2079. <td>Number</td>
  2080. <td>300</td>
  2081. <td>Time in milliseconds a user must hover over a node or edge before a tooltip appears.</td>
  2082. </tr>
  2083. <tr>
  2084. <td>fontColor</td>
  2085. <td>String</td>
  2086. <td>"black"</td>
  2087. <td>Default color for tooltip text.</td>
  2088. </tr>
  2089. <tr>
  2090. <td>fontSize</td>
  2091. <td>Number</td>
  2092. <td>14</td>
  2093. <td>Size in pixels of tooltip text.</td>
  2094. </tr>
  2095. <tr>
  2096. <td>fontFace</td>
  2097. <td>String</td>
  2098. <td>"verdana"</td>
  2099. <td>Font family to used for tooltip text.</td>
  2100. </tr>
  2101. <tr>
  2102. <td>color.background</td>
  2103. <td>String</td>
  2104. <td>"#FFFFC6"</td>
  2105. <td>Background color for the node.</td>
  2106. </tr>
  2107. <tr>
  2108. <td>color.border</td>
  2109. <td>String</td>
  2110. <td>"#666"</td>
  2111. <td>Border color for the node.</td>
  2112. </tr>
  2113. </table>
  2114. <h2 id="Methods">Methods</h2>
  2115. <p>
  2116. Network supports the following methods.
  2117. </p>
  2118. <table>
  2119. <tr>
  2120. <th>Method</th>
  2121. <th>Return Type</th>
  2122. <th>Description</th>
  2123. </tr>
  2124. <tr>
  2125. <td>getScale()</td>
  2126. <td>Number</td>
  2127. <td>Returns the scale of the network. This can be for animation. This scale is like a percentage, 1.0 = 100%.
  2128. Zooming in is > 1.0, zooming out is < 0. Scale cannot be smaller or equal to 0.
  2129. </td>
  2130. </tr>
  2131. <tr>
  2132. <td>getCenterCoordinates()</td>
  2133. <td>Number</td>
  2134. <td>Returns the x and y coodinates of the center of the screen (in canvas space).
  2135. </td>
  2136. </tr>
  2137. <tr>
  2138. <td>getBoundingBox(nodeId)</td>
  2139. <td>Object</td>
  2140. <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.
  2141. </td>
  2142. </tr>
  2143. <tr>
  2144. <td>getConnectedNodes(nodeId)</td>
  2145. <td>Array</td>
  2146. <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
  2147. to quickly get them without iterating over all edges manually. This is a lot faster for cases with many edges.
  2148. </td>
  2149. </tr>
  2150. <tr>
  2151. <td>getSelection()</td>
  2152. <td>Array of ids</td>
  2153. <td>Returns an array with the ids of the selected nodes.
  2154. Returns an empty array if no nodes are selected.
  2155. The selections are not ordered.
  2156. </td>
  2157. </tr>
  2158. <tr>
  2159. <td>focusOnNode(nodeId, [options])</td>
  2160. <td>none</td>
  2161. <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 />
  2162. The options that can be defined are:<br />
  2163. <b><code>scale:Number</code></b><br /> - to zoom to that scale,<br />
  2164. <b><code>offset:{x:Number, y:Number}</code></b><br /> - to offset the position from the center of the canvas (in pixels),<br />
  2165. <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 />
  2166. <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 />
  2167. <br />
  2168. The animation object can consist of:<br />
  2169. <b><code>duration: Number</code></b><br /> - the duration of the animation in milliseconds,<br />
  2170. <b><code>easingFunction: String</code></b><br /> - the easing function of the animation, available are:<br />
  2171. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  2172. easeInQuart, easeOutQuart, easeInOutQuart,
  2173. easeInQuint, easeOutQuint, easeInOutQuint </code> <br /><br />
  2174. </td>
  2175. </tr>
  2176. <tr>
  2177. <td>freezeSimulation(Boolean)</td>
  2178. <td>none</td>
  2179. <td>Calling freezeSimulation(true) immmediately stops the simulation and triggerst the stabilized event. This does not mean that the network
  2180. is physically stabilized but the nodes are not moving anymore. To continue the simulation call freezeSimulation(false).
  2181. </td>
  2182. </tr>
  2183. <tr>
  2184. <td>releaseNode()</td>
  2185. <td>none</td>
  2186. <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.
  2187. </td>
  2188. </tr>
  2189. <tr>
  2190. <td>DOMtoCanvas(pos)</td>
  2191. <td>object</td>
  2192. <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.
  2193. </td>
  2194. </tr>
  2195. <tr>
  2196. <td>canvasToDOM(pos)</td>
  2197. <td>object</td>
  2198. <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.
  2199. </td>
  2200. </tr>
  2201. <tr>
  2202. <td>moveTo(options)</td>
  2203. <td>object</td>
  2204. <td>This function allows you to programmatically move the view. The options that can be defined are:<br />
  2205. <b><code>position:{x:Number, y:Number}</code></b><br /> - to move to that position (in canvas units), <br />
  2206. <b><code>scale:Number</code></b><br /> - to zoom to that scale,<br />
  2207. <b><code>offset:{x:Number, y:Number}</code></b><br /> - to offset the position from the center of the canvas (in DOM units),<br />
  2208. <b><code>animation: Object || Boolean</code></b><br /> - to define the specifics of the animation.<br />
  2209. <br />
  2210. The animation object can consist of:<br />
  2211. <b><code>duration: Number</code></b><br /> - the duration of the animation in milliseconds,<br />
  2212. <b><code>easingFunction: String</code></b><br /> - the easing function of the animation, available are:<br />
  2213. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  2214. easeInQuart, easeOutQuart, easeInOutQuart,
  2215. easeInQuint, easeOutQuint, easeInOutQuint </code> <br /><br />
  2216. <i>You will have to define at least a scale or a position. Otherwise, there is nothing to move to.</i>
  2217. </td>
  2218. </tr>
  2219. <tr>
  2220. <td>on(event, callback)</td>
  2221. <td>none</td>
  2222. <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>
  2223. </tr>
  2224. <tr>
  2225. <td>off(event, callback)</td>
  2226. <td>none</td>
  2227. <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>
  2228. </tr>
  2229. <tr>
  2230. <td>destroy()</td>
  2231. <td>none</td>
  2232. <td>Remove all bindings and clean up after the Network.</td>
  2233. </tr>
  2234. <tr>
  2235. <td>redraw()</td>
  2236. <td>none</td>
  2237. <td>Redraw the network. Useful when the layout of the webpage changed.</td>
  2238. </tr>
  2239. <tr>
  2240. <td>setData(data,[disableStart])</td>
  2241. <td>none</td>
  2242. <td>Loads data. Parameter <code>data</code> is an object containing
  2243. nodes, edges, and options. Parameters nodes, edges are an Array.
  2244. Options is a name-value map and is optional. Parameter <code>disableStart</code> is
  2245. an optional Boolean and can disable the start of the simulation that would begin at the end
  2246. of this function by default.
  2247. </td>
  2248. </tr>
  2249. <tr>
  2250. <td>setOptions(options)</td>
  2251. <td>none</td>
  2252. <td>Set options for the network. The available options are described in
  2253. the section <a href="#Configuration_options">Configuration Options</a>.
  2254. </td>
  2255. </tr>
  2256. <tr>
  2257. <td>selectNodes(selection, [highlightEdges])</td>
  2258. <td>none</td>
  2259. <td>Select nodes.
  2260. <code>selection</code> is an array with ids of nodes to be selected.
  2261. The array <code>selection</code> can contain zero or multiple ids.
  2262. Example usage: <code>network.selectNodes([3, 5]);</code> will select
  2263. nodes with id 3 and 5. The highlisghEdges boolean can be used to automatically select the edges connected to the node.
  2264. </td>
  2265. </tr>
  2266. <tr>
  2267. <td>getConnectedNodes(nodeId)</td>
  2268. <td>Array</td>
  2269. <td>Get an array of (unique) nodeIds that are directly connected to this node.
  2270. </td>
  2271. </tr>
  2272. <tr>
  2273. <td>selectEdges(selection)</td>
  2274. <td>none</td>
  2275. <td>Select Edges.
  2276. <code>selection</code> is an array with ids of edges to be selected.
  2277. The array <code>selection</code> can contain zero or multiple ids.
  2278. Example usage: <code>network.selectEdges([3, 5]);</code> will select
  2279. edges with id 3 and 5.
  2280. </td>
  2281. </tr>
  2282. <tr>
  2283. <td>setSize(width, height)</td>
  2284. <td>none</td>
  2285. <td>Parameters <code>width</code> and <code>height</code> are strings,
  2286. containing a new size for the visualization. Size can be provided in pixels
  2287. or in percentages.</td>
  2288. </tr>
  2289. <tr>
  2290. <td>getPositions([nodeIds])</td>
  2291. <td>Object</td>
  2292. <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.
  2293. </td>
  2294. </tr>
  2295. <tr>
  2296. <td>storePositions()</td>
  2297. <td>none</td>
  2298. <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.
  2299. If you're loading your nodes from a database and have this dynamically coupled with the DataSet, you can use this
  2300. 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.
  2301. 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.
  2302. <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>
  2303. </td>
  2304. </tr>
  2305. <tr>
  2306. <td>zoomExtent([options])</td>
  2307. <td>none</td>
  2308. <td>Scales the network so all the nodes are in center view. Optionally you can supply options for animation. These
  2309. options can just be a boolean. When true, the zoom is animated, when false there is no animation.
  2310. Alternatively, you can supply an object.
  2311. <br /><br /> The object can consist of:<br />
  2312. <b><code>nodes: [nodeIds]</code></b><br /> - an optional subset of nodes to zoom in on,<br />
  2313. <b><code>duration: Number</code></b><br /> - the duration of the animation in milliseconds,<br />
  2314. <b><code>easingFunction: String</code></b><br /> - the easing function of the animation, available are:<br />
  2315. <code>linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
  2316. easeInQuart, easeOutQuart, easeInOutQuart,
  2317. easeInQuint, easeOutQuint, easeInOutQuint </code>
  2318. </td>
  2319. </tr>
  2320. </table>
  2321. <h2 id="Events">Events</h2>
  2322. <p>
  2323. Network fires events after one or multiple nodes are selected or deselected.
  2324. The event can be catched by creating a listener.
  2325. </p>
  2326. <p>
  2327. Here an example on how to catch a <code>select</code> event.
  2328. </p>
  2329. <pre class="prettyprint lang-js">
  2330. network.on('select', function (properties) {
  2331. alert('selected nodes: ' + properties.nodes);
  2332. });
  2333. </pre>
  2334. <p>
  2335. A listener can be removed via the function <code>off</code>:
  2336. </p>
  2337. <pre class="prettyprint lang-js">
  2338. function onSelect (properties) {
  2339. alert('selected nodes: ' + properties.nodes);
  2340. }
  2341. // add event listener
  2342. network.on('select', onSelect);
  2343. // do stuff...
  2344. // remove event listener
  2345. network.off('select', onSelect);
  2346. </pre>
  2347. <p>
  2348. The following events are available.
  2349. </p>
  2350. <table>
  2351. <tr>
  2352. <th>name</th>
  2353. <th>Description</th>
  2354. <th>Properties</th>
  2355. </tr>
  2356. <tr>
  2357. <td>animationFinished</td>
  2358. <td>Fired after an animation is finished.
  2359. </td>
  2360. <td>
  2361. none
  2362. </td>
  2363. </tr>
  2364. <tr>
  2365. <td>select</td>
  2366. <td>Fired after the user selects or deselects a node by clicking it.
  2367. Not fired when the method <code>setSelection</code>is executed.
  2368. </td>
  2369. <td>
  2370. <ul>
  2371. <li><code>nodes</code>: an array with the ids of the selected nodes</li>
  2372. <li><code>edges</code>: an array with the ids of the selected edges</li>
  2373. </ul>
  2374. </td>
  2375. </tr>
  2376. <tr>
  2377. <td>click</td>
  2378. <td>Fired after the user clicks or taps on a touchscreen.</td>
  2379. <td>
  2380. <ul>
  2381. <li><code>nodes</code>: an array with the ids of the selected nodes</li>
  2382. <li><code>edges</code>: an array with the ids of the selected edges</li>
  2383. <li><code>pointer.DOM</code>:object containing XY coordinates in the DOM</li>
  2384. <li><code>pointer.canvas</code>:object containing XY coordinates in the canvas</li>
  2385. </ul>
  2386. </td>
  2387. </tr>
  2388. <tr>
  2389. <td>doubleClick</td>
  2390. <td>Fired after the user double clicks or double taps on a touchscreen.</td>
  2391. <td>
  2392. <ul>
  2393. <li><code>nodes</code>: an array with the ids of the selected nodes</li>
  2394. <li><code>edges</code>: an array with the ids of the selected edges</li>
  2395. <li><code>pointer.DOM</code>:object containing XY coordinates in the DOM</li>
  2396. <li><code>pointer.canvas</code>:object containing XY coordinates in the canvas</li>
  2397. </ul>
  2398. </td>
  2399. </tr>
  2400. <tr>
  2401. <tr>
  2402. <td>hoverNode</td>
  2403. <td>Fired when the mouse is moved over a node (assuming the hover option is enabled).</td>
  2404. <td>
  2405. <ul>
  2406. <li><code>node</code>: an object with the id of the hovered node.</li>
  2407. </ul>
  2408. </td>
  2409. </tr>
  2410. <tr>
  2411. <tr>
  2412. <td>blurNode</td>
  2413. <td>Fired when the mouse is moved off a node (assuming the hover option is enabled).</td>
  2414. <td>
  2415. <ul>
  2416. <li><code>node</code>: an object with the id of the hovered node.</li>
  2417. </ul>
  2418. </td>
  2419. </tr>
  2420. <tr>
  2421. <td>resize</td>
  2422. <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>
  2423. <td>
  2424. <ul>
  2425. <li><code>width</code>: the new width of the canvas</li>
  2426. <li><code>height</code>: the new height of the canvas</li>
  2427. <li><code>oldWidth</code>: the old width of the canvas</li>
  2428. <li><code>oldHeight</code>: the old height of the canvas</li>
  2429. </ul>
  2430. </td>
  2431. </tr>
  2432. <tr>
  2433. <td>dragStart</td>
  2434. <td>Fired when a node is being dragged.</td>
  2435. <td>
  2436. <ul>
  2437. <li><code>nodeIds</code>: Array of ids of the nodes that are being dragged</li>
  2438. </ul>
  2439. </td>
  2440. </tr>
  2441. <tr>
  2442. <td>dragEnd</td>
  2443. <td>Fired when the dragging of a node(s) has ended.</td>
  2444. <td>
  2445. <ul>
  2446. <li><code>nodeIds</code>: Array of ids of the nodes that were being dragged</li>
  2447. </ul>
  2448. </td>
  2449. </tr>
  2450. <tr>
  2451. <td>startStabilization</td>
  2452. <td>Fired once when the network starts the physics calculation. This ends with the stabilized event.
  2453. <td>
  2454. none
  2455. </td>
  2456. </tr>
  2457. <tr>
  2458. <td>stabilizationIterationsDone</td>
  2459. <td>Fired once when the network finished the initial stabilization run. This is fired REGARDLESS if the network has stabilized. It only means that the amount of configured stabilizationIterations have been completed.
  2460. <td>
  2461. none
  2462. </td>
  2463. </tr>
  2464. <tr>
  2465. <td>stabilized</td>
  2466. <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>
  2467. <td>
  2468. <ul>
  2469. <li><code>iterations</code>: number of iterations used to stabilize</li>
  2470. </ul>
  2471. </td>
  2472. </tr>
  2473. <tr>
  2474. <td>viewChanged</td>
  2475. <td>Fired when the view has changed. This is when the network has moved or zoomed.</td>
  2476. <td>
  2477. none
  2478. </td>
  2479. </tr>
  2480. <tr>
  2481. <td>zoom</td>
  2482. <td>Fired when the network has zoomed. This event can be used to trigger the .storePositions() function after stabilization.</td>
  2483. <td>
  2484. <ul>
  2485. <li><code>direction: </code> "+" or "-" </li>
  2486. </ul>
  2487. </td>
  2488. </tr>
  2489. </table>
  2490. <h2 id="Data_policy">Data policy</h2>
  2491. <p>
  2492. All code and data is processed and rendered in the browser.
  2493. No data is sent to any server.
  2494. </p>
  2495. </div>
  2496. </body>
  2497. </html>