Skip to content Skip to sidebar Skip to footer

D3.js Trying To Animate Data, But Changed Data Always Treated As New

I have json data: an array of frames, each frame is an array of 10 nodes, and each node is a dictionary with the node id and x,y coordinates. I want to create a d3 animation that t

Solution 1:

You were very close. Just make sure you select the elements you have created (.attr("class", "node");). So:

var nodes = svg.selectAll(".node")
    .data(graphFrame);

You were selecting on "node" which does not exist and so the enter selection was always set. And it is fine to just let the data bind be based on the index, the default, since you are basically moving the same items (=same index) in the selection.

Here is a complete working PLUNK.

Post a Comment for "D3.js Trying To Animate Data, But Changed Data Always Treated As New"