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

306
Vistas
D3 - how to fire an on-click function for only a specific group of nodes

In this d3 force layout viz project I'm trying to remove the user's ability to click on the bigger yellow nodes. I have an on-click, fire the clicknodeControl function,

 nodes.append('circle')
  .attr("r", 28)  
  .attr("id", "hoverdots")
  .style("opacity", 0) 
  .style("fill", "#00bedd") 
  .on("click", function(d) { return clicknodeControl(d.group); }) 
  .style("z-index", "10")
  .on("mouseover", mouseover)
  .on("mouseout", mouseout)

and then ideally this variable would pass through the clicknode function to one group of nodes but not the other:

 var clicknodeControl = d3.scaleOrdinal([`clicknode`, ``]);

This does not seem to be working in practice, the clicknode function is not being passed through.

Thanks if anyone has any ideas on this!!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In D3 V7 mouse event handlers have event as the first argument and datum as the second.

Replace

.on("click", function(d) { return clicknodeControl(d.group); }) 

with:

.on("click", (_, d) => clicknodeControl(d.group)) 
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