How can I add a label on an edge using Cytoscape.js?
Asked
Active
Viewed 1.5k times
1 Answers
48
Map the label
style property to a data field:
e.g. in the stylesheet on init
...
{
selector: 'edge',
style: {
'label': 'data(label)' // maps to data.label
}
}
...
http://cytoscape.github.com/cytoscape.js/#style/properties
Older versions use content:
in place of label:
. Newer versions of 2.x allow label
and also content
for backwards compatibility.

maxkfranz
- 11,896
- 1
- 27
- 36
-
Hey maxkfranz can u tell i have node id which i got from some text box how can i select that node in graph by triggering any event. I want to do something like basic code of click fucntion in cytoscape graph works but my user will enter node id in textfield. – Imran Jawaid Jul 16 '14 at 18:48
-
`label` does not work for me although I use cytoscapejs 2.4.9. `content` works, indeed. – fracz Apr 05 '16 at 09:35
-
@maxkfranz is there a way to handle if label is null?? – Ebikeneser Nov 19 '20 at 15:08