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.

2492 lines
81 KiB

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