Is there a way to display a node label centered inside the node such as cytoscape desktop does by default?
Label display inside nodes cytoscape.js
Asked Answered
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, ... })
I set css style for nodes and it works:
"text-valign" : "center"
"text-halign" : "center"
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
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, ... })
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.
© 2022 - 2024 — McMap. All rights reserved.