Accepted answer

Based on advice from Lars Kotfoff :

Working fiddle here

If the elements to be graph-ed already exist, simply skip the enter() D3 phase and use select() or selectAll() based on a common characteristic of your elements ( a class name for instance ).

This is how the element got created ( added a specific class for allowing an isolated selection ):

var element0a = svgContainer.append("g").attr("class","node").attr("transform","translate(100,100)");
var element0b = element0a.append("rect").attr("x",0).attr("y",0).attr("width",20).attr("height",10).attr("fill","red");

This is thene part of the code replacing the enter() phase

var node = svgContainer.selectAll("g.node")

This is what was removed

var node = svgContainer.selectAll("g.node")
    .attr("class", "node")

// HERE (below) COMES THE ISSUE, where you see append("cicle") I want to append the nodeArray's ".ui" element. 

node.append("circle")          // <--- 
    .attr("class", "node")


The problem is that you append the elements to svgContainer to create them, thus they are already attached to something.

What I would suggest as a workaround is to store the element properties in a json file and then read the configuration from the json.

There might be something more elegant.

Related Query

More Query from same tag