Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

291
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda