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

195
Visualizações
mouseover not working as an arrow function?

I have the function below:

.on("mouseover", function(d, i) {
    d3.select(this)
      .attr("fill", "red");
})

However, I wanted to try writing it as an arrow function, so I found that this tutorial and got this:

.on("mouseover", (d, i, nodes) => {
    d3.select(nodes[i])
      .attr("fill", "red");
})

However, whenever I try running it, I keep getting an error that says TypeError: undefined is not an object (evaluating 'nodes[i]').

I have also tried replacing nodes and just calling this but it seems that no matter what I try, arrow functions don't work here. I feel like it shouldn't be a version issue since I'm using v7 of d3. Can anyone explain what the issue is here?

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I figured it out. Apparently starting since v6, the arrow function solutions provided in the link above is no longer possible, according to this discussion

So now the current solution would be:

.on("mouseover", (d) => {
    d3.select(d.currentTarget)
      .attr("fill", "red");
})
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