Add an edge label with Cytoscape.js

user2126217 picture user2126217 · Mar 2, 2013 · Viewed 11.1k times · Source

How can I add a label on an edge using Cytoscape.js?

Answer

maxkfranz picture maxkfranz · Mar 4, 2013

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.