I have a force simulation graph using d3 v4. Each node is bound to some data, which I use for example to determine the radius of each node.
The underlying bound data is updated periodically, and for some nodes it changes, and for others it stays the same.
I want to be able to select just those DOM elements for which the bound data changes, so that I can highlight these elements on my graph.
For example, suppose that initially my data (which is bound to the forceSimulation nodes) is:
data = [{id: 1, type: 0}, {id: 2, type: 1}]
and it is then updated to:
data = [{id: 1, type: 1}, {id: 2, type: 1}]
I'd like to be able to select just the DOM element that corresponds to id=1 so that I can for example make the colour change temporarily.
The update selection contains both id=1 and id=2 - I could maintain an internal mapping of previous data values and compare, but this seems inefficient.
Thanks, Adam