As far as I can tell, you're right - there is no way to do this within the standard D3 idiom. Presumably, this will be possible as soon as it selection.append()can take the function:
a choice. Append (name)
... , .
, (data, index) . , .enter() - .enter() .append, .insert .select, .
, , .enter(), : http://jsfiddle.net/xuJ6w/4/
var tuples = data.map(function(row) {
var newRow = [],
x;
for (x=0; x<row.length; x+=2) {
newRow.push({
label: row[x],
value: row[x+1]
})
}
return newRow;
});
var rows = d3.select('table').selectAll('tr')
.data(tuples);
rows.enter().append('tr');
var cellPairs = rows.selectAll('.cell')
.data(function(d) { return d; });
var entry = cellPairs.enter();
entry.append('th')
.attr('class', 'cell')
.text(function(d) {
return d.label;
});
entry.insert('td', 'th + th')
.attr('class', 'cell')
.text(function(d) {
return d.value;
});
, :
cellPairs
.style('background', '#CCC');
, .