I would like to create multiple non-nested elements using d3 to create a structure like this:
from data[0] &l
Similar to the above but in a different idiom. This is truer to the nested selections approach and eliminates the need for sorting or insertion:
var divs = d3.select('#parent');
var ps = divs.selectAll('#parent > div')
.data(d3.range(3)).enter().append('div');
ps.append('p').html(function(d,i) { return 'from data[' + i + ']'; });
ps.append('p').html(function(d,i) { return 'from data[' + i + ']'; });
More elegantly (and probably faster):
var divs = d3.select('#parent');
var ps = divs.selectAll('#parent > div')
.data(d3.range(3)).enter().append('div');
ps.append('p').html(function(d,i) { return 'from data[' + i + ']'; })
.select(function() { return this.parentNode.appendChild(this.cloneNode(true)); });