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!
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");
})