Handles the creation and deletion of nodes and contains the global node options and styles.
The options for the nodes have to be contained in an object titled 'nodes'. All of these options can be supplied per node as well. Obviously, 'id' should not be defined globally but per node. Options defined in the global nodes object, are applied to all nodes. If a node has options of its own, those will be used instead of the global options.
When you have given a node an option, you will override the global option for that property, and also the group option for that property if the node is in a group. 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 node. All of the individual options are explained here:
Name | Type | Default | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
borderWidth | Number | 1 |
The width of the border of the node. | ||||||||||||||||||||||||
borderWidthSelected | Number | 2 |
The width of the border of the node when it is selected. When undefined, the borderWidth * 2 is used. | ||||||||||||||||||||||||
brokenImage | String | undefined |
When the shape is set to image or circularImage , this option can be an URL to
a backup image in case the URL supplied in the image option cannot be resolved.
|
||||||||||||||||||||||||
chosen | Object or Boolean | true |
When true, selecting or hovering on a node will change it and its label's characteristics according the default. When false, no change to the node or its label will occur when the node is chosen. If an object is supplied, finer-grained adjustment of node and label characteristics is available when a node is chosen. | ||||||||||||||||||||||||
chosen.node | Function or Boolean | undefined |
When true, selecting or hovering on a node will change its characteristics according the default.
When false, no change to the node will occur when the node is chosen.
If a function is supplied, it is called when the node is chosen. function(values, id, selected, hovering) { values.property = chosenValue; }
Any of the incoming arguments may be used to determine characteristic changes.
If a property is not specifically assigned by the supplied function, it will be left unchanged.
A specific function may be assigned to each particular node in its options, or to all in the network's The properties define the characteristics that can be changed as follows:
|
||||||||||||||||||||||||
chosen.label | Function or Boolean | undefined |
When true, selecting or hovering on a node will change its label's characteristics according the default.
When false, no change to the node's label will occur when the node is chosen.
If a function is supplied, it is called when the node is chosen. function(values, id, selected, hovering) { values.property = chosenValue; }
Any of the incoming arguments may be used to determine characteristic changes.
If a property is not specifically assigned by the supplied function, it will be left unchanged.
A specific function may be assigned to each particular node in its options, or to all in the network's The properties define the characteristics that can be changed as follows:
|
||||||||||||||||||||||||
color | Object or String | Object |
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 'rgba(120,32,14,1)' , '#ffffff' or 'red'
can be supplied instead of an object.
|
||||||||||||||||||||||||
color.border | String | '#2B7CE9' |
The color of the border of the node when it is not selected or hovered over (assuming hover is enabled in the interaction module). | ||||||||||||||||||||||||
color.background | String | '#D2E5FF' |
The color of the background of the node when it is not selected or hovered over (assuming hover is enabled in the interaction module). | ||||||||||||||||||||||||
color.highlight | Object or String | Object |
The color the node when it is selected. Alternatively you can just supply a string color value. | ||||||||||||||||||||||||
color.highlight.border | String | '#2B7CE9' |
The color of the border of the node when it is selected. | ||||||||||||||||||||||||
color.highlight.background | String | '#D2E5FF' |
The color of the background of the node when it is selected. | ||||||||||||||||||||||||
color.hover | Object or String | Object |
The color the node when the mouse hovers over it (assuming hover is enabled in the interaction module). Shorthand like above is also supported. | ||||||||||||||||||||||||
color.hover.border | String | '#2B7CE9' |
The color of the border of the node when the mouse hovers over it (assuming hover is enabled in the interaction module). | ||||||||||||||||||||||||
color.hover.background | String | '#D2E5FF' |
The color of the background of the node when the mouse hovers over it (assuming hover is enabled in the interaction module). | ||||||||||||||||||||||||
fixed | Object or Boolean | Object |
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. | ||||||||||||||||||||||||
fixed.x | Boolean | false |
When true, the node will not move in the X direction. | ||||||||||||||||||||||||
fixed.y | Boolean | false |
When true, the node will not move in the Y direction. | ||||||||||||||||||||||||
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' .
|
||||||||||||||||||||||||
font.color | String | '#343434' |
Color of the label text. | ||||||||||||||||||||||||
font.size | Number | 14 |
Size of the label text. | ||||||||||||||||||||||||
font.face | String | 'arial' |
Font face (or font family) of the label text. | ||||||||||||||||||||||||
font.background | String | undefined |
When not undefined but a color string, a background rectangle will be drawn behind
the label in the supplied color.
|
||||||||||||||||||||||||
font.strokeWidth | Number | 0 |
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. | ||||||||||||||||||||||||
font.strokeColor | String | '#ffffff' |
This is the color of the stroke assuming the value for stroke is higher than 0. | ||||||||||||||||||||||||
font.align | String | 'center' |
This can be set to 'left' to make the label left-aligned. Otherwise, defaults to 'center'. | ||||||||||||||||||||||||
font.vadjust | String | 0 |
A font-specific correction to the vertical positioning of the base font in the label text. (Positive is down.) | ||||||||||||||||||||||||
font.multi | Boolean or String | false |
If false , the label is treated as pure text drawn with the base font. If true or 'html' the label may be multifonted, with bold, italic and code markup, interpreted as html. If the value is 'markdown' or 'md' the label may be multifonted, with bold, italic and code markup, interpreted as markdown.
The bold, italic, bold-italic and monospaced fonts may be set up under in the font.bold, font.ital, font.boldital and font.mono properties, respectively. |
||||||||||||||||||||||||
font.bold | Object or String | false |
This object defines the details of the bold font in the label. A shorthand is also supported in the form 'size face
color' for example: '14px arial red' .
|
||||||||||||||||||||||||
font.bold.color | String | '#343434' |
Color of the bold font in the label text. Defaults to the base font's color. | ||||||||||||||||||||||||
font.bold.size | Number | 14 |
Size of the bold font in the label text. Defaults to the base font's size. | ||||||||||||||||||||||||
font.bold.face | String | 'arial' |
Font face (or font family) of the bold font in the label text. Defaults to the base font's face. | ||||||||||||||||||||||||
font.bold.mod | String | 'bold' |
A string added to the face and size when determining the bold font in the label text. | ||||||||||||||||||||||||
font.bold.vadjust | String | 0 |
A font-specific correction to the vertical positioning of the bold italic font in the label text. (Positive is down.) Defaults to the base font's valign. | ||||||||||||||||||||||||
font.ital | Object or String | false |
This object defines the details of the italic font in the label. A shorthand is also supported in the form 'size face
color' for example: '14px arial red' .
|
||||||||||||||||||||||||
font.ital.color | String | '#343434' |
Color of the italic font in the label text. Defaults to the base font's color. | ||||||||||||||||||||||||
font.ital.size | Number | 14 |
Size of the italic font in the label text. Defaults to the base font's size. | ||||||||||||||||||||||||
font.ital.face | String | 'arial' |
Font face (or font family) of the italic font in the label text. Defaults to the base font's face. | ||||||||||||||||||||||||
font.ital.mod | String | 'italic' |
A string added to the face and size when determining the italic font in the label text. | ||||||||||||||||||||||||
font.ital.vadjust | String | 0 |
A font-specific correction to the vertical positioning of the italic font in the label text. (Positive is down.) Defaults to the base font's valign. | ||||||||||||||||||||||||
font.boldital | Object or String | false |
This object defines the details of the bold italic font in the label. A shorthand is also supported in the form 'size face
color' for example: '14px arial red' .
|
||||||||||||||||||||||||
font.boldital.color | String | '#343434' |
Color of the bold italic font in the label text. Defaults to the base font's color. | ||||||||||||||||||||||||
font.boldital.size | Number | 14 |
Size of the bold italic font in the label text. Defaults to the base font's size. | ||||||||||||||||||||||||
font.boldital.face | String | 'arial' |
Font face (or font family) of the bold italic font in the label text. Defaults to the base font's face. | ||||||||||||||||||||||||
font.boldital.mod | String | 'bold' |
A string added to the face and size when determining the bold italic font in the label text. | ||||||||||||||||||||||||
font.boldital.vadjust | String | 0 |
A font-specific correction to the vertical positioning of the bold italic font in the label text. (Positive is down.) Defaults to the base font's valign. | ||||||||||||||||||||||||
font.mono | Object or String | false |
This object defines the details of the monospaced font in the label. A shorthand is also supported in the form 'size face
color' for example: '15px courier red' .
|
||||||||||||||||||||||||
font.mono.color | String | '#343434' |
Color of the monospaced font in the label text. Defaults to the base font's color. | ||||||||||||||||||||||||
font.mono.size | Number | 15 |
Size of the monospaced font in the label text. Defaults to the base font's size. | ||||||||||||||||||||||||
font.mono.face | String | 'courier new' |
Font face (or font family) of the monospaced font in the label text. | ||||||||||||||||||||||||
font.mono.mod | String | '' |
A string added to the face and size when determining the monospaced font in the label text. | ||||||||||||||||||||||||
font.mono.vadjust | String | 2 |
A font-specific correction to the vertical positioning of the monospaced font in the label text. (Positive is down.) Defaults to the base font's valign. | ||||||||||||||||||||||||
group | String | undefined |
When not undefined , the node will belong to the defined group. Styling information of
that group will apply to this node. Node specific styling overrides group styling.
|
||||||||||||||||||||||||
heightConstraint | Number, Boolean or Object | false |
If false, no heightConstraint is applied. If a number is specified, the value is used as the minimum height of the node. The node's height will be be set to the minimum if less than the value. | ||||||||||||||||||||||||
heightConstraint.minimum | Number | undefined |
If a number is specified, the value is used as the minimum height of the node. The node's height will be be set to the minimum if less than the value. | ||||||||||||||||||||||||
heightConstraint.valign | String | 'middle' |
Valid values are 'top' , 'middle' , and 'bottom' .
When specified, if the height of the label text is less than the minimum (including any top or bottom margins), it will be offset vertically to the designated position. |
||||||||||||||||||||||||
hidden | Boolean | false |
When true, the node will not be shown. It will still be part of the physics simulation though! | ||||||||||||||||||||||||
icon | Object | Object |
These options are only used when the shape is set to icon . |
||||||||||||||||||||||||
icon.face | String | 'FontAwesome' |
These options are only used when the shape is set to icon . The possible options for the
face are: 'FontAwesome' and 'Ionicons' .
|
||||||||||||||||||||||||
icon.code | String | undefined |
This is the code of the icon, for example '\uf007' . |
||||||||||||||||||||||||
icon.size | Number | 50 |
The size of the icon. | ||||||||||||||||||||||||
icon.color | String | '#2B7CE9' |
The color of the icon. | ||||||||||||||||||||||||
id | String | undefined |
The id of the node. The id is mandatory for nodes and they have to be unique. This should obviously be set per node, not globally. | ||||||||||||||||||||||||
image | String | undefined |
When the shape is set to image or circularImage , this option should be the URL
to an image. If the image cannot be found, the brokenImage option can be used.
|
||||||||||||||||||||||||
label | String | undefined |
The label is the piece of text shown in or under the node, depending on the shape. | ||||||||||||||||||||||||
labelHighlightBold | Boolean | true |
Determines whether or not the label becomes bold when the node is selected. | ||||||||||||||||||||||||
level | Number | undefined |
When using the hierarchical layout, the level determines where the node is going to be positioned. | ||||||||||||||||||||||||
margin | Object or Number | 5 |
If a number is specified, the margins of the label are set to that value on all sides. These options are only used when the shape is set to box , circle , database , icon or text . |
||||||||||||||||||||||||
margin.top | Number | 5 |
The top margin of the label is set to this value. | ||||||||||||||||||||||||
margin.right | Number | 5 |
The right margin of the label is set to this value. | ||||||||||||||||||||||||
margin.bottom | Number | 5 |
The bottom margin of the label is set to this value. | ||||||||||||||||||||||||
margin.left | Number | 5 |
The left margin of the label is set to this value. | ||||||||||||||||||||||||
mass | Number | 1 |
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. | ||||||||||||||||||||||||
physics | Boolean | true |
When false, the node is not part of the physics simulation. It will not move except for from manual dragging. | ||||||||||||||||||||||||
scaling | Object | Object |
If the value 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.
Only scalable when label scaling is enabled are:
ellipse , circle , database , box , text .
Always scalable are:
image , circularImage , diamond , dot ,
star , triangle , triangleDown , square and
icon . Keep in mind that when using scaling, the size option is neglected.
|
||||||||||||||||||||||||
scaling.min | Number | 10 |
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. | ||||||||||||||||||||||||
scaling.max | Number | 30 |
This is the maximum allowed size when the nodes are scaled using the value option. | ||||||||||||||||||||||||
scaling.label | Object or Boolean | Object |
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. | ||||||||||||||||||||||||
scaling.label.enabled | Boolean | false |
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. | ||||||||||||||||||||||||
scaling.label.min | Number | 14 |
The minimum font-size used for labels when scaling. | ||||||||||||||||||||||||
scaling.label.max | Number | 30 |
The maximum font-size used for labels when scaling. | ||||||||||||||||||||||||
scaling.label.maxVisible | Number | 30 |
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%. | ||||||||||||||||||||||||
scaling.label.drawThreshold | Number | 5 |
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. | ||||||||||||||||||||||||
scaling.customScalingFunction | Function | in description | If nodes have value fields, this function determines how the size of the nodes are scaled
based on their values. The default function is:
function (min,max,total,value) { if (max === min) { return 0.5; } else { var scale = 1 / (max - min); return Math.max(0,(value - min)*scale); } }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. It has to return a value between 0 and 1. The nodes and edges then calculate their size as follows: var scale = customScalingFunction(min,max,total,value); var diff = maxSize - minSize; mySize = minSize + diff * scale;Please note: maxSize and minSize are the values scaling.max
and scaling.min provided in the options.
|
||||||||||||||||||||||||
shadow | Object or Boolean | Object |
When true, the node casts a shadow using the default settings. This can be further refined by supplying an object. | ||||||||||||||||||||||||
shadow.enabled | Boolean | false |
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. | ||||||||||||||||||||||||
shadow.color | String | 'rgba(0,0,0,0.5)' |
The color size of the shadow as a string. Supported formats are 'rgb(255,255,255)', 'rgba(255,255,255,1)' and '#FFFFFF'. | ||||||||||||||||||||||||
shadow.size | Number | 10 |
The blur size of the shadow. | ||||||||||||||||||||||||
shadow.x | Number | 5 |
The x offset. | ||||||||||||||||||||||||
shadow.y | Number | 5 |
The y offset. | ||||||||||||||||||||||||
shape | String | 'ellipse' |
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:
ellipse , circle , database , box , text .
The ones with the label outside of it are: image , circularImage ,
diamond , dot , star , triangle ,
triangleDown , square and icon .
|
||||||||||||||||||||||||
shapeProperties | Object | Object |
This object contains configuration for specific shapes | ||||||||||||||||||||||||
shapeProperties.borderDashes | Array or Boolean | false |
This property applies to all shapes that have borders. You set the dashes by supplying an Array. Array formart: [dash length, gap length]. You can also use a Boolean, false is disable and true is default [5,15]. | ||||||||||||||||||||||||
shapeProperties.borderRadius | Number | 6 |
This property is used only for the box shape. It allows you to determine the roundness of the corners of the shape.
|
||||||||||||||||||||||||
shapeProperties.interpolation | Boolean | true |
This property only applies to the image and circularImage shapes. When true, the image is resampled when scaled down, resulting in a nicer image at the cost of computional time.
|
||||||||||||||||||||||||
shapeProperties.useImageSize | Boolean | false |
This property only applies to the image and circularImage shapes. When false, the size option is used, when true, the size of the image is used. Important: if this is set to true, the image cannot be scaled with the value option! |
||||||||||||||||||||||||
shapeProperties.useBorderWithImage | Boolean | false |
This property only applies to the image shape.
When true, the color object is used. A rectangle with the background color is
drawn behind it and it has a border. This means all border options are taken into account.
|
||||||||||||||||||||||||
size | Number | 25 |
The size is used to determine the size of node shapes that do not have the label inside of them. These
shapes are: image , circularImage , diamond , dot ,
star , triangle , triangleDown , square and
icon |
||||||||||||||||||||||||
title | String or Element | undefined |
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. | ||||||||||||||||||||||||
value | Number | undefined |
When a value is set, the nodes will be scaled using the options in the scaling object defined above. | ||||||||||||||||||||||||
widthConstraint | Number, Boolean or Object | false |
If false, no widthConstraint is applied. If a number is specified, the minimum and maximum widths of the node are set to the value. The node's label's lines will be broken on spaces to stay below the maximum and the node's width will be set to the minimum if less than the value. | ||||||||||||||||||||||||
widthConstraint.minimum | Number | undefined |
If a number is specified, the minimum width of the node is set to the value. The node's width will be set to the minimum if less than the value. | ||||||||||||||||||||||||
widthConstraint.maximum | Number | undefined |
If a number is specified, the maximum width of the node is set to the value. The node's label's lines will be broken on spaces to stay below the maximum. | ||||||||||||||||||||||||
x | Number | undefined |
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. | ||||||||||||||||||||||||
y | Number | undefined |
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. |