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. </style>
  24. </head>
  25. <!-- NAVBAR
  26. ================================================== -->
  27. <body>
  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" aria-expanded="false" aria-controls="navbar">
  34. <span class="sr-only">Toggle navigation</span>
  35. <span class="icon-bar"></span>
  36. <span class="icon-bar"></span>
  37. <span class="icon-bar"></span>
  38. </button>
  39. <a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
  40. </div>
  41. <div id="navbar" class="navbar-collapse collapse">
  42. <ul class="nav navbar-nav">
  43. <li><a href="../index.html#modules">Modules</a></li>
  44. <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>
  45. <li><a href="../blog.html">Blog</a></li>
  46. <li><a href="../index.html#download_install">Download</a></li>
  47. <li><a href="../showcase/index.html">Showcase</a></li>
  48. <li><a href="../index.html#contribute">Contribute</a></li>
  49. <li><a href="../featureRequests.html">Feature requests</a></li>
  50. <li><a href="../index.html#licenses">License</a></li>
  51. </ul>
  52. </div>
  53. </div>
  54. </nav>
  55. </div>
  56. </div>
  57. <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>
  58. <div class="container full">
  59. <h1>Network - nodes</h1>
  60. <p>Handles the creation and deletion of nodes and contains the global node options and styles.</p>
  61. <h3>Options</h3>
  62. <p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p>
  63. <table class="moduleTable">
  64. <tr class="header"><td>name</td> <td>type</td> <td>default</td> <td>description</td></tr>
  65. <tr><td>borderWidth</td> <td class="mid">Number</td> <td class="mid"><code>1</code></td> <td>The width of the border of the node.</td></tr>
  66. <tr><td>borderWidthSelected</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>The width of the border of the node when it is selected. When undefined, the borderWidth is used</td></tr>
  67. <tr><td>brokenImage</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>When the shape is set to <code>image</code> or <code>circularImage</code>, this option can be an URL to a backup image in case the URL supplied in the image option cannot be resolved.</td></tr>
  68. <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 node in every situation. When the node only needs a single color, a color value like <code>'rgba(120,32,14,1)'</code>, <code>'#ffffff'</code> or <code>'red'</code> can be supplied instead of an object.</td></tr>
  69. <tr><td>color.border</td> <td class="mid">String</td> <td class="mid"><code>'#2B7CE9'</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>
  70. <tr><td>color.background</td> <td class="mid">String</td> <td class="mid"><code>'#D2E5FF'</code></td> <td>The color of the background of the node when it is not selected or hovered over <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
  71. <tr><td>color.highlight</td> <td class="mid">Object | String</td><td class="mid"><code>Object</code></td> <td>The color the node when it is selected. Alternatively you can just supply a string color value.</td></tr>
  72. <tr><td>color.highlight.border</td><td class="mid">String</td> <td class="mid"><code>'#2B7CE9'</code></td> <td>The color of the border of the node when it is selected.</td></tr>
  73. <tr><td>color.highlight.background</td><td class="mid">String</td> <td class="mid"><code>'#D2E5FF'</code></td> <td>The color of the background of the node when it is selected.</td></tr>
  74. <tr><td>color.hover</td> <td class="mid">Object/String</td><td class="mid"><code>Object</code></td> <td>The color the node when the mouse hovers over it <i>(assuming hover is enabled in the interaction module)</i>. Shorthand like above is also supported.</td></tr>
  75. <tr><td>color.hover.border</td> <td class="mid">String</td> <td class="mid"><code>'#2B7CE9'</code></td> <td>The color of the border of the node when the mouse hovers over it <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
  76. <tr><td>color.hover.background</td> <td class="mid">String</td> <td class="mid"><code>'#D2E5FF'</code></td> <td>The color of the background of the node when the mouse hovers over it <i>(assuming hover is enabled in the interaction module)</i>.</td></tr>
  77. <tr><td>fixed</td> <td class="mid">Object | Boolean</td><td class="mid"><code>Object</code></td> <td>When true, the node will not move but IS part of the physics simulation. When defined as an object, movement in either X or Y direction can be disabled.</td></tr>
  78. <tr><td>fixed.x</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>When true, the node will not move in the X direction.</td></tr>
  79. <tr><td>fixed.y</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>When true, the node will not move in the Y direction.</td></tr>
  80. <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>
  81. <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>
  82. <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>
  83. <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>
  84. <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>
  85. <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>
  86. <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>
  87. <tr><td>group</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>When not <code>undefined</code>, the</td></tr>
  88. <tr><td>hidden</td> <td class="mid">Boolean</td> <td class="mid"><code>false</code></td> <td>When true, the node will not be shown. It will still be part of the physics simulation though!</td></tr>
  89. <tr><td>icon.face</td> <td class="mid">String</td> <td class="mid"><code>'FontAwesome'</code></td><td>These options are only used when the shape is set to <code>icon</code>. The possible options for the face are: <code>'FontAwesome'</code> and <code>'Ionicons'</code>.</td></tr>
  90. <tr><td>icon.code</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>This is the code of the icon, for example <code>'\uf007'</code>.</td></tr>
  91. <tr><td>icon.size</td> <td class="mid">Number</td> <td class="mid"><code>50</code></td> <td>The size of the icon.</td></tr>
  92. <tr><td>icon.color</td> <td class="mid">String</td> <td class="mid"><code>'#2B7CE9'</code></td> <td>The color of the icon.</td></tr>
  93. <tr><td>image</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>When the shape is set to <code>image</code> or <code>circularImage</code>, this option should be the URL to an image. If the image cannot be found, the brokenImage option can be used.</td></tr>
  94. <tr><td>label</td> <td class="mid">String</td> <td class="mid"><code>undefined</code></td> <td>The label is the piece of text shown in or under the node, depending on the shape.</td></tr>
  95. <tr><td>level</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>When using the hierarchical layout, the level determines where the node is going to be positioned.</td></tr>
  96. <tr><td>mass</td> <td class="mid">Number</td> <td class="mid"><code>1</code></td> <td>The barnesHut physics model (which is enabled by default) is based on an inverted gravity model. By increasing the mass of a node, you increase it's repulsion. Values lower than 1 are not recommended.</td></tr>
  97. <tr><td>physics</td> <td class="mid">Boolean</td> <td class="mid"><code>true</code></td> <td>When false, the node is not part of the physics simulation. It will not move except for from manual dragging.</td></tr>
  98. <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 size of the nodes will be scaled according to the properties in this object. All node shapes can be scaled, but some only when label scaling is enabled as their size is based on the size of the label.
  99. Only scalable when label scaling is enabled are:
  100. <code>ellipse</code>, <code>circle</code>, <code>database</code>, <code>box</code>, <code>text</code>.
  101. Always scalable are:
  102. <code>image</code>, <code>circularImage</code>, <code>diamond</code>, <code>dot</code>,
  103. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and <code>icon</code>. Keep in mind that when using scaling, the <code>size</code> option is neglected.</td></tr>
  104. <tr><td>scaling.min</td> <td class="mid">Number</td> <td class="mid"><code>10</code></td> <td>If nodes have a value, their sizes are determined by the value, the scaling function and the min max values. The min value is the minimum allowed value.</td></tr>
  105. <tr><td>scaling.max</td> <td class="mid">Number</td> <td class="mid"><code>30</code></td> <td>This is the maximum allowed size when the nodes are scaled using the value option.</td></tr>
  106. <tr><td>scaling.label</td> <td class="mid">Object | Boolean</td><td class="mid"><code>Object</code></td><td>This can be false if the label is not allowed to scale with the node. If true it will scale using default settigns. For further customization, you can supply an object.</td></tr>
  107. <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>
  108. <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>
  109. <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>
  110. <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>
  111. <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 nodes when zoomed out and only show the rest when zooming in.</td></tr>
  112. <tr><td>scaling.customScalingFunction</td> <td class="mid">Function</td> <td class="mid">in description</td> <td>If nodes have <code>value</code> fields, this function determines how the size of the nodes are scaled based on their values. The default function is:
  113. <pre>
  114. function (min,max,total,value) {
  115. if (max === min) {
  116. return 0.5;
  117. }
  118. else {
  119. var scale = 1 / (max - min);
  120. return Math.max(0,(value - min)*scale);
  121. }
  122. }
  123. </pre>
  124. 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:
  125. <pre>
  126. var scale = customScalingFunction(min,max,total,value);
  127. var diff = maxSize - minSize;
  128. mySize = minSize + diff * scale;
  129. </pre>
  130. </td></tr>
  131. <tr><td>shadow</td> <td class="mid">Object | Boolean</td> <td class="mid"><code>Object</code></td><td>When true, the node casts a shadow using the default settings. This can be further refined by supplying an object.</td></tr>
  132. <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>
  133. <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>
  134. <tr><td>shadow.x</td> <td class="mid">Number</td> <td class="mid"><code>5</code></td> <td>The x offset.</td></tr>
  135. <tr><td>shadow.y</td> <td class="mid">Number</td> <td class="mid"><code>5</code></td> <td>The y offset.</td></tr>
  136. <tr><td>shape</td> <td class="mid">String</td> <td class="mid"><code>'ellipse'</code></td> <td>The shape defines what the node looks like. There are two types of nodes. One type has the label inside of it and the other type has the label underneath it. The types with the label inside of it are:
  137. <code>ellipse</code>, <code>circle</code>, <code>database</code>, <code>box</code>, <code>text</code>.
  138. The ones with the label outside of it are: <code>image</code>, <code>circularImage</code>, <code>diamond</code>, <code>dot</code>, <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and <code>icon</code>.</td></tr>
  139. <tr><td>size</td> <td class="mid">Number</td> <td class="mid"><code>25</code></td> <td>The size is used to determine the size of node shapes that do not have the label inside of them. These shapes are: <code>image</code>, <code>circularImage</code>, <code>diamond</code>, <code>dot</code>,
  140. <code>star</code>, <code>triangle</code>, <code>triangleDown</code>, <code>square</code> and <code>icon</code></td></tr>
  141. <tr><td>title</td> <td class="mid">String | Element</td> <td class="mid"><code>undefined</code></td> <td>Title to be displayed when the user hovers over the node. The title can be an HTML element or a string containing plain text or HTML.</td></tr>
  142. <tr><td>value</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>When a value is set, the nodes will be scaled using the options in the scaling object defined above.</td></tr>
  143. <tr><td>x</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>This gives a node an initial x position. When using the hierarchical layout, either the x or y position is set by the layout engine depending on the type of view. The other value remains untouched. When using stabilization, the stabilized position may be different from the initial one. To lock the node to that position use the physics or fixed options.</td></tr>
  144. <tr><td>y</td> <td class="mid">Number</td> <td class="mid"><code>undefined</code></td> <td>This gives a node an initial y position. When using the hierarchical layout, either the x or y position is set by the layout engine depending on the type of view. The other value remains untouched. When using stabilization, the stabilized position may be different from the initial one. To lock the node to that position use the physics or fixed options.</td></tr>
  145. </table>
  146. <h3>Methods</h3>
  147. <p>The nodes module has no methods.</p>
  148. <h3>Events</h3>
  149. <p>The nodes module emits no events. Click and select events are emitted from the interaction and selection modules.</p>
  150. <br />
  151. <br />
  152. <br />
  153. <br />
  154. <br />
  155. <br />
  156. <br />
  157. </div>
  158. <!-- Bootstrap core JavaScript
  159. ================================================== -->
  160. <!-- Placed at the end of the document so the pages load faster -->
  161. <script src="../js/jquery.min.js"></script>
  162. <script src="../js/bootstrap.min.js"></script>
  163. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  164. <script src="../js/ie10-viewport-bug-workaround.js"></script>