Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda