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.

183 lines
11 KiB

  1. <!DOCTYPE html>
  2. <html lang="en"><head>
  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. <link href="../css/prettify.css" type="text/css" rel="stylesheet"/>
  19. <script type="text/javascript" src="../js/googleAnalytics.js"></script>
  20. <script type="text/javascript" src="../js/prettify/prettify.js"></script>
  21. <script src="../js/smooth-scroll.min.js"></script>
  22. <script language="JavaScript">
  23. smoothScroll.init();
  24. </script>
  25. <script type="text/javascript" src="../js/toggleTable.js"></script>
  26. </head>
  27. <body onload="prettyPrint();">
  28. <div class="navbar-wrapper">
  29. <div class="container">
  30. <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  31. <div class="container">
  32. <div class="navbar-header">
  33. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
  34. aria-expanded="false" aria-controls="navbar">
  35. <span class="sr-only">Toggle navigation</span>
  36. <span class="icon-bar"></span>
  37. <span class="icon-bar"></span>
  38. <span class="icon-bar"></span>
  39. </button>
  40. <a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
  41. </div>
  42. <div id="navbar" class="navbar-collapse collapse">
  43. <ul class="nav navbar-nav">
  44. <li><a href="http://www.visjs.org/index.html#modules">Modules</a></li>
  45. <li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon"
  46. src="../img/external-link-icons/external-link-icon-white.png"></a>
  47. </li>
  48. <li><a href="http://www.visjs.org/blog.html">Blog</a></li>
  49. <li><a href="http://www.visjs.org/index.html#download_install">Download</a></li>
  50. <li><a href="http://www.visjs.org/showcase/index.html">Showcase</a></li>
  51. <li><a href="http://www.visjs.org/index.html#contribute">Contribute</a></li>
  52. <li><a href="http://www.visjs.org/featureRequests.html">Feature requests</a></li>
  53. <li><a href="http://www.visjs.org/index.html#licenses">License</a></li>
  54. </ul>
  55. </div>
  56. </div>
  57. </nav>
  58. </div>
  59. </div>
  60. <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>
  61. <div class="container full">
  62. <h1>Network - manipulation</h1>
  63. <p>Acts as the camera that looks on the canvas. Does the animation, zooming and focusing.</p>
  64. <h3>Options</h3>
  65. <p>The options for the manipulation module have to be contained in an object titled 'manipulation'.</p>
  66. <p>Click on the full options or shorthand options to show how these options are supposed to be used.</p>
  67. <ul class="nav nav-tabs">
  68. <li role="presentation" class="active" onclick="toggleTab(this)"><a href="#">options hidden</a></li>
  69. <li role="presentation" onclick="toggleTab(this);" targetNode="fullOptions"><a href="#">full options</a></li>
  70. <li role="presentation" onclick="toggleTab(this);" targetNode="shortOptions"><a href="#">shorthand options</a></li>
  71. </ul>
  72. <br>
  73. <pre class="prettyprint lang-js options top hidden" id="fullOptions">
  74. // these are all options in full.
  75. var options = {
  76. manipulation: {
  77. enabled: false,
  78. initiallyActive: false,
  79. addNode: true,
  80. addEdge: true,
  81. editNode: undefined,
  82. editEdge: true,
  83. deleteNode: true,
  84. deleteEdge: true,
  85. controlNodeStyle:{
  86. // all node options are valid.
  87. }
  88. }
  89. }
  90. network.setOptions(options);
  91. </pre>
  92. <pre class="prettyprint lang-js options top hidden" id="shortOptions">
  93. // only the options that have shorthand notations are shown.
  94. var options = {
  95. manipulation: false
  96. }
  97. network.setOptions(options);
  98. </pre>
  99. <table class="moduleTable" id="optionTable">
  100. <tr><th>name</th><th>type</th><th>default</th><td>description</td></tr>
  101. <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>
  102. <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>
  103. <tr><td>addNode</td> <td class="mid">Boolean or Function</td> <td class="mid"><code>true</code></td> <td>You can use these options to switch certain functionalities on or off of attach
  104. a handler function to them. These functions are called before the action is performed. If a node is going to be added through the manipulation system,
  105. 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. For all except the editNode functionality, these handler functions are optional.
  106. <br><br>
  107. When you supply a boolean, you only toggle the adding of nodes.
  108. When a function is supplied, it will be 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:
  109. <pre class="code">
  110. var options = {
  111. manipulation: {
  112. addNode: function(nodeData,callback) {
  113. nodeData.label = 'hello world';
  114. callback(nodeData);
  115. }
  116. }
  117. }
  118. </pre>
  119. This function changes the label of the new node into 'hello world'. 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.</td></tr>
  120. <tr><td>addEdge</td> <td class="mid">Boolean or Function</td> <td class="mid"><code>true</code></td> <td>If boolean, toggle the adding of edges.
  121. When a function is supplied, it will be 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:
  122. <pre class="code">
  123. var options = {
  124. manipulation: {
  125. addEdge: function(edgeData,callback) {
  126. if (edgeData.from === edgeData.to) {
  127. var r = confirm("Do you want to connect the node to itself?");
  128. if (r === true) {
  129. callback(edgeData);
  130. }
  131. }
  132. else {
  133. callback(edgeData);
  134. }
  135. }
  136. }
  137. }
  138. </pre>
  139. 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></td></tr>
  140. <tr><td>editNode</td> <td class="mid">Function</td> <td class="mid"><code>undefined</code></td> <td>Editing of nodes is only possible when a handling function is supplied. If this is not the case, editing of nodes will be disabled. The function will be 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>
  141. <tr><td>editEdge</td> <td class="mid">Boolean or Function</td> <td class="mid"><code>true</code></td> <td>If boolean, toggle the editing of edges. When a function is supplied, it will be 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. <b>To cancel, call the callback function with <code>null</code> as argument or without arguments</b>.</td></tr>
  142. <tr><td>deleteNode</td> <td class="mid">Boolean or Function</td> <td class="mid"><code>true</code></td> <td>If boolean, toggle the deletion of nodes. If function, it will be called when a node is selected and the 'Delete selected' button is pressed.</td></tr>
  143. <tr><td>deleteEdge</td> <td class="mid">Boolean or Function</td> <td class="mid"><code>true</code></td> <td>If boolean, toggle the deletion of edges. If function, it will be called when an edge is selected and the 'Delete selected' button is pressed.</td></tr>
  144. <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:
  145. <pre class="code">
  146. {
  147. shape:'dot',
  148. size:6,
  149. color: {
  150. background: '#ff0000',
  151. border: '#3c3c3c',
  152. highlight: {
  153. background: '#07f968',
  154. border: '#3c3c3c'
  155. }
  156. },
  157. borderWidth: 2,
  158. borderWidthSelected: 2
  159. }
  160. </pre></td></tr>
  161. </table>
  162. </div>
  163. <!-- Bootstrap core JavaScript
  164. ================================================== -->
  165. <!-- Placed at the end of the document so the pages load faster -->
  166. <script src="../js/jquery.min.js"></script>
  167. <script src="../js/bootstrap.min.js"></script>
  168. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  169. <script src="../js/ie10-viewport-bug-workaround.js"></script>