2👍
A quick answer would be to use something like
Template.analysisChart.rendered = function(){
Tracker.autorun(function(){
var data = Questions_Users.find();
drawChart();
})
}
Or look into observeChanges, something like:
Template.analysisChart.rendered = function(){
Questions_Users.find().observeChanges({
added:function(id, fields){
//update Chart.datasets
Chart.update()
}
})
}
1👍
I have an example project that just implements the update logic with Tracker and an ReactiveArray (tracker is part of Meteor’s front-end, ReactiveArray is similar to Minimongo with fetch): https://github.com/Slava/jsconf-asia-demo/blob/master/tracker.html#L47-L61
To adapt it to a Meteor app, you would start an autorun in template’s rendered
callback and depend on the minimongo query that you fetch and feed to Chart.js. Once you done, tell Chart.js to update itself.
Source:stackexchange.com