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.

2404 lines
76 KiB

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