Let's supose i have something like this:
$scope.playersData = [{
"label": obj.data[0].player,
"color": colors[0],
"data": obj.data[0].value
}, {
"label": obj.data[1].player,
"color": colors[1],
"data": obj.data[1].value
}];
This works if i have always only 2 items in obj.data.
Now, if i want to add values dynamically in a For Loop, how do i do it?
I tried something like this, not working:
var temparray = [];
for (var i = 0; i < data.length; i++) {
temparray[i] = {"label": obj.data[i].player,"color": colors[i],"data": obj.data[i].value};
}
.push(), but even as it stands, that should be good enough. What exactly isn't working here? BTW, shouldn't you check fori < obj.data.lengthinstead?data.lengthorobj.data.length?