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.

191 lines
15 KiB

  1. <!DOCTYPE html>
  2. <html lang="en"><head><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3. <meta charset="utf-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="description" content="">
  7. <meta name="author" content="">
  8. <link rel="icon" HREF="favicon.ico">
  9. <title>vis.js - A dynamic, browser based visualization library.</title>
  10. <!-- Bootstrap core CSS -->
  11. <link href="../css/bootstrap.css" rel="stylesheet">
  12. <link href="../css/newdocs.css" rel="stylesheet">
  13. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  14. <!--[if lt IE 9]>
  15. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  16. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  17. <![endif]-->
  18. <script src="../js/smooth-scroll.min.js"></script>
  19. <script language="JavaScript">
  20. smoothScroll.init();
  21. </script>
  22. <script type="text/javascript" src="../js/toggleTable.js"></script>
  23. </head>
  24. <!-- NAVBAR
  25. ================================================== -->
  26. <body>
  27. <div class="navbar-wrapper">
  28. <div class="container">
  29. <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  30. <div class="container">
  31. <div class="navbar-header">
  32. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
  33. <span class="sr-only">Toggle navigation</span>
  34. <span class="icon-bar"></span>
  35. <span class="icon-bar"></span>
  36. <span class="icon-bar"></span>
  37. </button>
  38. <a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
  39. </div>
  40. <div id="navbar" class="navbar-collapse collapse">
  41. <ul class="nav navbar-nav">
  42. <li><a href="../index.html#modules">Modules</a></li>
  43. <li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon" src="../img/external-link-icons/external-link-icon-white.png"></a></li>
  44. <li><a href="../blog.html">Blog</a></li>
  45. <li><a href="../index.html#download_install">Download</a></li>
  46. <li><a href="../showcase/index.html">Showcase</a></li>
  47. <li><a href="../index.html#contribute">Contribute</a></li>
  48. <li><a href="../featureRequests.html">Feature requests</a></li>
  49. <li><a href="../index.html#licenses">License</a></li>
  50. </ul>
  51. </div>
  52. </div>
  53. </nav>
  54. </div>
  55. </div>
  56. <a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
  57. <div class="container full">
  58. <h1>Network - manipulation</h1>
  59. <p>Acts as the camera that looks on the canvas. Does the animation, zooming and focusing.</p>
  60. <h3>Options</h3>
  61. <p>When enabling the hierarchical layout, it overrules some of the other options. The physics is set to the hierarchical repulsion solver and dynamic smooth edges are converted to static smooth edges.</p>
  62. <table class="moduleTable" id="optionTable">
  63. <tr class="header"><td class="name">name</td><td class="type">type</td><td class="default">default</td><td class="description">description</td></tr>
  64. <tr><td>enabled</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>Toggle the manipulation system on or off. This property is optional. If you define any of the options below and enabled is undefined, this will be set to true.</td></tr>
  65. <tr><td>initiallyActive</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle whether the toolbar is visible initially or if only the edit button is visible initially.</td></tr>
  66. <tr><td>locale</td> <td class="mid">String</td> <td class="mid"><code>'en'</code></td> <td>Select the locale. By default, the language is English. If you want to use another language, you will need to define your own locale and refer to it here.</td></tr>
  67. <tr><td>locales</td> <td class="mid">Object</td> <td class="mid">defaultLocales</td> <td>Locales object. By default only <code>'en'</code> and <code>'nl'</code> are supported. Take a look at the <a href="#locales" data-scroll="" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }">locales section below</a> for more explaination on how to customize this.</td></tr>
  68. <tr class='toggle collapsible' onclick="toggleTable('optionTable','functionality', this);"><td><span parent="functionality" class="right-caret"></span> functionality</td> <td class="mid">Object</td> <td class="mid">Object</td> <td>You can use this object to switch certain functionalities on or off. By default they are all on.</td></tr>
  69. <tr parent="functionality" class="hidden"><td class="indent">functionality.addNode</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle the adding of nodes.</td></tr>
  70. <tr parent="functionality" class="hidden"><td class="indent">functionality.addEdge</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle the adding of edges.</td></tr>
  71. <tr parent="functionality" class="hidden"><td class="indent">functionality.editNode</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle the editing of nodes. Even if this is enabled, it will only be shown if a handler function is set for <code>editNode</code>.</td></tr>
  72. <tr parent="functionality" class="hidden"><td class="indent">functionality.editEdge</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle the editing of edges.</td></tr>
  73. <tr parent="functionality" class="hidden"><td class="indent">functionality.deleteNode</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle the deletion of nodes.</td></tr>
  74. <tr parent="functionality" class="hidden"><td class="indent">functionality.deleteEdge</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle the deletion of edges.</td></tr>
  75. <tr class='toggle collapsible' onclick="toggleTable('optionTable','handlerFunctions', this);"><td><span parent="handlerFunctions" class="right-caret"></span> handlerFunctions</td> <td class="mid">Object</td> <td class="mid"><code>Object</code></td> <td>These functions are inserted before the action is performed. If a node is going to be added through the manipulation system, the addNode function will be called first. With this, you can provide a gui for your users, abort the process or anything else you want to do.</td></tr>
  76. <tr parent="handlerFunctions" class="hidden"><td class="indent">handlerFunctions.addNode</td> <td class="mid">Function</td> <td class="mid"><code>undefined</code></td> <td>Called when the user clicks the canvas in 'addNode' mode. This function will receive two variables: the properties of the node that can be created and a callback function. If you call the callback function with the properties of the new node, the node will be added. <br><br> Example:
  77. <pre class="code">
  78. var options = {
  79. handlerFunctions: {
  80. addNode: function(nodeData,callback) {
  81. nodeData.label = 'hello world';
  82. callback(nodeData);
  83. }
  84. }
  85. }
  86. </pre>
  87. If you do not want the node created, do not call the callback function or call the callback function <code>null</code> or no argument.
  88. </td></tr>
  89. <tr parent="handlerFunctions" class="hidden"><td class="indent">handlerFunctions.addEdge</td> <td class="mid">Function</td> <td class="mid"><code>undefined</code></td> <td>Called when the user drags the new edge from one node to the next in 'addEdge' mode. This function will receive two variables: the properties of the edge that can be created and a callback function. If you call the callback function with the properties of the new edge, the edge will be added. <br><br> Example:
  90. <pre class="code">
  91. var options = {
  92. handlerFunctions: {
  93. addEdge: function(edgeData,callback) {
  94. if (edgeData.from === edgeData.to) {
  95. var r = confirm("Do you want to connect the node to itself?");
  96. if (r === true) {
  97. callback(edgeData);
  98. }
  99. }
  100. else {
  101. callback(edgeData);
  102. }
  103. }
  104. }
  105. }
  106. </pre>
  107. This example code will show a popup if you connect a node to itself to ask you if that was what you wanted. If you do not want the edge created, do not call the callback function or call the callback function <code>null</code> or no argument.</td></tr>
  108. <tr parent="handlerFunctions" class="hidden"><td class="indent">handlerFunctions.editNode</td> <td class="mid">Function</td> <td class="mid"><code>undefined</code></td> <td>Called when a node is selected and the 'Edit Node' button on the toolbar is pressed. This function will be called like the <code>addNode</code> function with the node's data and a callback function.</td></tr>
  109. <tr parent="handlerFunctions" class="hidden"><td class="indent">handlerFunctions.editEdge</td> <td class="mid">Function</td> <td class="mid"><code>undefined</code></td> <td>Called when an edge is selcted and the 'Edit Edge' button on the toolbar is pressed. This function will be called in the same way the <code>addEdge</code> function was called. If the callback is not performed, the edge will remain hanging where it was released. To cancel, call the callback function with <code>null</code> as argument or without arguments.</pre></td></tr>
  110. <tr parent="handlerFunctions" class="hidden"><td class="indent">handlerFunctions.deleteNode</td><td class="mid">Function</td> <td class="mid"><code>undefined</code></td> <td>Called when a node is selected and the 'Delete selected' button is pressed.</td></tr>
  111. <tr parent="handlerFunctions" class="hidden"><td class="indent">handlerFunctions.deleteEdge</td><td class="mid">Function</td> <td class="mid"><code>undefined</code></td> <td>Called when an edge is selected and the 'Delete selected' button is pressed.</td></tr>
  112. <tr><td>controlNodeStyle</td> <td class="mid">Object</td> <td class="mid">Object</td><td>You can supply any styling information you'd like here. All fields described in <a href="./nodes.html">the nodes module</a> are allowed except obviously for id, x, y and fixed. <br><br>Default:
  113. <pre class="code">
  114. {
  115. shape:'dot',
  116. size:6,
  117. color: {
  118. background: '#ff0000',
  119. border: '#3c3c3c',
  120. highlight: {
  121. background: '#07f968',
  122. border: '#3c3c3c'
  123. }
  124. },
  125. borderWidth: 2,
  126. borderWidthSelected: 2
  127. }
  128. </pre></td></tr>
  129. </table>
  130. <h3>Methods</h3>
  131. <p>This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.</p>
  132. <table class="moduleTable">
  133. <tr class="header"> <td class="method">name</td><td>returns</td><td>description</td></tr>
  134. <tr><td>enableEditMode()</td> <td class="mid">none</td><td>Programatically enable the edit mode. Similar effect to pressing the edit button.</td></tr>
  135. <tr><td>disableEditMode()</td><td class="mid">none</td><td>Programatically disable the edit mode. Similar effect to pressing the close icon (small cross in the corner of the toolbar).</td></tr>
  136. <tr><td>addNodeMode()</td> <td class="mid">none</td><td>Go into addNode mode. Having edit mode or manipulation enabled is not required. To get out of this mode, call <code>disableEditMode()</code>. The callback functions defined in <code>handlerFunctions</code> still apply. To use these methods without having the manipulation GUI, make sure you set <code>enabled</code> to false. </td></tr>
  137. <tr><td>editNodeMode()</td> <td class="mid">none</td><td>Go into editNode mode. The explaination from <code>addNodeMode</code> applies here as well.</td></tr>
  138. <tr><td>addEdgeMode()</td> <td class="mid">none</td><td>Go into addEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td></tr>
  139. <tr><td>editEdgeMode()</td> <td class="mid">none</td><td>Go into editEdge mode. The explaination from <code>addNodeMode</code> applies here as well.</td></tr>
  140. <tr><td>deleteSelected()</td> <td class="mid">none</td><td>Delete selected. Having edit mode or manipulation enabled is not required.</td></tr>
  141. </table>
  142. <h3>Events</h3>
  143. <p>There are no events emitted by the layout module.</p>
  144. <h3 id="locales">Locales</h3>
  145. <p>The locales object has the following format:</p>
  146. <pre class="code">
  147. var locales = {
  148. en: {
  149. edit: 'Edit',
  150. del: 'Delete selected',
  151. back: 'Back',
  152. addNode: 'Add Node',
  153. addEdge: 'Add Edge',
  154. editNode: 'Edit Node',
  155. editEdge: 'Edit Edge',
  156. addDescription: 'Click in an empty space to place a new node.',
  157. edgeDescription: 'Click on a node and drag the edge to another node to connect them.',
  158. editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
  159. createEdgeError: 'Cannot link edges to a cluster.',
  160. deleteClusterError: 'Clusters cannot be deleted.',
  161. editClusterError: 'Clusters cannot be edited.'
  162. }
  163. }</pre>
  164. <p>If you want to define your own locale, you can change the key ('en' here) and change all the string. You can then use your new key in the locale option.</p>
  165. <br />
  166. <br />
  167. <br />
  168. <br />
  169. <br />
  170. <br />
  171. <br />
  172. </div>
  173. <!-- Bootstrap core JavaScript
  174. ================================================== -->
  175. <!-- Placed at the end of the document so the pages load faster -->
  176. <script src="../js/jquery.min.js"></script>
  177. <script src="../js/bootstrap.min.js"></script>
  178. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  179. <script src="../js/ie10-viewport-bug-workaround.js"></script>