Example of d3 key functions data binding First time the data is binded but the keyfunction links extra information Second or additional times this can be used to lookup the associated link e g by name in this example script src https d3js org d3 v7 min js script script function id d return d name let a name bob val 22 name joe val 3 name abc val 33 d3 selectAll span data a id enter append span text d d name d val let b name joe val 3 name bob val 4 name abc val 5 d3 selectAll span data b id text d d name d val script
val 22 name joe val 3 name abc val 33 d3 selectAll span data a id enter append span text d d name d val let b name joe val 3 name bob val 4 name abc val 5 d3 selectAll span data b id text d d name d val script