I am trying to add a class to the node, to have all my css in a stylesheet file, not inside javascrpt declaration.
var values = {
nodes: [
{ data: { id: 'explore'},
classes: 'ClassName1'
},
{ data: { id: 'discover' } }
],
edges: [
{ data: { source: 'explore', target: 'discover' } }
]
};
As you can see I am adding classes and the class name, but nothing happens.
You should use selectors, Here is the solution:
var cy = cytoscape({
container: this.div[0],
style: cytoscape.stylesheet()
.selector(".ClassName1")
.css({
'background-color': 'red',
}) ,
elements: values ,
layout: 'MyLayout'
});
cy.layout();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With