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

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

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 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