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.
 
 
 

177 lines
21 KiB

<!DOCTYPE html>
<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">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" HREF="favicon.ico">
<title>vis.js - A dynamic, browser based visualization library.</title>
<!-- Bootstrap core CSS -->
<link href="../css/bootstrap.css" rel="stylesheet">
<link href="../css/newdocs.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="../js/smooth-scroll.min.js"></script>
<script language="JavaScript">
smoothScroll.init();
</script>
<style>
td.type {
width:160px;
}
</style>
</head>
<!-- NAVBAR
================================================== -->
<body>
<div class="navbar-wrapper">
<div class="container">
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="../index.html#modules">Modules</a></li>
<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>
<li><a href="../blog.html">Blog</a></li>
<li><a href="../index.html#download_install">Download</a></li>
<li><a href="../showcase/index.html">Showcase</a></li>
<li><a href="../index.html#contribute">Contribute</a></li>
<li><a href="../featureRequests.html">Feature requests</a></li>
<li><a href="../index.html#licenses">License</a></li>
</ul>
</div>
</div>
</nav>
</div>
</div>
<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>
<div class="container full">
<h1>Network - edges</h1>
<p>Handles the creation and deletion of edges and contains the global edge options and styles.</p>
<h3>Options</h3>
<p>This is a list of all the methods in the public API. They are collected here from all individual modules.</p>
<table class="moduleTable">
<tr class="header"><td>name</td> <td class="type">type</td> <td>default</td> <td>description</td></tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<br><br>Supported options are: <code>true, false, 'from','to','both'</code>.
<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.
<br><br>When set to 'to', the border color from the 'to' node will be used.
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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:
<pre>
function (min,max,total,value) {
if (max === min) {
return 0.5;
}
else {
var scale = 1 / (max - min);
return Math.max(0,(value - min)*scale);
}
}
</pre>
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:
<pre>
var scale = customScalingFunction(min,max,total,value);
var diff = maxWidth - minWidth;
myWidth = minWidth + diff * scale;
</pre>
</td></tr>
<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>
<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>
<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>
<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>
<tr><td>shadow.x</td> <td class="mid">Number</td> <td class="mid"><code>5</code></td> <td>The x offset.</td></tr>
<tr><td>shadow.y</td> <td class="mid">Number</td> <td class="mid"><code>5</code></td> <td>The y offset.</td></tr>
<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.
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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</table>
<h3>Methods</h3>
<p>The nodes module has no methods.</p>
<h3>Events</h3>
<p>The nodes module emits no events. Click and select events are emitted from the interaction and selection modules.</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../js/ie10-viewport-bug-workaround.js"></script>