mySelection.datum( func ) in D3.js

Set the data associated with elements in the selection based on existing data.

Arguments

nametypedescription
func Function This function is invoked for each selected element, being passed the previous datum d and the current index i, with the this context as the current DOM element. The return value of this function is used to set each element’s data. A null value will delete the bound data.
Return Type
Selection

Description

For more details see https://github.com/mbostock/d3/wiki/Selections#wiki-datum.

See Also