cytoscape js initialisation element style by id

haz Source

Supposing I've set the style options like this:

style: [
    {
      selector: 'node',
      style: {
    'label': 'data(name)',
    'font-size':'16',
    'color': 'white',
    'text-valign': 'center',
    'width': 'label',
    'height': 'label',
    'background-color': '#30c9bc',
    'shape':'roundrectangle'
      }

I know that I can set the style to a specific node programmatically jQuery style, eg

cy.$("#my_first_node").css('font-size', '30')

But how can I set a style rule during initialisation so that, for example, a node with the id = 'my_first_node' will be set with a font size of 30?

javascriptcytoscape.js

Answers

answered 6 months ago haz #1

some testing has revealed I can simply use the selector, ie

{
      selector: '#my_first_node',
      style: {
    'label': 'data(name)',
    'font-size':'30',
    'color': 'white',
    'text-valign': 'center',
    'width': 'label',
    'height': 'label',
    'background-color': '#30c9bc',
    'shape':'roundrectangle'
      }

comments powered by Disqus