d3 data vs datum

If you have a static chart, eg you don’t add a new line to the chart, then you can use .datum().

If you have data that dynamically change, use .data(). This gives you, enter, update and exit pattern. (Enter; the nodes that are incoming, Update; same nodes, but you might want to change color, position etc, Exit: nodes that are no longer in the data, quite often you will just remove these)

Thanks to Haakon Thor Brunstad in D3 slack for the succinct explanation

Leave a comment