I have the following fields as my nodes data:
nodes {
data: {id: "something", type: "human"}
data: {id: "somethingElse", type: "mouse"}
}
Is there any way to set the shapes of the nodes based on the type
in data
?
You can structure the cytoscape style element and selectors, like in the code snippet below:
style: [
{
selector: 'node[type="human"]',
style: {
'shape': 'triangle',
'background-color': 'red'
}
},
{
selector: 'node[type="mouse"]',
style: {
'shape': 'square',
'background-color': 'blue'
}
}
]
Use a stylesheet with appropriate selectors, e.g.:
node[type = 'foo'] {
background-color: red;
shape: star;
/* ... */
}
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