Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
How can I inject a variable in selectors in Cytoscape JS?

I am trying to visualize edges of a graph with different widths by selecting edges based on their id fields. Is it possible to use variables in selector queries? How can I achieve this behaviour? There are ways to work around this by repeating code, for example:

if (i==0){  
        edge_item = cy.elements('edge[id = "edge_0"]');

        cy.style()
          .selector(edge_item)
          .style({
          'width': 10
          })
          .update();
      }

I would however prefer a cleaner solution, preferably by using a variable instead of "edge_0" above with something like the following:

edge_var = "edge_" + i;
edge_item = cy.elements('edge[id = "edge_var"]');

Is this possible?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Apparently, this is done by escaped characters.

var nodeId = "edge_";
  for (var i = 0; i < 60; i++) {
  cy.remove('edge[id=\'' + nodeId.concat(i.toString()) + '\']');
  }

I came across the answer to this post here in a similar setting.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!