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.

1792 lines
53 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>vis.js | graph 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>Graph documentation</h1>
  12. <h2 id="Overview">Overview</h2>
  13. <p>
  14. Graph is a visualization to display graphs 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 graph visualization works smooth on any modern browser for up to a
  20. few hundred nodes and edges.
  21. </p>
  22. <p>
  23. To get started with Graph, install or download the
  24. <a href="http://visjs.org" target="_blank">vis.js</a> library.
  25. </p>
  26. <h2><a name="Contents"></a>Contents</h2>
  27. <ul>
  28. <li><a href="#Overview">Overview</a></li>
  29. <li><a href="#Example">Example</a></li>
  30. <li><a href="#Loading">Loading</a></li>
  31. <li>
  32. <a href="#Data_format">Data format</a>
  33. <ul>
  34. <li><a href="#Nodes">Nodes</a></li>
  35. <li><a href="#Edges">Edges</a></li>
  36. <li><a href="#DOT_language">DOT language</a></li>
  37. </ul>
  38. </li>
  39. <li>
  40. <a href="#Configuration_options">Configuration options</a>
  41. <ul>
  42. <li><a href="#Nodes_configuration">Nodes</a></li>
  43. <li><a href="#Edges_configuration">Edges</a></li>
  44. <li><a href="#Groups_configuration">Groups</a></li>
  45. <li><a href="#Physics">Physics</a></li>
  46. <li><a href="#Data_manipulation">Data_manipulation</a></li>
  47. <li><a href="#Clustering">Clustering</a></li>
  48. <li><a href="#Navigation_controls">Navigation controls</a></li>
  49. <li><a href="#Keyboard_navigation">Keyboard navigation</a></li>
  50. </ul>
  51. </li>
  52. <li><a href="#Methods">Methods</a></li>
  53. <li><a href="#Events">Events</a></li>
  54. <li><a href="#Data_policy">Data policy</a></li>
  55. </ul>
  56. <h2 id="Example">Example</h2>
  57. <p>
  58. Here a basic graph example. Note that unlike the
  59. <a href="timeline.html">Timeline</a>, the Graph does not need the vis.css
  60. file.
  61. </p>
  62. <p>
  63. More examples can be found in the
  64. <a href="../examples" target="_blank">examples directory</a>.
  65. </p>
  66. <pre class="prettyprint lang-html">&lt;!doctype html&gt;
  67. &lt;html&gt;
  68. &lt;head&gt;
  69. &lt;title&gt;Graph | Basic usage&lt;/title&gt;
  70. &lt;script type="text/javascript" src="../../dist/vis.js"&gt;&lt;/script&gt;
  71. &lt;/head&gt;
  72. &lt;body&gt;
  73. &lt;div id="mygraph"&gt;&lt;/div&gt;
  74. &lt;script type="text/javascript"&gt;
  75. // create an array with nodes
  76. var nodes = [
  77. {id: 1, label: 'Node 1'},
  78. {id: 2, label: 'Node 2'},
  79. {id: 3, label: 'Node 3'},
  80. {id: 4, label: 'Node 4'},
  81. {id: 5, label: 'Node 5'}
  82. ];
  83. // create an array with edges
  84. var edges = [
  85. {from: 1, to: 2},
  86. {from: 1, to: 3},
  87. {from: 2, to: 4},
  88. {from: 2, to: 5}
  89. ];
  90. // create a graph
  91. var container = document.getElementById('mygraph');
  92. var data= {
  93. nodes: nodes,
  94. edges: edges,
  95. };
  96. var options = {
  97. width: '400px',
  98. height: '400px'
  99. };
  100. var graph = new vis.Graph(container, data, options);
  101. &lt;/script&gt;
  102. &lt;/body&gt;
  103. &lt;/html&gt;
  104. </pre>
  105. <h2 id="Loading">Loading</h2>
  106. <p>
  107. Install or download the <a href="http://visjs.org" target="_blank">vis.js</a> library.
  108. in a subfolder of your project. Include the library script in the head of your html code:
  109. </p>
  110. <pre class="prettyprint lang-html">
  111. &lt;script type="text/javascript" src="vis/dist/vis.js"&gt;&lt;/script&gt;
  112. </pre>
  113. The constructor of the Graph is <code>vis.Graph</code>.
  114. <pre class="prettyprint lang-js">var graph = new vis.Graph(container, data, options);</pre>
  115. The constructor accepts three parameters:
  116. <ul>
  117. <li>
  118. <code>container</code> is the DOM element in which to create the graph.
  119. </li>
  120. <li>
  121. <code>data</code> is an Object containing properties <code>nodes</code> and
  122. <code>edges</code>, which both contain an array with objects.
  123. Optionally, data may contain an <code>options</code> object.
  124. The parameter <code>data</code> is optional, data can also be set using
  125. the method <code>setData</code>. Section <a href="#Data_Format">Data Format</a>
  126. describes the data object.
  127. </li>
  128. <li>
  129. <code>options</code> is an optional Object containing a name-value map
  130. with options. Options can also be set using the method
  131. <code>setOptions</code>.
  132. Section <a href="#Configuration_Options">Configuration Options</a>
  133. describes the available options.
  134. </li>
  135. </ul>
  136. <h2 id="Data_format">Data format</h2>
  137. <p>
  138. The <code>data</code> parameter of the Graph constructor is an object
  139. which can contain different types of data.
  140. The following properties are supported in the <code>data</code> object:
  141. </p>
  142. <ul>
  143. <li>
  144. <span style="font-weight: bold;">A property pair <code>nodes</code> and <code>edges</code></span>,
  145. both containing an Array with objects. The data formats are described
  146. in the sections <a href="#Nodes">Nodes</a> and <a href="#Edges">Edges</a>.
  147. Example:
  148. <pre class="prettyprint lang-js">
  149. var data = {
  150. nodes: [...],
  151. edges: [...]
  152. };
  153. </pre>
  154. </li>
  155. <li>
  156. <span style="font-weight: bold;">A property <code>dot</code></span>,
  157. containing a string with data in the
  158. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  159. DOT support is described in section <a href="#DOT_language">DOT_language</a>.
  160. Example:
  161. <pre class="prettyprint lang-js">
  162. var data = {
  163. dot: '...'
  164. };
  165. </pre>
  166. </li>
  167. <li>
  168. <span style="font-weight: bold;">A property <code>options</code></span>,
  169. containing an object with global options.
  170. Options can be provided as third parameter in the graph constructor
  171. as well. Section <a href="#Configuration_Options">Configuration Options</a>
  172. describes the available options.
  173. </li>
  174. </ul>
  175. <h3 id="Nodes">Nodes</h3>
  176. <p>
  177. Nodes typically have an <code>id</code> and <code>label</code>.
  178. A node must contain at least a property <code>id</code>.
  179. Nodes can have extra properties, used to define the shape and style of the
  180. nodes.
  181. </p>
  182. <p>
  183. A JavaScript Array with nodes is constructed like:
  184. </p>
  185. <pre class="prettyprint lang-js">
  186. var nodes = [
  187. {
  188. id: 1,
  189. label: 'Node 1'
  190. },
  191. // ... more nodes
  192. ];
  193. </pre>
  194. <p>
  195. Nodes support the following properties:
  196. </p>
  197. <table>
  198. <tr>
  199. <th>Name</th>
  200. <th>Type</th>
  201. <th>Required</th>
  202. <th>Description</th>
  203. </tr>
  204. <tr>
  205. <td>color</td>
  206. <td>String | Object</td>
  207. <td>no</td>
  208. <td>Color for the node.</td>
  209. </tr>
  210. <tr>
  211. <td>color.background</td>
  212. <td>String</td>
  213. <td>no</td>
  214. <td>Background color for the node.</td>
  215. </tr>
  216. <tr>
  217. <td>color.border</td>
  218. <td>String</td>
  219. <td>no</td>
  220. <td>Border color for the node.</td>
  221. </tr>
  222. <tr>
  223. <td>color.highlight</td>
  224. <td>String | Object</td>
  225. <td>no</td>
  226. <td>Color of the node when selected.</td>
  227. </tr>
  228. <tr>
  229. <td>color.highlight.background</td>
  230. <td>String</td>
  231. <td>no</td>
  232. <td>Background color of the node when selected.</td>
  233. </tr>
  234. <tr>
  235. <td>color.highlight.border</td>
  236. <td>String</td>
  237. <td>no</td>
  238. <td>Border color of the node when selected.</td>
  239. </tr>
  240. <tr>
  241. <td>group</td>
  242. <td>Number | String</td>
  243. <td>no</td>
  244. <td>A group number or name. The type can be <code>number</code>,
  245. <code>string</code>, or an other type. All nodes with the same group get
  246. the same color schema.</td>
  247. </tr>
  248. <tr>
  249. <td>fontColor</td>
  250. <td>String</td>
  251. <td>no</td>
  252. <td>Font color for label in the node.</td>
  253. </tr>
  254. <tr>
  255. <td>fontFace</td>
  256. <td>String</td>
  257. <td>no</td>
  258. <td>Font face for label in the node, for example "verdana" or "arial".</td>
  259. </tr>
  260. <tr>
  261. <td>fontSize</td>
  262. <td>Number</td>
  263. <td>no</td>
  264. <td>Font size in pixels for label in the node.</td>
  265. </tr>
  266. <tr>
  267. <td>id</td>
  268. <td>Number | String</td>
  269. <td>yes</td>
  270. <td>A unique id for this node.
  271. Nodes may not have duplicate id's.
  272. Id's do not need to be consecutive.
  273. An id is normally a number, but may be any type.</td>
  274. </tr>
  275. <tr>
  276. <td>image</td>
  277. <td>string</td>
  278. <td>no</td>
  279. <td>Url of an image. Only applicable when the shape of the node is
  280. <code>image</code>.</td>
  281. </tr>
  282. <tr>
  283. <td>radius</td>
  284. <td>number</td>
  285. <td>no</td>
  286. <td>Radius for the node. Applicable for all shapes except <code>box</code>,
  287. <code>circle</code>, <code>ellipse</code> and <code>database</code>.
  288. The value of <code>radius</code> will override a value in
  289. property <code>value</code>.</td>
  290. </tr>
  291. <tr>
  292. <td>shape</td>
  293. <td>string</td>
  294. <td>no</td>
  295. <td>Define the shape for the node.
  296. Choose from
  297. <code>ellipse</code> (default), <code>circle</code>, <code>box</code>,
  298. <code>database</code>, <code>image</code>, <code>label</code>, <code>dot</code>,
  299. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.
  300. <br><br>
  301. In case of <code>image</code>, a property with name <code>image</code> must
  302. be provided, containing image urls.
  303. <br><br>
  304. The shapes <code>dot</code>, <code>star</code>, <code>triangle</code>,
  305. <code>triangleDown</code>, and <code>square</code>, are scalable.
  306. The size is determined by the properties <code>radius</code> or
  307. <code>value</code>.
  308. <br><br>
  309. When a property <code>label</code> is provided,
  310. this label will be displayed inside the shape in case of shapes
  311. <code>box</code>, <code>circle</code>, <code>ellipse</code>,
  312. and <code>database</code>.
  313. For all other shapes, the label will be displayed right below the shape.
  314. </td>
  315. </tr>
  316. <tr>
  317. <td>label</td>
  318. <td>string</td>
  319. <td>no</td>
  320. <td>Text label to be displayed in the node or under the image of the node.
  321. Multiple lines can be separated by a newline character <code>\n</code> .</td>
  322. </tr>
  323. <tr>
  324. <td>title</td>
  325. <td>string</td>
  326. <td>no</td>
  327. <td>Title to be displayed when the user hovers over the node.
  328. The title can contain HTML code.</td>
  329. </tr>
  330. <tr>
  331. <td>value</td>
  332. <td>number</td>
  333. <td>no</td>
  334. <td>A value for the node.
  335. The radius of the nodes will be scaled automatically from minimum to
  336. maximum value.
  337. Only applicable when the shape of the node is <code>dot</code>.
  338. If a <code>radius</code> is provided for the node too, it will override the
  339. radius calculated from the value.</td>
  340. </tr>
  341. <tr>
  342. <td>x</td>
  343. <td>number</td>
  344. <td>no</td>
  345. <td>Horizontal position in pixels.
  346. The horizontal position of the node will be fixed.
  347. The vertical position y may remain undefined.</td>
  348. </tr>
  349. <tr>
  350. <td>y</td>
  351. <td>number</td>
  352. <td>no</td>
  353. <td>Vertical position in pixels.
  354. The vertical position of the node will be fixed.
  355. The horizontal position x may remain undefined.</td>
  356. </tr>
  357. </table>
  358. <h3 id="Edges">Edges</h3>
  359. <p>
  360. Edges are connections between nodes.
  361. An edge must at least contain properties <code>from</code> and
  362. <code>to</code>, both referring to the <code>id</code> of a node.
  363. Edges can have extra properties, used to define the type and style.
  364. </p>
  365. <p>
  366. A JavaScript Array with edges is constructed as:
  367. </p>
  368. <pre class="prettyprint lang-js">
  369. var edges = [
  370. {
  371. from: 1,
  372. to: 3
  373. },
  374. // ... more edges
  375. ];
  376. </pre>
  377. <p>
  378. Edges support the following properties:
  379. </p>
  380. <table>
  381. <tr>
  382. <th>Name</th>
  383. <th>Type</th>
  384. <th>Required</th>
  385. <th>Description</th>
  386. </tr>
  387. <tr>
  388. <td>color</td>
  389. <td>string</td>
  390. <td>no</td>
  391. <td>A HTML color for the edge.</td>
  392. </tr>
  393. <tr>
  394. <td>dash</td>
  395. <td>Object</td>
  396. <td>no</td>
  397. <td>
  398. Object containing properties for dashed lines.
  399. Available properties: <code>length</code>, <code>gap</code>,
  400. <code>altLength</code>.
  401. </td>
  402. </tr>
  403. <tr>
  404. <td>dash.altLength</td>
  405. <td>number</td>
  406. <td>no</td>
  407. <td>Length of the alternated dash in pixels on a dashed line.
  408. Specifying <code>dash.altLength</code> allows for creating
  409. a dashed line with a dash-dot style, for example when
  410. <code>dash.length=10</code> and <code>dash.altLength=5</code>.
  411. See also the option <code>dahs.length</code>.
  412. Only applicable when the line style is <code>dash-line</code>.</td>
  413. </tr>
  414. <tr>
  415. <td>dash.length</td>
  416. <td>number</td>
  417. <td>no</td>
  418. <td>Length of a dash in pixels on a dashed line.
  419. Only applicable when the line style is <code>dash-line</code>.</td>
  420. </tr>
  421. <tr>
  422. <td>dash.gap</td>
  423. <td>number</td>
  424. <td>no</td>
  425. <td>Length of a gap in pixels on a dashed line.
  426. Only applicable when the line style is <code>dash-line</code>.</td>
  427. </tr>
  428. <tr>
  429. <td>fontColor</td>
  430. <td>String</td>
  431. <td>no</td>
  432. <td>Font color for the text label of the edge.
  433. Only applicable when property <code>label</code> is defined.</td>
  434. </tr>
  435. <tr>
  436. <td>fontFace</td>
  437. <td>String</td>
  438. <td>no</td>
  439. <td>Font face for the text label of the edge,
  440. for example "verdana" or "arial".
  441. Only applicable when property <code>label</code> is defined.</td>
  442. </tr>
  443. <tr>
  444. <td>fontSize</td>
  445. <td>Number</td>
  446. <td>no</td>
  447. <td>Font size in pixels for the text label of the edge.
  448. Only applicable when property <code>label</code> is defined.</td>
  449. </tr>
  450. <tr>
  451. <td>from</td>
  452. <td>Number | String</td>
  453. <td>yes</td>
  454. <td>The id of a node where the edge starts. The type must correspond with
  455. the type of the node id's. This is normally a number, but can be any
  456. type.</td>
  457. </tr>
  458. <tr>
  459. <td>style</td>
  460. <td>string</td>
  461. <td>no</td>
  462. <td>Define a line style for the edge.
  463. Choose from <code>line</code> (default), <code>arrow</code>,
  464. <code>arrow-center</code>, or <code>dash-line</code>.
  465. </td>
  466. </tr>
  467. <tr>
  468. <td>label</td>
  469. <td>string</td>
  470. <td>no</td>
  471. <td>Text label to be displayed halfway the edge.</td>
  472. </tr>
  473. <tr>
  474. <td>title</td>
  475. <td>string</td>
  476. <td>no</td>
  477. <td>Title to be displayed when the user hovers over the edge.
  478. The title can contain HTML code.</td>
  479. </tr>
  480. <tr>
  481. <td>to</td>
  482. <td>Number | String</td>
  483. <td>yes</td>
  484. <td>The id of a node where the edge ends. The type must correspond with
  485. the type of the node id's. This is normally a number, but can be any
  486. type.</td>
  487. </tr>
  488. <tr>
  489. <td>value</td>
  490. <td>number</td>
  491. <td>no</td>
  492. <td>A value for the edge.
  493. The width of the edges will be scaled automatically from minimum to
  494. maximum value.
  495. If a <code>width</code> is provided for the edge too, it will override the
  496. width calculated from the value.</td>
  497. </tr>
  498. <tr>
  499. <td>width</td>
  500. <td>number</td>
  501. <td>no</td>
  502. <td>Width of the line in pixels. The <code>width</code> will
  503. override a specified <code>value</code>, if a <code>value</code> is
  504. specified too.</td>
  505. </tr>
  506. </table>
  507. <h3 id="DOT_language">DOT language</h3>
  508. <p>
  509. Graph supports data in the
  510. <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT language</a>.
  511. To provide data in the DOT language, the <code>data</code> object must contain
  512. a property <code>dot</code> with a String containing the data.
  513. </p>
  514. <p>
  515. Example usage:
  516. </p>
  517. <pre class="prettyprint lang-js">
  518. // provide data in the DOT language
  519. var data = {
  520. dot: 'digraph {1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }'
  521. };
  522. // create a graph
  523. var graph = new vis.Graph(container, data);
  524. </pre>
  525. <h2 id="Configuration_options">Configuration options</h2>
  526. <p>
  527. Options can be used to customize the graph. Options are defined as a JSON object.
  528. All options are optional.
  529. </p>
  530. <pre class="prettyprint lang-js">
  531. var options = {
  532. width: '100%',
  533. height: '400px',
  534. edges: {
  535. color: 'red',
  536. width: 2
  537. }
  538. };
  539. </pre>
  540. <p>
  541. The following options are available.
  542. </p>
  543. <table>
  544. <tr>
  545. <th>Name</th>
  546. <th>Type</th>
  547. <th>Default</th>
  548. <th>Description</th>
  549. </tr>
  550. <tr>
  551. <td><a href="#Physics">physics</a></td>
  552. <td>Object</td>
  553. <td>none</td>
  554. <td>
  555. Configuration of the physics system governing the simulation of the nodes and edges.
  556. Barnes-Hut nBody simulation is used by default. See section <a href="#Physics">Physics</a> for an overview of the available options.
  557. </td>
  558. </tr>
  559. <tr>
  560. <td><a href="#Data_manipulation">dataManipulation</a></td>
  561. <td>Object</td>
  562. <td>none</td>
  563. <td>
  564. Settings for manipulating the Dataset. See section <a href="#Data_manipulation">Data manipulation</a> for an overview of the available options.
  565. </td>
  566. </tr>
  567. <tr>
  568. <td><a href="#Clustering">clustering</a></td>
  569. <td>Object</td>
  570. <td>none</td>
  571. <td>
  572. Clustering configuration. Clustering is turned off by default. See section <a href="#Clustering">Clustering</a> for an overview of the available options.
  573. </td>
  574. </tr>
  575. <tr>
  576. <td><a href="#Edges_configuration">edges</a></td>
  577. <td>Object</td>
  578. <td>none</td>
  579. <td>
  580. Configuration options applied to all edges. See section <a href="#Edges_configuration">Edges configuration</a> for an overview of the available options.
  581. </td>
  582. </tr>
  583. <tr>
  584. <td><a href="#Groups_configuration">groups</a></td>
  585. <td>Object</td>
  586. <td>none</td>
  587. <td>It is possible to specify custom styles for groups.
  588. Each node assigned a group gets the specified style.
  589. See <a href="#Groups_configuration">Groups configuration</a> for an overview of the available styles
  590. and an example.
  591. </td>
  592. </tr>
  593. <tr>
  594. <td>height</td>
  595. <td>String</td>
  596. <td>"400px"</td>
  597. <td>The height of the graph in pixels or as a percentage.</td>
  598. </tr>
  599. <tr>
  600. <td><a href="#Keyboard_navigation">keyboard</a></td>
  601. <td>Object</td>
  602. <td>none</td>
  603. <td>
  604. Configuration options for shortcuts keys. Sortcut keys are turned off by default. See section <a href="#Keyboard_navigation">Keyboard navigation</a> for an overview of the available options.
  605. </td>
  606. </tr>
  607. <tr>
  608. <td><a href="#Navigation_controls">navigation</a></td>
  609. <td>Object</td>
  610. <td>none</td>
  611. <td>
  612. Configuration options for the navigation controls. See section <a href="#Navigation_controls">Navigation controls</a> for an overview of the available options.
  613. </td>
  614. </tr>
  615. <tr>
  616. <td><a href="#Nodes_configuration">nodes</a></td>
  617. <td>Object</td>
  618. <td>none</td>
  619. <td>
  620. Configuration options applied to all nodes. See section <a href="#Nodes_configuration">Nodes configuration</a> for an overview of the available options.
  621. </td>
  622. </tr>
  623. <tr>
  624. <td>smoothCurves</td>
  625. <td>Boolean</td>
  626. <td>true</td>
  627. <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>
  628. </tr>
  629. <tr>
  630. <td>selectable</td>
  631. <td>Boolean</td>
  632. <td>true</td>
  633. <td>If true, nodes in the graph can be selected by clicking them.
  634. Long press can be used to select multiple nodes.</td>
  635. </tr>
  636. <tr>
  637. <td>stabilize</td>
  638. <td>Boolean</td>
  639. <td>true</td>
  640. <td>If true, the graph is stabilized before displaying it. If false,
  641. the nodes move to a stabe position visibly in an animated way.</td>
  642. </tr>
  643. <tr>
  644. <td>width</td>
  645. <td>String</td>
  646. <td>"400px"</td>
  647. <td>The width of the graph in pixels or as a percentage.</td>
  648. </tr>
  649. </table>
  650. <br>
  651. <h3 id="Nodes_configuration">Nodes configuration</h3>
  652. <p>
  653. 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 Graph.
  654. </p>
  655. <p>
  656. For example to give the nodes a custom color, shape, and size:
  657. </p>
  658. <pre class="prettyprint lang-js">
  659. var options = {
  660. // ...
  661. nodes: {
  662. color: {
  663. background: 'white',
  664. border: 'red',
  665. highlight: {
  666. background: 'pink',
  667. border: 'red'
  668. }
  669. },
  670. shape: 'star',
  671. radius: 24
  672. }
  673. };
  674. </pre>
  675. <p>
  676. The following options are available for nodes. These options must be created
  677. inside an object <code>nodes</code> in the graphs options object.</p>
  678. <table>
  679. <tr>
  680. <td>color</td>
  681. <td>String | Object</td>
  682. <td>Object</td>
  683. <td>Default color of the nodes. When color is a string, the color is applied
  684. to both background as well as the border of the node.</td>
  685. </tr>
  686. <tr>
  687. <td>color.background</td>
  688. <td>String</td>
  689. <td>"#97C2FC"</td>
  690. <td>Default background color of the nodes</td>
  691. </tr>
  692. <tr>
  693. <td>color.border</td>
  694. <td>String</td>
  695. <td>"#2B7CE9"</td>
  696. <td>Default border color of the nodes</td>
  697. </tr>
  698. <tr>
  699. <td>color.highlight</td>
  700. <td>String | Object</td>
  701. <td>Object</td>
  702. <td>Default color of the node when the node is selected. In case of a string, the color is applied to
  703. both border and background of the node.</td>
  704. </tr>
  705. <tr>
  706. <td>color.highlight.background</td>
  707. <td>String</td>
  708. <td>"#D2E5FF"</td>
  709. <td>Default background color of the node when selected.</td>
  710. </tr>
  711. <tr>
  712. <td>color.highlight.border</td>
  713. <td>String</td>
  714. <td>"#2B7CE9"</td>
  715. <td>Default border color of the node when selected.</td>
  716. </tr>
  717. <tr>
  718. <td>fontColor</td>
  719. <td>String</td>
  720. <td>"black"</td>
  721. <td>Default font color for the text label in the nodes.</td>
  722. </tr>
  723. <tr>
  724. <td>fontFace</td>
  725. <td>String</td>
  726. <td>"sans"</td>
  727. <td>Default font face for the text label in the nodes, for example "verdana" or "arial".</td>
  728. </tr>
  729. <tr>
  730. <td>fontSize</td>
  731. <td>Number</td>
  732. <td>14</td>
  733. <td>Default font size in pixels for the text label in the nodes.</td>
  734. </tr>
  735. <tr>
  736. <td>group</td>
  737. <td>String</td>
  738. <td>none</td>
  739. <td>Default group for the nodes.</td>
  740. </tr>
  741. <tr>
  742. <td>image</td>
  743. <td>String</td>
  744. <td>none</td>
  745. <td>Default image url for the nodes. only applicable to shape <code>image</code>.</td>
  746. </tr>
  747. <tr>
  748. <td>widthMin</td>
  749. <td>Number</td>
  750. <td>16</td>
  751. <td>The minimum width for a scaled image. Only applicable to shape <code>image</code>.</td>
  752. </tr>
  753. <tr>
  754. <td>widthMax</td>
  755. <td>Number</td>
  756. <td>64</td>
  757. <td>The maximum width for a scaled image. Only applicable to shape <code>image</code>.</td>
  758. </tr>
  759. <tr>
  760. <td>shape</td>
  761. <td>String</td>
  762. <td>"ellipse"</td>
  763. <td>The default shape for all nodes.
  764. Choose from
  765. <code>ellipse</code> (default), <code>circle</code>, <code>box</code>,
  766. <code>database</code>, <code>image</code>, <code>label</code>, <code>dot</code>,
  767. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.
  768. This shape can be overridden by a group shape, or by a shape of an individual node.</td>
  769. </tr>
  770. <tr>
  771. <td>radius</td>
  772. <td>Number</td>
  773. <td>5</td>
  774. <td>The default radius for a node. Only applicable to shapes <code>dot</code>,
  775. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.</td>
  776. </tr>
  777. <tr>
  778. <td>radiusMin</td>
  779. <td>Number</td>
  780. <td>5</td>
  781. <td>The minimum radius for a scaled node. Only applicable to shapes <code>dot</code>,
  782. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.</td>
  783. </tr>
  784. <tr>
  785. <td>radiusMax</td>
  786. <td>Number</td>
  787. <td>20</td>
  788. <td>The maximum radius for a scaled node. Only applicable to shapes <code>dot</code>,
  789. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.</td>
  790. </tr>
  791. </table>
  792. <h3 id="Edges_configuration">Edges configuration</h3>
  793. <p>
  794. 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 Graph.
  795. </p>
  796. <p>
  797. For example to set the width of all edges to 2 pixels and give them a red color:
  798. </p>
  799. <pre class="prettyprint lang-js">
  800. var options = {
  801. // ...
  802. edges: {
  803. color: 'red',
  804. width: 2
  805. }
  806. };
  807. </pre>
  808. <p>
  809. The following options are available for edges. These options must be created
  810. inside an object <code>edges</code> in the graphs options object.
  811. </p>
  812. <table>
  813. <tr>
  814. <th>Name</th>
  815. <th>Type</th>
  816. <th>Default</th>
  817. <th>Description</th>
  818. </tr>
  819. <tr>
  820. <td>color</td>
  821. <td>String</td>
  822. <td>"#2B7CE9"</td>
  823. <td>The default color of a edge.</td>
  824. </tr>
  825. <tr>
  826. <td>dash</td>
  827. <td>Object</td>
  828. <td>Object</td>
  829. <td>
  830. Object containing default properties for dashed lines.
  831. Available properties: <code>length</code>, <code>gap</code>,
  832. <code>altLength</code>.
  833. </td>
  834. </tr>
  835. <tr>
  836. <td>dash.altLength</td>
  837. <td>number</td>
  838. <td>none</td>
  839. <td>Default length of the alternated dash in pixels on a dashed line.
  840. Specifying <code>dash.altLength</code> allows for creating
  841. a dashed line with a dash-dot style, for example when
  842. <code>dash.length=10</code> and <code>dash.altLength=5</code>.
  843. See also the option <code>dahs.length</code>.
  844. Only applicable when the line style is <code>dash-line</code>.</td>
  845. </tr>
  846. <tr>
  847. <td>dash.length</td>
  848. <td>number</td>
  849. <td>10</td>
  850. <td>Default length of a dash in pixels on a dashed line.
  851. Only applicable when the line style is <code>dash-line</code>.</td>
  852. </tr>
  853. <tr>
  854. <td>dash.gap</td>
  855. <td>number</td>
  856. <td>5</td>
  857. <td>Default length of a gap in pixels on a dashed line.
  858. Only applicable when the line style is <code>dash-line</code>.</td>
  859. </tr>
  860. <tr>
  861. <td>style</td>
  862. <td>String</td>
  863. <td>"line"</td>
  864. <td>The default style of a edge.
  865. Choose from <code>line</code> (default), <code>arrow</code>,
  866. <code>arrow-center</code>, <code>dash-line</code>.</td>
  867. </tr>
  868. <tr>
  869. <td>width</td>
  870. <td>Number</td>
  871. <td>1</td>
  872. <td>The default width of a edge.</td>
  873. </tr>
  874. </table>
  875. <h3 id="Groups_configuration">Groups configuration</h3>
  876. <p>It is possible to specify custom styles for groups of nodes.
  877. Each node having assigned to this group gets the specified style.
  878. The options <code>groups</code> is an object containing one or multiple groups,
  879. identified by a unique string, the groupname.
  880. </p>
  881. <p>
  882. A group can have the following styles:
  883. </p>
  884. <pre class="prettyprint lang-js">
  885. var options = {
  886. // ...
  887. groups: {
  888. mygroup: {
  889. shape: 'circle',
  890. color: {
  891. border: 'black',
  892. background: 'white',
  893. highlight: {
  894. border: 'yellow',
  895. background: 'orange'
  896. }
  897. }
  898. fontColor: 'red',
  899. fontSize: 18
  900. }
  901. // add more groups here
  902. }
  903. };
  904. var nodes = [
  905. {id: 1, label: 'Node 1'}, // will get the default style
  906. {id: 2, label: 'Node 2', group: 'mygroup'}, // will get the style from 'mygroup'
  907. // ... more nodes
  908. ];
  909. </pre>
  910. <p>The following styles are available for groups:</p>
  911. <table>
  912. <tr>
  913. <th>Name</th>
  914. <th>Type</th>
  915. <th>Default</th>
  916. <th>Description</th>
  917. </tr>
  918. <tr>
  919. <td>color</td>
  920. <td>String | Object</td>
  921. <td>Object</td>
  922. <td>Color of the node</td>
  923. </tr>
  924. <tr>
  925. <td>color.border</td>
  926. <td>String</td>
  927. <td>"#2B7CE9"</td>
  928. <td>Border color of the node</td>
  929. </tr>
  930. <tr>
  931. <td>color.background</td>
  932. <td>String</td>
  933. <td>"#97C2FC"</td>
  934. <td>Background color of the node</td>
  935. </tr>
  936. <tr>
  937. <td>color.highlight</td>
  938. <td>String | Object</td>
  939. <td>"#D2E5FF"</td>
  940. <td>Default color of the node when the node is selected. In case of a string, the color is applied to
  941. both border and background of the node.</td>
  942. </tr>
  943. <tr>
  944. <td>color.highlight.background</td>
  945. <td>String</td>
  946. <td>"#D2E5FF"</td>
  947. <td>Background color of the node when selected.</td>
  948. </tr>
  949. <tr>
  950. <td>color.highlight.border</td>
  951. <td>String</td>
  952. <td>"#D2E5FF"</td>
  953. <td>Border color of the node when selected.</td>
  954. </tr>
  955. <tr>
  956. <td>image</td>
  957. <td>String</td>
  958. <td>none</td>
  959. <td>Default image for the nodes. Only applicable in combination with
  960. shape <code>image</code>.</td>
  961. </tr>
  962. <tr>
  963. <td>fontColor</td>
  964. <td>String</td>
  965. <td>"black"</td>
  966. <td>Font color of the node.</td>
  967. </tr>
  968. <tr>
  969. <td>fontFace</td>
  970. <td>String</td>
  971. <td>"sans"</td>
  972. <td>Font name of the node, for example "verdana" or "arial".</td>
  973. </tr>
  974. <tr>
  975. <td>fontSize</td>
  976. <td>Number</td>
  977. <td>14</td>
  978. <td>Font size for the node in pixels.</td>
  979. </tr>
  980. <tr>
  981. <td>shape</td>
  982. <td>String</td>
  983. <td>"ellipse"</td>
  984. <td>Choose from
  985. <code>ellipse</code> (default), <code>circle</code>, <code>box</code>,
  986. <code>database</code>, <code>image</code>, <code>label</code>, <code>dot</code>,
  987. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, and <code>square</code>.
  988. In case of image, a property with name image must be provided, containing
  989. image urls.</td>
  990. </tr>
  991. <tr>
  992. <td>radius</td>
  993. <td>Number</td>
  994. <td>5</td>
  995. <td>Default radius for the node. Only applicable in combination with
  996. shapes <code>box</code> and <code>dot</code>.</td>
  997. </tr>
  998. </table>
  999. <h3 id="Physics">Physics</h3>
  1000. <p>
  1001. The physics system has been overhauled to increase performance. The original simulation method was based on particel physics with a repulsion field (potential) around each node,
  1002. 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.
  1003. 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.
  1004. If no options for the physics system are supplied, the Barnes-Hut method will be used with the default parameters.
  1005. </p>
  1006. <pre class="prettyprint">
  1007. // These variables must be defined in an options object named physics.
  1008. // If a variable is not supplied, the default value is used.
  1009. var options = {
  1010. physics: {
  1011. barnesHut: {
  1012. enabled: true,
  1013. gravitationalConstant: -2000,
  1014. centralGravity: 0.1,
  1015. springLength: 100,
  1016. springConstant: 0.05,
  1017. damping: 0.09
  1018. },
  1019. repulsion: {
  1020. centralGravity: 0.1,
  1021. springLength: 50,
  1022. springConstant: 0.05,
  1023. nodeDistance: 100,
  1024. damping: 0.09
  1025. },
  1026. }
  1027. </pre>
  1028. <h5>barnesHut:</h5>
  1029. <table>
  1030. <tr>
  1031. <th>Name</th>
  1032. <th>Type</th>
  1033. <th>Default</th>
  1034. <th>Description</th>
  1035. </tr>
  1036. <tr>
  1037. <td>enabled</td>
  1038. <td>Boolean</td>
  1039. <td>true</td>
  1040. <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>
  1041. </tr>
  1042. <tr>
  1043. <td>gravitationalConstant</td>
  1044. <td>Number</td>
  1045. <td>-2000</td>
  1046. <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>
  1047. </tr>
  1048. <tr>
  1049. <td>centralGravity</td>
  1050. <td>Number</td>
  1051. <td>0.1</td>
  1052. <td>The central gravity is a force that pulls all nodes to the center. This ensures independent groups do not float apart.</td>
  1053. </tr>
  1054. <tr>
  1055. <td>springLength</td>
  1056. <td>Number</td>
  1057. <td>100</td>
  1058. <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.
  1059. To greatly reduce the edge length, the gravitationalConstant has to be reduced as well.</td>
  1060. </tr>
  1061. <tr>
  1062. <td>springConstant</td>
  1063. <td>Number</td>
  1064. <td>0.05</td>
  1065. <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>
  1066. </tr>
  1067. <tr>
  1068. <td>damping</td>
  1069. <td>Number</td>
  1070. <td>0.09</td>
  1071. <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>
  1072. </tr>
  1073. </table>
  1074. <h5>repulsion:</h5>
  1075. <table>
  1076. <tr>
  1077. <th>Name</th>
  1078. <th>Type</th>
  1079. <th>Default</th>
  1080. <th>Description</th>
  1081. </tr>
  1082. <tr>
  1083. <td>centralGravity</td>
  1084. <td>Number</td>
  1085. <td>0.1</td>
  1086. <td>The central gravity is a force that pulls all nodes to the center. This ensures independent groups do not float apart.</td>
  1087. </tr>
  1088. <tr>
  1089. <td>springLength</td>
  1090. <td>Number</td>
  1091. <td>50</td>
  1092. <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.
  1093. To greatly reduce the edge length, the gravitationalConstant has to be reduced as well.</td>
  1094. </tr>
  1095. <tr>
  1096. <td>nodeDistance</td>
  1097. <td>Number</td>
  1098. <td>100</td>
  1099. <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>
  1100. </tr>
  1101. <tr>
  1102. <td>springConstant</td>
  1103. <td>Number</td>
  1104. <td>0.05</td>
  1105. <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>
  1106. </tr>
  1107. <tr>
  1108. <td>damping</td>
  1109. <td>Number</td>
  1110. <td>0.09</td>
  1111. <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>
  1112. </tr>
  1113. </table>
  1114. <h3 id="Data_manipulation">Data manipulation</h3>
  1115. <p>
  1116. By using the data manipulation feature of the graph you can dynamically create nodes, connect nodes with edges, edit nodes or delete nodes and edges.
  1117. 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
  1118. 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/graph/21_data_manipulation.html">example 21</a>,
  1119. two functions have been injected into the add and edit functionality. This is described in more detail in the next subsection.
  1120. </p>
  1121. <pre class="prettyprint">
  1122. // These variables must be defined in an options object named dataManipulation.
  1123. // If a variable is not supplied, the default value is used.
  1124. var options = {
  1125. dataManipulation: {
  1126. enabled: false,
  1127. initiallyVisible: false
  1128. }
  1129. }
  1130. // OR to just load the module with default values:
  1131. var options: {
  1132. dataManipulation: true
  1133. }
  1134. </pre>
  1135. <table>
  1136. <tr>
  1137. <th>Name</th>
  1138. <th>Type</th>
  1139. <th>Default</th>
  1140. <th>Description</th>
  1141. </tr>
  1142. <tr>
  1143. <td>enabled</td>
  1144. <td>Boolean</td>
  1145. <td>false</td>
  1146. <td>Enabling or disabling of the data manipulation toolbar. If it is initially hidden, an edit button appears in the top left corner.</td>
  1147. </tr>
  1148. <tr>
  1149. <td>initiallyVisible</td>
  1150. <td>Boolean</td>
  1151. <td>false</td>
  1152. <td>Initially hide or show the data manipulation toolbar.</td>
  1153. </tr>
  1154. </table>
  1155. <h4 id="Data_manipulation_custom">Data manipulation: custom functionality</h4>
  1156. <p>
  1157. 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.
  1158. If the callback is NOT called, nothing happens. <a href="../examples/graph/21_data_manipulation.html">Example 21</a> has two working examples
  1159. for the add and edit functions. The data the user is supplied with in these functions has been described in the code below.
  1160. 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
  1161. 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
  1162. requires the same data structure that is supplied to the user. <br /><br />
  1163. <b>If there is no injected function supplied for the edit operation, the button will not be shown in the toolbar.</b>
  1164. </p>
  1165. <pre class="prettyprint">
  1166. // If a variable is not supplied, the default value is used.
  1167. var options: {
  1168. dataManipulation: true,
  1169. onAdd: function(data,callback) {
  1170. // fixed must be false because we define a set x and y position.
  1171. // If fixed is not false, the node cannot move.
  1172. /** data = {id: random unique id,
  1173. * label: new,
  1174. * x: x position of click (canvas space),
  1175. * y: y position of click (canvas space),
  1176. * fixed: false
  1177. * };
  1178. */
  1179. var newData = {..}; // alter the data as you want.
  1180. // all fields normally accepted by a node can be used.
  1181. callback(newData); // call the callback to add a node.
  1182. },
  1183. onEdit: function(data,callback) {
  1184. /** data = {id:...,
  1185. * label: ...,
  1186. * group: ...,
  1187. * shape: ...,
  1188. * color: {
  1189. * background:...,
  1190. * border:...,
  1191. * highlight: {
  1192. * background:...,
  1193. * border:...
  1194. * }
  1195. * }
  1196. * };
  1197. */
  1198. var newData = {..}; // alter the data as you want.
  1199. // all fields normally accepted by a node can be used.
  1200. callback(newData); // call the callback with the new data to edit the node.
  1201. }
  1202. onConnect: function(data,callback) {
  1203. // data = {from: nodeId1, to: nodeId2};
  1204. var newData = {..}; // check or alter data as you see fit.
  1205. callback(newData); // call the callback to connect the nodes.
  1206. },
  1207. onDelete: function(data,callback) {
  1208. // data = {nodes: [selectedNodeIds], edges: [selectedEdgeIds]};
  1209. var newData = {..}; // alter the data as you want.
  1210. // the same data structure is required.
  1211. callback(newData); // call the callback to delete the objects.
  1212. }
  1213. };
  1214. </pre>
  1215. <p>
  1216. 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 frameResize.
  1217. 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.
  1218. An code snippet from example 21 is shown below.
  1219. </p>
  1220. <pre class="prettyprint">
  1221. graph.on("frameResize", function(params) {console.log(params.width,params.height)});
  1222. </pre>
  1223. <h3 id="Clustering">Clustering</h3>
  1224. <p>
  1225. The graph now supports dynamic clustering of nodes. This allows a user to view a very large dataset (> 50.000 nodes) without
  1226. sacrificing performance. When loading a large dataset, the nodes are clustered initially (this may take a small while) to have a
  1227. responsive visualization to work with. The clustering is both outside-in and inside-out. Outside-in means that nodes with only one
  1228. connection will be contained, or clustered, in the node it is connected to. Inside-out clustering first determines which nodes are hubs.
  1229. Hubs are defined as the nodes with the top 3% highest amount of connections (assuming normal distribution). These hubs then "grow", meaning
  1230. 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.
  1231. <br />
  1232. <br />
  1233. 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
  1234. to calculate the required forces. The contained nodes are removed from the global nodes index, greatly speeding up the system.
  1235. <br />
  1236. <br />
  1237. The clustering has the following user-configurable settings. The default values have been tested with the Graph examples and work well.
  1238. The default state for clustering is <b>off</b>.
  1239. </p>
  1240. <pre class="prettyprint">
  1241. // These variables must be defined in an options object named clustering.
  1242. // If a variable is not supplied, the default value is used.
  1243. var options = {
  1244. clustering: {
  1245. initialMaxNodes: 100,
  1246. clusterThreshold:500,
  1247. reduceToNodes:300,
  1248. chainThreshold: 0.4,
  1249. clusterEdgeThreshold: 20,
  1250. sectorThreshold: 100,
  1251. screenSizeThreshold: 0.2,
  1252. fontSizeMultiplier: 4.0,
  1253. maxFontSize: 1000,
  1254. forceAmplification: 0.1,
  1255. distanceAmplification: 0.1,
  1256. edgeGrowth: 20,
  1257. nodeScaling: {width: 1,
  1258. height: 1,
  1259. radius: 1},
  1260. maxNodeSizeIncrements: 600,
  1261. activeAreaBoxSize: 100,
  1262. clusterLevelDifference: 2
  1263. }
  1264. }
  1265. // OR to just load the module with default values:
  1266. var options: {
  1267. clustering: true
  1268. }
  1269. </pre>
  1270. <table>
  1271. <tr>
  1272. <th>Name</th>
  1273. <th>Type</th>
  1274. <th>Default</th>
  1275. <th>Description</th>
  1276. </tr>
  1277. <tr>
  1278. <td>initialMaxNodes</td>
  1279. <td>Number</td>
  1280. <td>100</td>
  1281. <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>
  1282. </tr>
  1283. <tr>
  1284. <td>clusterThreshold</td>
  1285. <td>Number</td>
  1286. <td>500</td>
  1287. <td>While zooming in and out, clusters can open up. Once there are more than <code>absoluteMaxNumberOfNodes</code> nodes,
  1288. clustering starts until <code>reduceToMaxNumberOfNodes</code> nodes are left. This is done to ensure performance is continuously fluid.</td>
  1289. </tr>
  1290. <tr>
  1291. <td>reduceToNodes</td>
  1292. <td>Number</td>
  1293. <td>300</td>
  1294. <td>While zooming in and out, clusters can open up. Once there are more than <code>absoluteMaxNumberOfNodes</code> nodes,
  1295. clustering starts until <code>reduceToMaxNumberOfNodes</code> nodes are left. This is done to ensure performance is continiously fluid.</td>
  1296. </tr>
  1297. <tr>
  1298. <td>chainThreshold</td>
  1299. <td>Number</td>
  1300. <td>0.4</td>
  1301. <td>Because of the clustering methods used, long chains of nodes can be formed. To reduce these chains, this threshold is used.
  1302. 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).
  1303. If there are more, they are clustered together.</td>
  1304. </tr>
  1305. <tr>
  1306. <td>clusterEdgeThreshold</td>
  1307. <td>Number</td>
  1308. <td>20</td>
  1309. <td>This is the absolute edge length threshold in pixels. If the edge is smaller on screen (that means zooming out reduces this length)
  1310. the node will be clustered. This is triggered when zooming out.</td>
  1311. </tr>
  1312. <tr>
  1313. <td>sectorThreshold</td>
  1314. <td>Integer</td>
  1315. <td>50</td>
  1316. <td>If a cluster larger than <code>sectorThreshold</code> is opened, a seperate instance called a sector, will be created. All the simulation of
  1317. nodes outside of this instance will be paused. This is to maintain performance and clarity when examining large clusters.
  1318. 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>
  1319. </tr>
  1320. <tr>
  1321. <td>screenSizeThreshold</td>
  1322. <td>Number</td>
  1323. <td>0.2</td>
  1324. <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
  1325. 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
  1326. 20%, we collapse this sector.</td>
  1327. </tr>
  1328. <tr>
  1329. <td>fontSizeMultiplier</td>
  1330. <td>Number</td>
  1331. <td>4.0</td>
  1332. <td>This parameter denotes the increase in fontSize of the cluster when a single node is added to it.</td>
  1333. </tr>
  1334. <tr>
  1335. <td>maxFontSize</td>
  1336. <td>Number</td>
  1337. <td>1000</td>
  1338. <td>This parameter denotes the largest allowed font size. If the font becomes too large, some browsers experience problems displaying this.</td>
  1339. </tr>
  1340. <tr>
  1341. <td>forceAmplification</td>
  1342. <td>Number</td>
  1343. <td>0.6</td>
  1344. <td>This factor is used to calculate the increase of the repulsive force of a cluster. It is calculated by the following
  1345. formula: <code>repulsingForce *= 1 + (clusterSize * forceAmplification)</code>.</td>
  1346. </tr>
  1347. <tr>
  1348. <td>distanceAmplification</td>
  1349. <td>Number</td>
  1350. <td>0.2</td>
  1351. <td>This factor is used to calculate the increase in effective range of the repulsive force of the cluster.
  1352. A larger cluster has a longer range. It is calculated by the following
  1353. formula: <code>minDistance *= 1 + (clusterSize * distanceAmplification)</code>.</td>
  1354. </tr>
  1355. <tr>
  1356. <td>edgeGrowth</td>
  1357. <td>Number</td>
  1358. <td>20</td>
  1359. <td>This factor determines the elongation of edges connected to a cluster.</td>
  1360. </tr>
  1361. <tr>
  1362. <td>nodeScaling.width</td>
  1363. <td>Number</td>
  1364. <td>10</td>
  1365. <td>This factor determines how much the width of a cluster increases in pixels per added node.</td>
  1366. </tr>
  1367. <tr>
  1368. <td>nodeScaling.height</td>
  1369. <td>Number</td>
  1370. <td>10</td>
  1371. <td>This factor determines how much the height of a cluster increases in pixels per added node.</td>
  1372. </tr>
  1373. <tr>
  1374. <td>nodeScaling.radius</td>
  1375. <td>Number</td>
  1376. <td>10</td>
  1377. <td>This factor determines how much the radius of a cluster increases in pixels per added node.</td>
  1378. </tr>
  1379. <tr>
  1380. <td>maxNodeSizeIncrements</td>
  1381. <td>Number</td>
  1382. <td>600</td>
  1383. <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>
  1384. </tr>
  1385. <tr>
  1386. <td>activeAreaBoxSize</td>
  1387. <td>Number</td>
  1388. <td>100</td>
  1389. <td>Imagine a square with an edge length of <code>activeAreaBoxSize</code> pixels around your cursor.
  1390. If a cluster is in this box as you zoom in, the cluster can be opened in a seperate sector.
  1391. This is regardless of the zoom level.</td>
  1392. </tr>
  1393. <tr>
  1394. <td>clusterLevelDifference</td>
  1395. <td>Number</td>
  1396. <td>2</td>
  1397. <td>At every clustering session, Graph will check if the difference between cluster levels is
  1398. acceptable. When a cluster is formed when zooming out, that is one cluster level.
  1399. If you zoom out further and it encompasses more nodes, that is another level. For example:
  1400. If the highest level of your graph at any given time is 3, nodes that have not clustered or
  1401. have clustered only once will join their neighbour with the lowest cluster level.</td>
  1402. </tr>
  1403. </table>
  1404. <h3 id="Navigation_controls">Navigation controls</h3>
  1405. <p>
  1406. Graph has a menu with navigation controls, which is disabled by default.
  1407. It can be configured with the following settings.
  1408. </p>
  1409. <pre class="prettyprint">
  1410. // simple use of navigation controls
  1411. var options: {
  1412. navigation: true
  1413. }
  1414. // advanced use of navigation controls
  1415. var options: {
  1416. navigation: {
  1417. iconPath: '/path/to/navigation/icons/'
  1418. }
  1419. }
  1420. </pre>
  1421. <table>
  1422. <tr>
  1423. <th>Name</th>
  1424. <th>Type</th>
  1425. <th>Default</th>
  1426. <th>Description</th>
  1427. </tr>
  1428. <tr>
  1429. <td>iconPath</td>
  1430. <td>string</td>
  1431. <td>"/img"</td>
  1432. <td>The path to the icon images can be defined here. If custom icons are used, they have to have the same filename as the ones originally packaged with vis.js.</td>
  1433. </tr>
  1434. </table>
  1435. <h3 id="Keyboard_navigation">Keyboard navigation</h3>
  1436. <p>
  1437. The graph can be navigated using shortcut keys.
  1438. It can be configured with the following user-configurable settings.
  1439. The default state for the keyboard navigation is <b>off</b>. The predefined keys can be found in the example <a href="../examples/graph/20_navigation.html">20_navigation.html</a>.
  1440. </p>
  1441. <pre class="prettyprint">
  1442. // simple use of keyboard controls
  1443. var options: {
  1444. keyboard: true
  1445. }
  1446. // advanced configuration for keyboard controls
  1447. var options: {
  1448. keyboard: {
  1449. speed: {
  1450. x: 10,
  1451. y: 10,
  1452. zoom: 0.02
  1453. }
  1454. }
  1455. }
  1456. </pre>
  1457. <table>
  1458. <tr>
  1459. <th>Name</th>
  1460. <th>Type</th>
  1461. <th>Default</th>
  1462. <th>Description</th>
  1463. </tr>
  1464. <tr>
  1465. <td>speed.x</td>
  1466. <td>Number</td>
  1467. <td>10</td>
  1468. <td>This defines the speed of the camera movement in the x direction when using the keyboard navigation.
  1469. </td>
  1470. </tr>
  1471. <tr>
  1472. <td>speed.y</td>
  1473. <td>Number</td>
  1474. <td>10</td>
  1475. <td>This defines the speed of the camera movement in the y direction when using the keyboard navigation.</td>
  1476. </tr>
  1477. <tr>
  1478. <td>speed.zoom</td>
  1479. <td>Number</td>
  1480. <td>0.02</td>
  1481. <td>This defines the zoomspeed when using the keyboard navigation.</td>
  1482. </tr>
  1483. </table>
  1484. <h2 id="Methods">Methods</h2>
  1485. <p>
  1486. Graph supports the following methods.
  1487. </p>
  1488. <table>
  1489. <tr>
  1490. <th>Method</th>
  1491. <th>Return Type</th>
  1492. <th>Description</th>
  1493. </tr>
  1494. <tr>
  1495. <td>getSelection()</td>
  1496. <td>Array of ids</td>
  1497. <td>Returns an array with the ids of the selected nodes.
  1498. Returns an empty array if no nodes are selected.
  1499. The selections are not ordered.
  1500. </td>
  1501. </tr>
  1502. <tr>
  1503. <td>on(event, callback)</td>
  1504. <td>none</td>
  1505. <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>
  1506. </tr>
  1507. <tr>
  1508. <td>off(event, callback)</td>
  1509. <td>none</td>
  1510. <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>
  1511. </tr>
  1512. <tr>
  1513. <td>redraw()</td>
  1514. <td>none</td>
  1515. <td>Redraw the graph. Useful when the layout of the webpage changed.</td>
  1516. </tr>
  1517. <tr>
  1518. <td>setData(data,[disableStart])</td>
  1519. <td>none</td>
  1520. <td>Loads data. Parameter <code>data</code> is an object containing
  1521. nodes, edges, and options. Parameters nodes, edges are an Array.
  1522. Options is a name-value map and is optional. Parameter <code>disableStart</code> is
  1523. an optional Boolean and can disable the start of the simulation that would begin at the end
  1524. of this function by default.
  1525. </td>
  1526. </tr>
  1527. <tr>
  1528. <td>setOptions(options)</td>
  1529. <td>none</td>
  1530. <td>Set options for the graph. The available options are described in
  1531. the section <a href="#Configuration_options">Configuration Options</a>.
  1532. </td>
  1533. </tr>
  1534. <tr>
  1535. <td>setSelection(selection)</td>
  1536. <td>none</td>
  1537. <td>Select nodes.
  1538. <code>selection</code> is an array with ids of nodes to be selected.
  1539. The array <code>selection</code> can contain zero or multiple ids.
  1540. Example usage: <code>graph.setSelection([3, 5]);</code> will select
  1541. nodes with id 3 and 5.
  1542. </td>
  1543. </tr>
  1544. <tr>
  1545. <td>setSize(width, height)</td>
  1546. <td>none</td>
  1547. <td>Parameters <code>width</code> and <code>height</code> are strings,
  1548. containing a new size for the visualization. Size can be provided in pixels
  1549. or in percentages.</td>
  1550. </tr>
  1551. </table>
  1552. <h2 id="Events">Events</h2>
  1553. <p>
  1554. Graph fires events after one or multiple nodes are selected or deselected.
  1555. The event can be catched by creating a listener.
  1556. </p>
  1557. <p>
  1558. Here an example on how to catch a <code>select</code> event.
  1559. </p>
  1560. <pre class="prettyprint lang-js">
  1561. graph.on('select', function (properties) {
  1562. alert('selected nodes: ' + properties.nodes);
  1563. });
  1564. </pre>
  1565. <p>
  1566. A listener can be removed via the function <code>off</code>:
  1567. </p>
  1568. <pre class="prettyprint lang-js">
  1569. function onSelect (properties) {
  1570. alert('selected nodes: ' + properties.nodes);
  1571. }
  1572. // add event listener
  1573. graph.on('select', onSelect);
  1574. // do stuff...
  1575. // remove event listener
  1576. graph.off('select', onSelect);
  1577. </pre>
  1578. <p>
  1579. The following events are available.
  1580. </p>
  1581. <table>
  1582. <tr>
  1583. <th>name</th>
  1584. <th>Description</th>
  1585. <th>Properties</th>
  1586. </tr>
  1587. <tr>
  1588. <td>select</td>
  1589. <td>Fired after the user selects or deselects a node by clicking it.
  1590. Not fired when the method <code>setSelection</code>is executed.
  1591. </td>
  1592. <td>
  1593. <ul>
  1594. <li><code>nodes</code>: an array with the ids of the selected nodes</li>
  1595. </ul>
  1596. </td>
  1597. </tr>
  1598. </table>
  1599. <h2 id="Data_policy">Data policy</h2>
  1600. <p>
  1601. All code and data is processed and rendered in the browser.
  1602. No data is sent to any server.
  1603. </p>
  1604. </div>
  1605. </body>
  1606. </html>