Key Functions for Data Joins
The data operator also accepts a key function:
d3.selectAll(...)
.data([{id:"42",value:1028}, ...],
function(d) { return d.id; })
The key function is used to uniquely join data elements with
DOM elements. Unmatched keys are assigned to the enter selection
(for data without a matching DOM element)
or the exit selection (vice versa).