d3.js - Meteor, where to put d3 code? -
d3.js - Meteor, where to put d3 code? -
i utilize meteor, iron-router, , d3. d3 used reactively display pie chart based on data, calculate in info function of iron-router. so, want d3 run when dom in place.
however, don't know should set d3 code. used set in info function generate data. however, info function computed while dom not ready (so d3 cannot draw chart).
i want run d3 after dom rendered, , function can access result of info function. tried utilize hooks onafteraction, seems function cannot access data. tried utilize template..rendered, other posts in stackoverflow says. however, rendered function seems run once, , doesn't re-run when info changes. set rendered function in tracker.autorun function, still run once.
so, there place run d3 code reactively can access rendered dom info field?
thanks.
you should utilize onrendered callback template autorun. out of box doesn't work 1.0
, there's trick - can autorun rerun after context alter using template.currentdata this:
template.mypictures.onrendered(function () { this.autorun(function () { var info = template.currentdata(); // utilize info d3 here }); });
for more details, see end of this issue.
d3.js meteor iron-router
Comments
Post a Comment