๐:0
Right now you are trying to create chart without waiting your post call return data. Move your chart creation code into $.post callback like this:
$.post("<?php echo base_url(). ;?>",
function(data){
var obj = JSON.parse(data);
$.each(obj,function(i,item){
numpassed.push(item.passed);
numfailed.push(item.failed);
});
var doughnutData = [
{
value: numpassed,
color:"#F7464A"
},
{
value : numfailed,
color : "#46BFBD"
},
];
new Chart(document.getElementById("doughnut").getContext("2d")).Doughnut(doughnutData);
});