I'm trying to populate data on my google chart with AngularJS. However not is return the object. See:
function drawNew($scope,conf,GetData,i) {
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = addData(GetData,conf);
var chart = new google.visualization.BarChart(document.getElementById('chart_div'+i));
chart.draw(data, {title: "OOOPOPOP", width: 800, height: 300});
}
}
function addData(GetData,abelua) {
GetData.Values(abelua)
.then(function(msg) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Assertivas');
data.addColumn('number', 'Contador');
data.addColumn({type: 'number', role: 'annotation'});
data.addRows(msg.data.length);
angular.forEach(msg.data,function(value,key){
data.setCell(key,0, value.ASSERTIVA);
data.setCell(key,1, value.CONTADOR);
data.setCell(key,2, value.CONTADOR);
});
});
return data;
}
On My Service:
function Values(conf) {
return $http.post('php/Values.php',conf);
}
On addData
not is returning the object with data populating. What is wrong ?
Thanks!