user2126217
user2126217

Reputation: 301

Add an edge label with Cytoscape.js

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

Upvotes: 30

Views: 15925

Answers (1)

maxkfranz
maxkfranz

Reputation: 12242

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.

Upvotes: 51

Related Questions