I am currently working on implementing angular-google-charts
using the $http
service to retrieve data and display it on charts. I found a helpful tutorial on this blog post: since the GitHub README for angular-google-charts
lacks examples of backend data services.
Encountering the following error:
https://i.stack.imgur.com/TU9M2.png
function SomeCtrl(
$scope,
$log,
$stateParams,
googleChartApiPromise,
$http,
$q) {
googleChartApiPromise.then(function() {
$scope.goodsAndServicesChartObject = {};
init();
function init() {
var dataPromise = $http.get('businesses/' + $stateParams.businessId + '/contact_users/gender');
$q.all({
data: dataPromise,
api: googleChartApiPromise
})
.then(apiLoadSuccess);
}
function apiLoadSuccess(result) {
$scope.goodsAndServicesChartObject.type = 'PieChart';
$scope.goodsAndServicesChartObject.options = {
'title': 'Goods Vs Services'
};
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('number', 'Value');
data.addRows(result.data.data);
$scope.goodsAndServicesChartObject.data = data;
}
});
}
On occasions, an image is loaded even when googleChartApiPromise
is not undefined
.
https://i.stack.imgur.com/cKbuZ.png
I'm curious as to why googleChartApiPromise
becomes undefined at times?