block by kenpenn c13d62dd437b5eb8bd76df9828adc3db

D3 v3 set datum

Full Screen

Using d3 v3 to set and use .datum() on elements

With d3 v3, when you set .datum() on an element created from blah.selectAll(“blahblah”).enter(),

the datum is bound to the element, and can be used later.

With d3 v4, when you set .datum() on an element created from blah.selectAll(“blahblah”).enter(),

the element is bound to the .data() of the .enter(), and any .datum() you set cannot be used later,

unless you create a new selection that’s not bound to the data.

Compare this example to d3 v4 set datum.

index.html