You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this code doesn't work anymore because d3 is selecting the wrong element. In fact, I have lost the only reference to the element, because this was not overridden by d3.
How can I change d3.select(this) so that it works?
The text was updated successfully, but these errors were encountered:
d object may be holding a property that could be used as a reference (like DOM Object) or a selector string to itself
Or
varmainSelection=d3.selectAll(".region");mainSelection.each((d,i)=>{mainSelection[i].style("fill"...// Not sure if it's indexed.// d3.select(mainSelection[i]).style(... // would be my 2nd try});
ES6 arrow functions lexically bind this, which prevents you from being able to access the this context of the selected node set by D3. There’s no way to fix this globally without abandoning the use of this as the selected node; some potential approaches are discussed in #2246.
I had this code:
With ES6, I can use the arrow notation to avoid overwriting
this
:However, this code doesn't work anymore because d3 is selecting the wrong element. In fact, I have lost the only reference to the element, because
this
was not overridden by d3.How can I change
d3.select(this)
so that it works?The text was updated successfully, but these errors were encountered: