link.label(index, properties, opt)

Set properties on a label indexed by index. A link can have multiple labels each having different position and attributes.

{
    markup: <string>,
    position: <number>,
    attrs: { <selector>: <SVG attributes | JointJS attributes> }
}

Where position is the position of the label with regard to the link .connection SVG path. It's supposed to be an object with distance and offset properties. Where distance defined as below.

And offset defined as below. Alernatively the position could be defined as a number that behaves as distance defined above.

attrs is again an object with CSS selectors as keys and SVG attributes as values. The default 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' }
    }
});

Note that all labels are stored in an array on the link model under the attribute labels.

link.prop('labels'); // returns an array of label properties