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.

203 lines
12 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  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 - Manipulation documentation.</title>
  10. <!-- Bootstrap core CSS -->
  11. <link href="../css/bootstrap.css" rel="stylesheet">
  12. <!-- Tipue vendor css -->
  13. <link href="../css/tipuesearch.css" rel="stylesheet">
  14. <link href="../css/style.css" rel="stylesheet">
  15. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  16. <!--[if lt IE 9]>
  17. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  18. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  19. <![endif]-->
  20. <link href="../css/prettify.css" type="text/css" rel="stylesheet"/>
  21. <script type="text/javascript" src="../js/googleAnalytics.js"></script>
  22. <script type="text/javascript" src="../js/prettify/prettify.js"></script>
  23. <script src="../js/smooth-scroll.min.js"></script>
  24. <script language="JavaScript">
  25. smoothScroll.init();
  26. </script>
  27. <script type="text/javascript" src="../js/toggleTable.js"></script>
  28. </head>
  29. <body onload="prettyPrint();">
  30. <div class="navbar-wrapper">
  31. <div class="container">
  32. <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  33. <div class="container">
  34. <div class="navbar-header">
  35. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
  36. aria-expanded="false" aria-controls="navbar">
  37. <span class="sr-only">Toggle navigation</span>
  38. <span class="icon-bar"></span>
  39. <span class="icon-bar"></span>
  40. <span class="icon-bar"></span>
  41. </button>
  42. <a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
  43. </div>
  44. <div id="navbar" class="navbar-collapse collapse">
  45. <ul class="nav navbar-nav">
  46. <li><a href="http://www.visjs.org/index.html#modules">Modules</a></li>
  47. <li><a href="http://www.visjs.org/blog.html">Blog</a></li>
  48. <li><a href="http://www.visjs.org/index.html#download_install">Download</a></li>
  49. <li><a href="http://www.visjs.org/showcase/index.html">Showcase</a></li>
  50. <li><a href="http://www.visjs.org/index.html#contribute">Contribute</a></li>
  51. <li><a href="http://www.visjs.org/featureRequests.html">Feature requests</a></li>
  52. <li><a href="http://www.visjs.org/index.html#licenses">License</a></li>
  53. </ul>
  54. <form class="navbar-form navbar-right" role="search">
  55. <input name="q" id="tipue_search_input" autocomplete="off" type="text" class="form-control" placeholder="Enter keywords">
  56. <button type="button" class="btn btn-default" onclick="vis.initSiteSearch(true);">Go!</button>
  57. </form>
  58. <div id="search-results-wrapper" class="panel panel-default">
  59. <div class="panel-body">
  60. <div id="tipue_search_content"></div>
  61. </div>
  62. </div>
  63. <div id="keyword-info" class="panel panel-success">
  64. <div class="panel-body">
  65. Found <span id="keyword-count"></span> results. Click <a id="keyword-jumper-button" href="">here</a> to jump to the first keyword occurence!
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </nav>
  71. </div>
  72. </div>
  73. <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>
  74. <div class="container full">
  75. <h1>Network - manipulation</h1>
  76. <p>Acts as the camera that looks on the canvas. Does the animation, zooming and focusing.</p>
  77. <h3>Options</h3>
  78. <p>The options for the manipulation module have to be contained in an object titled 'manipulation'.</p>
  79. <p>Click on the full options or shorthand options to show how these options are supposed to be used.</p>
  80. <ul class="nav nav-tabs">
  81. <li role="presentation" class="active" onclick="toggleTab(this)"><a href="#">options hidden</a></li>
  82. <li role="presentation" onclick="toggleTab(this);" targetNode="fullOptions"><a href="#">full options</a></li>
  83. <li role="presentation" onclick="toggleTab(this);" targetNode="shortOptions"><a href="#">shorthand options</a></li>
  84. </ul>
  85. <br>
  86. <pre class="prettyprint lang-js options top hidden" id="fullOptions">
  87. // these are all options in full.
  88. var options = {
  89. manipulation: {
  90. enabled: false,
  91. initiallyActive: false,
  92. addNode: true,
  93. addEdge: true,
  94. editNode: undefined,
  95. editEdge: true,
  96. deleteNode: true,
  97. deleteEdge: true,
  98. controlNodeStyle:{
  99. // all node options are valid.
  100. }
  101. }
  102. }
  103. network.setOptions(options);
  104. </pre>
  105. <pre class="prettyprint lang-js options top hidden" id="shortOptions">
  106. // only the options that have shorthand notations are shown.
  107. var options = {
  108. manipulation: false
  109. }
  110. network.setOptions(options);
  111. </pre>
  112. <table class="options" id="optionTable">
  113. <tr><th>Name</th><th>Type</th><th>Default</th><td>Description</td></tr>
  114. <tr><td>enabled</td> <td>Boolean</td> <td><code>false</code></td> <td>Toggle the manipulation system on or off. Even when false, the manipulation API through the methods will still work. This property is optional. If you define any of the options below and enabled is undefined, this will be set to true.</td></tr>
  115. <tr><td>initiallyActive</td> <td>Boolean</td> <td><code>true</code></td> <td>Toggle whether the toolbar is visible initially or if only the edit button is visible initially.</td></tr>
  116. <tr><td>addNode</td> <td>Boolean or Function</td> <td><code>true</code></td> <td>You can use these options to switch certain functionalities on or off of attach
  117. 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,
  118. 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.
  119. <br><br>
  120. When you supply a boolean, you only toggle the 'add node' button on the GUI of the manipulation system. The lack of handling function could effect the API when using the methods.
  121. 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:
  122. <pre class="code">
  123. var options = {
  124. manipulation: {
  125. addNode: function(nodeData,callback) {
  126. nodeData.label = 'hello world';
  127. callback(nodeData);
  128. }
  129. }
  130. }
  131. </pre>
  132. 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>
  133. <tr><td>addEdge</td> <td>Boolean or Function</td> <td><code>true</code></td> <td>If boolean, toggle the availability of the 'addEdge' button in the GUI, the API through the methods will still work except (obviously) there will be no handler function.
  134. 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:
  135. <pre class="code">
  136. var options = {
  137. manipulation: {
  138. addEdge: function(edgeData,callback) {
  139. if (edgeData.from === edgeData.to) {
  140. var r = confirm("Do you want to connect the node to itself?");
  141. if (r === true) {
  142. callback(edgeData);
  143. }
  144. }
  145. else {
  146. callback(edgeData);
  147. }
  148. }
  149. }
  150. }
  151. </pre>
  152. 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>
  153. <tr><td>editNode</td> <td>Function</td> <td><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>
  154. <tr><td>editEdge</td> <td>Boolean or Function</td> <td><code>true</code></td> <td>If boolean, toggle the editing of edges in the GUI. When a function is supplied, it will be called when an edge is selected 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>
  155. <tr><td>deleteNode</td> <td>Boolean or Function</td> <td><code>true</code></td> <td>If boolean, toggle the deletion of nodes in the GUI. If function, it will be called when a node is selected and the 'Delete selected' button is pressed. When using a function, it will receive a callback and an object with an array of selected nodeIds and an array of selected edges Ids. These are the items that will be deleted if the callback is performed.</td></tr>
  156. <tr><td>deleteEdge</td> <td>Boolean or Function</td> <td><code>true</code></td> <td>If boolean, toggle the deletion of edges in the GUI. If function, it will be called when an edge is selected and the 'Delete selected' button is pressed. When using a function, it will receive a callback and an object with an array of selected nodeIds (empty) and an array of selected edges Ids. These are the items that will be deleted if the callback is performed.</td></tr>
  157. <tr><td>controlNodeStyle</td> <td>Object</td> <td>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:
  158. <pre class="code">
  159. {
  160. shape:'dot',
  161. size:6,
  162. color: {
  163. background: '#ff0000',
  164. border: '#3c3c3c',
  165. highlight: {
  166. background: '#07f968',
  167. border: '#3c3c3c'
  168. }
  169. },
  170. borderWidth: 2,
  171. borderWidthSelected: 2
  172. }
  173. </pre></td></tr>
  174. </table>
  175. </div>
  176. <!-- Bootstrap core JavaScript
  177. ================================================== -->
  178. <!-- Placed at the end of the document so the pages load faster -->
  179. <script src="../js/jquery.min.js"></script>
  180. <script src="../js/bootstrap.min.js"></script>
  181. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  182. <script src="../js/ie10-viewport-bug-workaround.js"></script>
  183. <!-- jquery extensions -->
  184. <script src="../js/jquery.highlight.js"></script>
  185. <script src="../js/jquery.url.min.js"></script>
  186. <!-- Tipue vendor js -->
  187. <script src="../js/tipuesearch.config.js"></script>
  188. <script src="../js/tipuesearch.js"></script>
  189. <!-- controller -->
  190. <script src="../js/main.js"></script>