Network - edges

Handles the creation and deletion of edges and contains the global edge options and styles.

Options

The options for the edges have to be contained in an object titled 'edges'. All of these options can be supplied per edge as well. Obviously, 'id' should not be defined globally but per edge. Options defined in the global edges object, are applied to all edges. If an edge has options of its own, those will be used instead of the global options.

When you have given an edge an option, you will override the global option for that property. If you then set that option to null, it will revert back to the default value.

Click on the full options or shorthand options to show how these options are supposed to be used.


These options can also be set per individual edge.

Name Type Default Description
arrows Object or String undefined To draw an arrow with default settings a string can be supplied. For example: arrows:'to, from, middle' or 'to;from', any combination with any seperating symbol is fine. If you want to control the size of the arrowheads, you can supply an object.
arrowStrikethrough Boolean true When false, the edge stops at the arrow. This can be useful if you have thick lines and you want the arrow to end in a point. Middle arrows are not affected by this.
color Object or String Object 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 'rgb(120,32,14)', '#ffffff' or 'red' can be supplied instead of an object.
dashes Array or Boolean false When true, the edge will be drawn as a dashed line. You can customize the dashes by supplying an Array. Array formart: Array of numbers, gap length, dash length, gap length, dash length, ... etc. The array is repeated until the distance is filled. When using dashed lines in IE versions older than 11, the line will be drawn straight, not smooth.
font Object or String false This object defines the details of the label. A shorthand is also supported in the form 'size face color' for example: '14px arial red'.
from Number or String Edges are between two nodes, one to and one from. This is where you define the from node. You have to supply the corresponding node ID. This naturally only applies to individual edges.
hidden Boolean false When true, the edge is not drawn. It is part still part of the physics simulation however!
hoverWidth Number or Function 0.5 Assuming the hover behaviour is enabled in the interaction module, the hoverWidth determines the width of the edge when the user hovers over it with the mouse. If a number is supplied, this number will be added to the width. Because the width can be altered by the value and the scaling functions, a constant multiplier or added value may not give the best results. To solve this, you can supply a function. Example:
var options: {
  edges: {
    hoverWidth: function (width) {return width+1;}
  }
}
It receives the Number width of the edge. In this simple example we add 1 to the width. You can taylor the logic in the function as long as it returns a Number.
id String undefined The id of the edge. The id is optional for edges. When not supplied, an UUID will be assigned to the edge. This naturally only applies to individual edges.
label String undefined The label of the edge. HTML does not work in here because the network uses HTML5 Canvas.
labelHighlightBold Boolean true Determines whether or not the label becomes bold when the edge is selected.
length Number undefined The physics simulation gives edges a spring length. This value can override the length of the spring in rest.
physics Boolean true When true, the edge is part of the physics simulation. When false, it will not act as a spring.
scaling Object Object If the value 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 width option is neglected.
selectionWidth Number or Function 1 The selectionWidth determines the width of the edge when the edge is selected. If a number is supplied, this number will be added to the width. Because the width can be altered by the value and the scaling functions, a constant multiplier or added value may not give the best results. To solve this, you can supply a function. Example:
var options: {
  edges: {
    selectionWidth: function (width) {return width*2;}
  }
}
It receives the Number width of the edge. In this simple example multiply the width by 2. You can taylor the logic in the function as long as it returns a Number.
selfReferenceSize Number false When the to and from nodes are the same, a circle is drawn. This is the radius of that circle.
shadow Object or Boolean Object When true, the edge casts a shadow using the default settings. This can be further refined by supplying an object.
smooth Object or Boolean Object When true, the edge is drawn as a dynamic 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 picking a different type of smooth curves then dynamic for better performance.
title String undefined The title is shown in a pop-up when the mouse moves over the edge.
to Number or String Edges are between two nodes, one to and one from. This is where you define the to node. You have to supply the corresponding node ID. This naturally only applies to individual edges.
value Number undefined When a value is set, the edges' width will be scaled using the options in the scaling object defined above.
width Number 1 The width of the edge. If value is set, this is not used.
widthConstraint Number, Boolean or Object false If false, no widthConstraint is applied. If a number is specified, the maximum width of the edge's label is set to the value. The edge's label's lines will be broken on spaces to stay below the maximum.