So I'm trying to build a pie chart using chartjs in meteor.
I'm pretty sure the problem is that the order of precedence is talking over here.
I need the object in this order
{
value: 900.65,
color:"#red",
highlight: "#FF5A5E",
label: "income"
}
but i get it in this order
{
color: "#red"
highlight: "#FF5A5E"
label: "income"
value: 900.65
}
This is my loop
function drawExpPie(){
data = [];
var Task = Tasks.find({},{fields:{value:1,text:1}}).fetch();
for(var i = 0; i < Task.length; i++) {
var newdataset = {
label:Task[i].text,
highlight: "#FCA456",
color: "red",
value:Task[i].value,
};
data.push(newdataset);
}
console.log(data);
var context = document.getElementById('myExpChart').getContext('2d');
var myPieChart = new Chart(context).Pie(data);
}
Template.exp.helpers({
exp: function() {return Session.get("exp");}
});
Template.exp.rendered = function(){
drawExpPie();
};
Any help is appreciated. Thanks