Skip to content

xAlignment: 'left' for multi line text #1679

Discussion options

You must be logged in to vote

Use the SVG textAnchor attribute (MDN documentation) to align text horizontally.

rect.attr({
    label: {
        text: inputText + '\n' + title + '\n' + value,
        textAnchor: 'start'
    }
});

And JointJS textVerticalAnchor custom attribute (JointJS documentation) to align text vertically.

rect.attr({
    label: {
        text: inputText + '\n' + title + '\n' + value,
        x: 'calc(0.5 * w)',
        // position the text 10 pixels above the element
        y: -10,
        textVerticalAnchor: 'bottom'
    }
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@YongheeMinnovation
Comment options

Answer selected by YongheeMinnovation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants