Jose Villaveces
Jose Villaveces

Reputation: 91

Label display inside nodes cytoscape.js

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

Upvotes: 5

Views: 7331

Answers (3)

Atanas Kamburov
Atanas Kamburov

Reputation: 103

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, ... })

Upvotes: 3

Unknown
Unknown

Reputation: 1397

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

Upvotes: 0

Luiz Veronesi
Luiz Veronesi

Reputation: 428

I set css style for nodes and it works:

"text-valign" : "center"
"text-halign" : "center"

Upvotes: 17

Related Questions