Label display inside nodes cytoscape.js
Asked Answered
K

3

5

Is there a way to display a node label centered inside the node such as cytoscape desktop does by default?

Kelton answered 29/6, 2012 at 9:34 Comment(0)
J
3

Yes, you can control this with the labelValign property as explained in the Wiki StyleObject description. For example:

var myStyle = {
    selectors: {
        "node": {
            labelValign: "middle",
            ... } } }

$("#cy").cy({style: myStyle, ... })
Jailbreak answered 29/6, 2012 at 13:45 Comment(0)
Q
17

I set css style for nodes and it works:

"text-valign" : "center"
"text-halign" : "center"
Quark answered 13/12, 2012 at 13:5 Comment(2)
I am not sure if I want to upvote or downvote. text-valign and text-halign really DO work, however they are certainly not css properties.Tewell
This works, but they are cytoscape-js styles though.Irremissible
J
3

Yes, you can control this with the labelValign property as explained in the Wiki StyleObject description. For example:

var myStyle = {
    selectors: {
        "node": {
            labelValign: "middle",
            ... } } }

$("#cy").cy({style: myStyle, ... })
Jailbreak answered 29/6, 2012 at 13:45 Comment(0)
T
0

From the official and actual documentation - text-valign and text-halign are the way to go. They are certainly not css properties however. The possible options are: text-halign - left, center, or right; text-valign - top, center, or bottom.

These options work only for nodes, not for edges.

Offical documentation for more info

Tewell answered 17/12, 2015 at 16:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.