Search code examples
filtercytoscape.js

Select elements in cytoscape.js using "or" operator


I want to select nodes in cytoscape using operators "and" and "or".

Based on the [cytoscape.js][1] document

[1]: https://js.cytoscape.org/#selectors, the users can use the below syntax for "and" operator, but i couldn't find any syntax for "or" operator.

// get all nodes with weight more than 50 and height strictly less than 180
cy.elements("node[weight >= 50][height < 180]");

How to filter nodes with "or" operator?


Solution

  • Below should work. Give attention to the COMMA. Comma is used for logical OR

    cy.nodes("[weight >= 50],[height < 180]");