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.

178 lines
21 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. <style>
  23. td.type {
  24. width:160px;
  25. }
  26. </style>
  27. </head>
  28. <!-- NAVBAR
  29. ================================================== -->
  30. <body>
  31. <div class="navbar-wrapper">
  32. <div class="container">
  33. <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  34. <div class="container">
  35. <div class="navbar-header">
  36. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" 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="../../index.html#modules">Modules</a></li>
  47. <li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon" src="../../images/external-link-icons/external-link-icon-white.png"></a></li>
  48. <li><a href="../../blog.html">Blog</a></li>
  49. <li><a href="../../index.html#download_install">Download</a></li>
  50. <li><a href="../../showcase/index.html">Showcase</a></li>
  51. <li><a href="../../index.html#contribute">Contribute</a></li>
  52. <li><a href="../../featureRequests.html">Feature requests</a></li>
  53. <li><a href="../../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 - edges</h1>
  63. <p>Handles the creation and deletion of edges and contains the global edge options and styles.</p>
  64. <h3>Options</h3>
  65. <p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p>
  66. <table class="moduleTable">
  67. <tr class="header"><td>name</td> <td class="type">type</td> <td>default</td> <td>description</td></tr>
  68. <tr><td>arrows</td> <td class="mid">Object | String</td> <td class="mid"><code>1</code></td> <td>To draw an arrow with default settings a string can be supplied. For example: <code>arrows:'to, from, middle'</code> or <code>'to;from'</code>, any combination with any seperating symbol is fine. If you want to control the size of the arrowheads, you can supply an object.</td></tr>
  69. <tr><td>arrows.to</td> <td class="mid">Object | Boolean</td> <td class="mid"><code>Object</code></td> <td>When true, an arrowhead on the 'to' side of the edge is drawn, pointing to the 'to' node with default settings. To customize the size of the arrow, supply an object.</td></tr>
  70. <tr><td>arrows.to.enabled</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>Toggle the arrow on or off. This option is optional, if undefined and the scaleFactor property is set, enabled will be set to true.</td></tr>
  71. <tr><td>arrows.to.scaleFactor</td> <td class="mid">Number</td> <td class="mid"><code>1</code></td> <td>The scale factor allows you to change the size of the arrowhead.</td></tr>
  72. <tr><td>arrows.middle</td> <td class="mid">Object | Boolean</td> <td class="mid"><code>Object</code></td> <td>Exactly the same as the to object but with an arrowhead in the center of the edge.</td></tr>
  73. <tr><td>arrows.from</td> <td class="mid">Object | Boolean</td> <td class="mid"><code>Object</code></td> <td>Exactly the same as the to object but with an arrowhead at the from node of the edge.</td></tr>
  74. <tr><td>color</td> <td class="mid">Object | String</td> <td class="mid"><code>Object</code></td> <td>The color object contains the color information of the edge in every situation. When the edge only needs a single color, a color value like <code>'rgb(120,32,14)'</code>, <code>'#ffffff'</code> or <code>'red'</code> can be supplied instead of an object.</td></tr>
  75. <tr><td>color.color</td> <td class="mid">String</td> <td class="mid"><code>'#848484'</code></td><td>The color of the border of the node when it is not selected or hovered over <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
  76. <tr><td>color.highlight</td> <td class="mid">String</td> <td class="mid"><code>'#848484'</code></td><td>The color the edge when it is selected.</td></tr>
  77. <tr><td>color.hover</td> <td class="mid">String</td> <td class="mid"><code>'#848484'</code></td><td>The color the edge when the mouse hovers over it <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
  78. <tr><td>color.inherit</td> <td class="mid">String | Boolean</td> <td class="mid"><code>'from'</code></td> <td><i>When color, highlight or hover are defined, inherit is set to false!</i>
  79. <br><br>Supported options are: <code>true, false, 'from','to','both'</code>.
  80. <br><br>The default value is 'from' which does the same as true: the edge will inherit the color from the border of the node on the 'from' side.
  81. <br><br>When set to 'to', the border color from the 'to' node will be used.
  82. <br><br>When set to 'both', the color will fade from the from color to the to color. <b>'both' is computationally intensive</b> because the gradient is recomputed every redraw. This is required because the angles change when the nodes move.</td></tr>
  83. <tr><td>color.opacity</td> <td class="mid">Number</td> <td class="mid"><code>1.0</code></td> <td>It can be useful to set the opacity of an edge without manually changing all the colors. The opacity option will convert all colors (also when using inherit) to adhere to the supplied opacity. The allowed range of the opacity option is between <code>0 and 1</code>. This is only done once so the performance impact is not too big.</td></tr>
  84. <tr><td>dashes</td> <td class="mid">Object | Boolean</td> <td class="mid"><code>Object</code></td> <td>When true, the edge will be drawn as a dashed line. You can customize the dashes by supplying an object. <i>When using dashed lines in IE versions older than 11, the line will be drawn straight, not smooth</i>.</td></tr>
  85. <tr><td>dashes.enabled</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>Toggle the dash drawing style on or off. This option is optional, if undefined and the scaleFactor property is set, enabled will be set to true.</td></tr>
  86. <tr><td>dashes.pattern</td> <td class="mid">Array</td> <td class="mid"><code>[5,5]</code></td> <td>Array of numbers repeating gap length, dash length, gap length, dash length, ... etc. The array is repeated until the distance is filled.</td></tr>
  87. <tr><td>font</td> <td class="mid">Object | String</td> <td class="mid"><code>false</code></td> <td>This object defines the details of the label. A shorthand is also supported in the form <code>'size face color'</code> for example: <code>'14px arial red'</code>.</td></tr>
  88. <tr><td>font.color</td> <td class="mid">String</td> <td class="mid"><code>'#343434'</code></td><td>Color of the label text.</td></tr>
  89. <tr><td>font.size</td> <td class="mid">Number</td> <td class="mid"><code>14</code></td> <td>Size of the label text.</td></tr>
  90. <tr><td>font.face</td> <td class="mid">String</td> <td class="mid"><code>'arial'</code></td> <td>Font face (or font family) of the label text.</td></tr>
  91. <tr><td>font.background</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td><td>When not <code>undefined</code> but a <b>color string</b>, a background rectangle will be drawn behind the label in the supplied color.</td></tr>
  92. <tr><td>font.stroke</td> <td class="mid">Number</td> <td class="mid"><code>0</code></td> <td>As an alternative to the background rectangle, a stroke can be drawn around the text. When a value higher than 0 is supplied, the stroke will be drawn.</td></tr>
  93. <tr><td>font.strokeColor</td> <td class="mid">String</td> <td class="mid"><code>'#ffffff'</code></td><td>This is the color of the stroke <i>assuming the value for stroke is higher than 0</i>.</td></tr>
  94. <tr><td>font.align</td> <td class="mid">String</td> <td class="mid"><code>'horizontal'</code></td><td>Possible options: <code>'horizontal','top','middle','bottom'</code>. The alignment determines how the label is aligned over the edge. The default value <code>horizontal</code> aligns the label horizontally, regardless of the orientation of the edge. When an option other than <code>horizontal</code> is chosen, the label will align itself according to the edge. </td></tr>
  95. <tr><td>hidden</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>When true, the edge is not drawn. It is part still part of the physics simulation however!</td></tr>
  96. <tr><td>hoverWidth</td> <td class="mid">Number</td> <td class="mid"><code>1.5</code></td> <td>The width of the edge when the mouse hovers over it (and hover is enabled in the interaction module!)</td></tr>
  97. <tr><td>label</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td><td>The label of the edge. HTML does not work in here because the network uses HTML5 Canvas.</td></tr>
  98. <tr><td>length</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td><td>The physics simulation gives edges a spring length. This value can override the length of the spring in rest.</td></tr>
  99. <tr><td>physics</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>When true, the edge is part of the physics simulation. When false, it will not act as a spring.</td></tr>
  100. <tr><td>scaling</td> <td class="mid">Object</td> <td class="mid"><code>Object</code></td> <td>If the <code>value</code> option is specified, the width of the edges will be scaled according to the properties in this object. Keep in mind that when using scaling, the <code>width</code> option is neglected.</td></tr>
  101. <tr><td>scaling.min</td> <td class="mid">Number</td> <td class="mid"><code>1</code></td> <td>If edges have a value, their widths are determined by the value, the scaling function and the min max values. The min value is the minimum allowed value.</td></tr>
  102. <tr><td>scaling.max</td> <td class="mid">Number</td> <td class="mid"><code>15</code></td> <td>This is the maximum allowed width when the edges are scaled using the value option.</td></tr>
  103. <tr><td>scaling.label</td> <td class="mid">Object | Boolean</td><td class="mid"><code>Object</code></td> <td>When false, the label is not allowed to scale with the edge. If true it will scale using default settigns. For further customization, you can supply an object.</td></tr>
  104. <tr><td>scaling.label.enabled</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>Toggle the scaling of the label on or off. If this option is not defined, it is set to true if any of the properties in this object are defined.</td></tr>
  105. <tr><td>scaling.label.min</td> <td class="mid">Number</td> <td class="mid"><code>14</code></td> <td>The minimum font-size used for labels when scaling.</td></tr>
  106. <tr><td>scaling.label.max</td> <td class="mid">Number</td> <td class="mid"><code>30</code></td> <td>The maximum font-size used for labels when scaling.</td></tr>
  107. <tr><td>scaling.label.maxVisible</td><td class="mid">Number</td> <td class="mid"><code>30</code></td> <td>When zooming in, the font is drawn larger as well. You can limit the perceived font size using this option. If set to 30, the font will never look larger than size 30 zoomed at 100%.</td></tr>
  108. <tr><td>scaling.label.drawThreshold</td><td class="mid">Number</td> <td class="mid"><code>3</code></td> <td>When zooming out, the font will be drawn smaller. This defines a lower limit for when the font is drawn. When using font scaling, you can use this together with the maxVisible to first show labels of important edges when zoomed out and only show the rest when zooming in.</td></tr>
  109. <tr><td>scaling.customScalingFunction</td> <td class="mid">Function</td><td class="mid">in description</td> <td>If edges have <code>value</code> fields, this function determines how the size of the nodes are scaled based on their values. The default function is:
  110. <pre>
  111. function (min,max,total,value) {
  112. if (max === min) {
  113. return 0.5;
  114. }
  115. else {
  116. var scale = 1 / (max - min);
  117. return Math.max(0,(value - min)*scale);
  118. }
  119. }
  120. </pre>
  121. The function receives the minimum value of the set, the maximum value, the total sum of all values and finally the value of the node or edge it works on. <b>It has to return a value between 0 and 1.</b> The nodes and edges then calculate their size as follows:
  122. <pre>
  123. var scale = customScalingFunction(min,max,total,value);
  124. var diff = maxWidth - minWidth;
  125. myWidth = minWidth + diff * scale;
  126. </pre>
  127. </td></tr>
  128. <tr><td>selfReferenceSize</td> <td class="mid">Number</td> <td class="mid"><code>false</code></td> <td>When the to and from nodes are the same, a circle is drawn. This is the radius of that circle.</td></tr>
  129. <tr><td>shadow</td> <td class="mid">Object | Boolean</td> <td class="mid"><code>Object</code></td><td>When true, the edge casts a shadow using the default settings. This can be further refined by supplying an object.</td></tr>
  130. <tr><td>shadow.enabled</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>Toggle the casting of shadows. If this option is not defined, it is set to true if any of the properties in this object are defined.</td></tr>
  131. <tr><td>shadow.size</td> <td class="mid">Number</td> <td class="mid"><code>10</code></td> <td>The blur size of the shadow.</td></tr>
  132. <tr><td>shadow.x</td> <td class="mid">Number</td> <td class="mid"><code>5</code></td> <td>The x offset.</td></tr>
  133. <tr><td>shadow.y</td> <td class="mid">Number</td> <td class="mid"><code>5</code></td> <td>The y offset.</td></tr>
  134. <tr><td>smooth</td> <td class="mid">Object | Boolean</td> <td class="mid"><code>Object</code></td><td>When true, the edge is drawn as a quadratic bezier curve. The drawing of these curves takes longer than that of straight curves but it looks better.
  135. There is a difference between dynamic smooth curves and static smooth curves. The dynamic smooth curves have an invisible support node that takes part in the physics simulation. If you have a lot of edges, you may want to consider turning off dynamic smooth curves for performance.</td></tr>
  136. <tr><td>smooth.enabled</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>Toggle smooth curves on and off. This is an optional option. If any of the other properties in this object are set, this option will be set to true.</td></tr>
  137. <tr><td>smooth.dynamic</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>When true, the edges will have an invisible support node guiding the shape. This node is part of the physics simulation. When false, there are a number of different approximations for smooth curves. Those can be selected in the type property.</td></tr>
  138. <tr><td>smooth.type</td> <td class="mid">String</td> <td class="mid"><code>'continuous'</code></td> <td>Possible options: <code>'continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW'</code>. Take a look at our example 26 to see what these look like and pick the one that you like best! <i>These do not do anything for dynamic smooth curves</i>.</td></tr>
  139. <tr><td>smooth.roundness</td> <td class="mid">Number</td> <td class="mid"><code>0.5</code></td> <td>Accepted range: <code>0 .. 1.0</code>. This parameter tweaks the roundness of the static smooth curves.</td></tr>
  140. <tr><td>title</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>The title is shown in a pop-up when the mouse moves over the edge.</td></tr>
  141. <tr><td>width</td> <td class="mid">Number</td> <td class="mid"><code>1</code></td> <td>The width of the edge. If value is set, this is not used.</td></tr>
  142. <tr><td>widthSelectionMultiplier</td><td class="mid">Number</td> <td class="mid"><code>2</code></td> <td>When you select the edge, the width will be the normal width * widthSelectionMultiplier.</td></tr>
  143. <tr><td>value</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>When a value is set, the edges' width will be scaled using the options in the scaling object defined above.</td></tr>
  144. </table>
  145. <h3>Methods</h3>
  146. <p>The nodes module has no methods.</p>
  147. <h3>Events</h3>
  148. <p>The nodes module emits no events. Click and select events are emitted from the interaction and selection modules.</p>
  149. <br />
  150. <br />
  151. <br />
  152. <br />
  153. <br />
  154. <br />
  155. <br />
  156. </div>
  157. <!-- Bootstrap core JavaScript
  158. ================================================== -->
  159. <!-- Placed at the end of the document so the pages load faster -->
  160. <script src="../../js/jquery.min.js"></script>
  161. <script src="../../js/bootstrap.min.js"></script>
  162. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  163. <script src="../../js/ie10-viewport-bug-workaround.js"></script>