Skip to content

Appearance Customization

Specifying style configurations by values

Change the appearance of each node and edge

In Node and Edge configuration, instead of concrete values, you can specify functions that return a configuration value with each node or edge as an argument. In addition, by explicitly specifying the Node or Edge type in UserConfigs, you can specify the argument type of the function.

Adding or removing nodes and links with customized appearance can also be reflected by changing the data of reactive data.

Custom Node

In case you want to change not only the shape of the node, but also its elements and behavior, it is now possible to replace the components of the node.

The following is an example of replacing the default node component with a combination of a circle and an icon.
Arranging the SVG elements in the override-node slot will replace the default nodes with them. In this slot, the (0, 0) position is the center of the node.

Note that if you want to replace the label of a node, you can do by using the override-node-label slot.

An example of specifying an image instead of an icon is shown below.
The images of the faces ware created https://generated.photos/.

Z-order of Nodes

The z-index of nodes can be specified to control the order of the nodes in the z-direction.
Since there is no concept of z-index in SVG, this feature is achieved by sorting the internal node objects. It is disabled by default for performance reasons. If configs.node.zOrder.enabled is set to true, this feature will be enabled.

In addition to specifying the z-index based on the properties of the node itself, it is also possible to move to the topmost when it is mouse hovered or selected.

Z-order of Edges

It is also possible to control the z-order of the edges as well as the nodes.

Arrow on edges

Markers such as arrow head can be specified for edges.

The following configuration items can be specified for configs.edge.marker.source and configs.edge.marker.target.

configdescription
type Type of marker. The supported values are as follows:
none
arrow
angle
circle
customPlease see customId
widthHorizontal length of the marker when the edge is placed horizontally.
heightVertical length of the marker when the edge is placed horizontally.
margin Distance between the marker and the end of the edge.
A negative value can also be specified.
offset Offset perpendicular to the edge line.
When the edge faces up, offset to the right if this value is positive and to the left if it is negative.
color Color of the marker. If null specified, the marker will be the same color as the edge stroke.
In this way, if an edge is selected or mouse hovered over, and the color of the edge changes, the marker will automatically change along with the color of the edge.
units This config is reflected in the markerUnits attribute of the SVG <marker> element.
If "strokeWidth" is specified, the width, height, and margin configs of the marker will be applied in units of the current edge's stroke-width value as 1. Therefore, these sizes will also change depending on the thickness of the edge.
If "userSpaceOnUse" is specified, the width, height, and margin configs of the marker will be the same as the ordinary coordinate units. It will not be affected by the thickness of the current edge.
customId When "custom" is specified for type, specify the ID of the marker you created in this config.

Custom markers on edges

In addition to the preset marker types, you can also specify your own markers.

Place any object on the edge

The markers shown above can only be displayed at the terminate point of an edge.
Placing an object besides the endpoint of an edge can be achieved by using an "edge-overlay" slot.
In the following example, a triangle toward the target is displayed at the center of the edge.

The "edge-overlay" slot properties contains the length of the edge and a function to get the coordinates of the specified length from the source side. By using these properties, any object can be drawn on the path of the edge.

Keep order of edges

In some cases, when there are multiple edges between two nodes, it is necessary to arrange the order of the edges from top to bottom, no matter which node is placed on the left side.
It is possible to handle such a case by specifying the edge.keepOrder config.
The following values can be specified for this config.

valuedescription
"clock" Keep the forward/backward when viewed as a clock.
"vertical" Keep the vertical alignment.
Even if the left and right sides of a node are swapped, the edge on top remains on top.
"horizontal" Keep the horizontal alignment.
Even if the top and bottom of the node are swapped, the edge on the left remains on the left.

Note that the basic display order is the order in which the edges appear in the given edges.

Self-loop edge

If the source and target of an edge are the same node, the edge is displayed as an arc.
Configuration regarding self-loop configs.edge.selfLoop can also specify a function that takes an edge as an argument.

This implementation is a simplified one and, different from normal edges, has the following limitations.

  • No label can be displayed.
  • Multiple edges cannot be summarized on a single line.
  • Supports only circle as node type

Style examples