javascript - How do I pass bound data to nested selections in D3? -
i'm trying build , update table using d3 selectors, i'm having issues updating rows after creation. following code tries bind rows in table incoming [object]
, each name
, value
fields.
var table = d3.select("#datatable"); var binding = table.selectall("tr.data") .data(data, function(d) { return d.name; }); var enterbinding = binding.enter(); var updatebinding = binding; updatebinding.selectall("td").text(function(d) { if(d3.select(this).classed("name")) { return d.name; } else { return d.value; } }); var newrows = enterbinding.append("tr").classed("data", true); newrows.append("td") .classed("name", true) .text(function(d) { return d.name; }); newrows.append("td") .classed("value", true) .text(function(d) { return json.stringify(d.value); });
the rows created properly, , right data. update selection occur , handlers called data presented anonymous function (supplied updatebinding.selectall.text
above) old , never changes.
can not depend on nested selections on binding
contain date data way i'm using here?
is there better way update nested elements <td>
s?
Comments
Post a Comment