Search code examples
javascriptcytoscape.jscytoscape

Manipulate content style in cytoscape.js


In cytoscape.js I can style nodes with

style: [
  {
    selector: 'node',
    style: {
      'content': 'data(id)',
    }
  },

When I change the content to 'content': 'data(id), data(id)', it just interprets it as a string.

Is it possible to handle the variables as variables instead of just a string?


Solution

  • Use a function:

    content: function( ele ){ return 'foo' + ele.data('bar') + 'baz'; }
    

    http://js.cytoscape.org/#style/mappers