D3: update data with multiple elements in a group
The key is to handle all the selections, not just the enter selection: var myGroups = svg.selectAll(‘g’).data(myData); // enter selection var myGroupsEnter = myGroups.enter().append(“g”); myGroupsEnter.append(“line”); myGroupsEnter.append(“polygon”); // … // update selection — this will also contain the newly appended elements myGroups.select(“line”).attr(…); // … // exit selection myGroups.exit().remove(); There are two things here that warrant further … Read more