Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!