javascript - All data is in enter() placeholder (D3) -
i've got update function code:
// actualy fetched server. array of js objects parsed right type var xdata = [{ id: 234234 // parsed integer date: 15/11/2001 // parsed date price: 6512 // parsed integer }]; // triggred user function updatesvg() { // fetch new data ther server xdata = []; xdata = [{ id: 234234 // parsed integer data: 15/11/2001 // parsed date price: 6512 // parsed integer }]; // join data var x = svg.selectall(".x-class") .data(xdata, function(d) { return d.id; }); // new data x.enter().append("image") .attr('class', 'x-class') .attr("xlink:href", "x-image.png") .attr("width", 16) .attr("height", 19) .attr('y', 0); // current , new data x.transition() .attr("x", function(d) { return x(d.date); }) .attr("y", function(d) { return y(d.date); }); /// old data x.exit().remove(); }
what expect when run function second or third time, of data update (i.e. not in enter), , few of data in enter() , exit().
but data in enter(). no matter what. d.id unique sure. works expected issue. when inspect x object before , after fetche new data, data in enter() placeholder.
any ideas? missing?
code problems (let know if of these help):
what
x
in case ofx(d.date)
? meanxdata
here?x.attr("x", function(d) { return x(d.date); })
what doing? haven't defined
data
, ory
. (orarrayobjectindexof
,yoffset
suspect implied)return y(data[arrayobjectindexof(data, d.date, 'date')].price) - yoffset;
also, since d3 data manipulation library, it's more difficult when don't know data looks like. idea (d.date
) important here (since you're apparently finding price elsewhere instead of doing d.price
)
Comments
Post a Comment