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.

2456 lines
79 KiB

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