Skip to main content

Port label layouts

layout.PortLabel import provides built-in label layout functions.

Built-in port label layouts

Inside/Outside

Places the label inside or outside of a rectangular shape. Where 'oriented' versions rotate the text towards the element center. The args object is optional.

namestring

Can be either 'inside', 'outside', 'insideOriented', or 'outsideOriented'.

argsobject
offsetnumberOffset in direction from the shape's center. Overridden by x and y values, if provided.
xnumberOverrides the x value calculated by the layout function.
ynumberOverrides the y value calculated by the layout function.
anglenumberThe port label rotation angle (in degrees in clockwise direction). Overrides the value calculated by the 'insideOriented' and 'outsideOriented' layout functions.
attrsobjectJointJS-style attributes applied on label's DOM element and its children. The same notation as the attrs property on Element. Overridden by port group attrs, if provided.
label: {
position: {
name :'outsideOriented',
args: {
offset: 10,
attrs: {}
}
}
}

Manual placement

It allows setting label position directly.

namestring

'manual'

argsobject
xnumberSets the label's x coordinate.
ynumberSets the label's y coordinate.
anglenumberThe port label rotation angle (in degrees in clockwise direction).
attrsobjectJointJS-style attributes applied on label's DOM element and its children. The same notation as the attrs property on Element. Overridden by port group attrs, if provided.
label: {
position: {
name: 'manual',
args: {
x: 10,
y: 20,
angle: 45,
attrs: {}
}
}
}

On Sides

Simple label layout suitable for rectangular shapes. It places the label on arbitrary side of a port. The args object is optional.

namestring

Can be either 'left', 'right', 'top', or 'bottom'.

argsobject
xnumberOverrides the x value calculated by the layout function.
ynumberOverrides the y value calculated by the layout function.
anglenumberThe port label rotation angle (in degrees in clockwise direction).
attrsobjectJointJS-style attributes applied on label's DOM element and its children. The same notation as the attrs property on Element. Overridden by port group attrs, if provided.
label: {
position: {
name : 'right',
args: {
x: 0,
y: 0,
angle: 0,
attrs: {}
}
}
}

Radial

Places the label outside of a circular shape. Where the 'oriented' version rotates the text towards the element center. The args object is optional.

namestring

Can be either 'radial', or 'radialOriented'.

argsobject
offsetnumberOffset in direction from the shape's center. Overridden by x and y values, if provided.
xnumberOverrides the x value calculated by the layout function.
ynumberOverrides the y value calculated by the layout function.
anglenumberThe port label rotation angle (in degrees in clockwise direction). Overrides the value calculated by the 'radialOriented' layout function.
attrsnumberJointJS-style attributes applied on label's DOM element and its children. The same notation as the attrs property on Element. Overridden by port group attrs, if provided.
label: {
position: {
name :'radialOriented',
args: {
offset: 0,
attrs: {}
}
}
}

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub