link.label(index, properties)
Set properties
on a label indexed by index
. A link can have multiple labels each having different position and attributes.
labels
{
position: <number>,
attrs: { <selector>: <SVG attributes> }
}
Where position
is the position of the label with regard to the link .connection
SVG path. If the position
is in [0,1]
interval then the position of the label is considered to be defined as a percentage of the total length of the .connection
path. E.g. position 0.5
puts the label to the middle of the link. If the position is >1
then the label will be put position
pixels starting from the beginning of the .connection
path. position <0
puts the label Math.abs(position)
pixels starting from the end of the .connection
path.
attrs
is again an object with CSS selectors as keys and SVG attributes as values. The label markup is defined as follows:
<g class="label">
<rect />
<text />
</g>
Where <rect>
is a box below the label.
link.label(0, {
position: .5,
attrs: {
rect: { fill: 'white' },
text: { fill: 'blue', text: 'my label' }
}
});