{"action":"created","issue":{"url":"https://api.github.com/repos/petermelias/angular-chartjs/issues/25","labels_url":"https://api.github.com/repos/petermelias/angular-chartjs/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/petermelias/angular-chartjs/issues/25/comments","events_url":"https://api.github.com/repos/petermelias/angular-chartjs/issues/25/events","html_url":"https://github.com/petermelias/angular-chartjs/issues/25","id":43150682,"number":25,"title":"asynchronous data question","user":{"login":"jbelis","id":100576,"avatar_url":"https://avatars.githubusercontent.com/u/100576?v=3","gravatar_id":"","url":"https://api.github.com/users/jbelis","html_url":"https://github.com/jbelis","followers_url":"https://api.github.com/users/jbelis/followers","following_url":"https://api.github.com/users/jbelis/following{/other_user}","gists_url":"https://api.github.com/users/jbelis/gists{/gist_id}","starred_url":"https://api.github.com/users/jbelis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbelis/subscriptions","organizations_url":"https://api.github.com/users/jbelis/orgs","repos_url":"https://api.github.com/users/jbelis/repos","events_url":"https://api.github.com/users/jbelis/events{/privacy}","received_events_url":"https://api.github.com/users/jbelis/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/petermelias/angular-chartjs/labels/investigating","name":"investigating","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-09-18T16:09:57Z","updated_at":"2016-01-25T21:14:58Z","closed_at":"2014-12-05T00:04:55Z","body":"Hi,\r\n\r\nI am looking for additional information about async chart data.  Specifically, I provide the chart data as a promise, and it seems the module is not waiting for the data promise to be resolved.   The following errors is thrown to the js console as soon a the controller returns:\r\n\r\n```\r\nTypeError: Cannot read property 'length' of undefined\r\n    at Object.Chart.Type.extend.buildScale (http://localhost:1509/bower_components/chartjs/Chart.js:2136:25)\r\n    at Object.Chart.Type.extend.initialize (http://localhost:1509/bower_components/chartjs/Chart.js:2065:9)\r\n    at Object.Chart.Type (http://localhost:1509/bower_components/chartjs/Chart.js:811:19)\r\n    at Object.Chart.Type.extend.ChartType (http://localhost:1509/bower_components/chartjs/Chart.js:1014:18)\r\n    at Chart.Type.extend.Chart.(anonymous function) [as Bar] (http://localhost:1509/bower_components/chartjs/Chart.js:1042:12)\r\n    at postLink (http://localhost:1509/bower_components/ng-chartjs/dist/angular-chartjs.js:88:35)\r\n    at http://localhost:1509/bower_components/angular/angular.js:7113:44\r\n    at nodeLinkFn (http://localhost:1509/bower_components/angular/angular.js:6711:13)\r\n    at compositeLinkFn (http://localhost:1509/bower_components/angular/angular.js:6105:13)\r\n    at compositeLinkFn (http://localhost:1509/bower_components/angular/angular.js:6108:13) <canvas dataset=\"chartdata\" segment-stroke-width=\"5\" class=\"ng-isolate-scope\" height=\"150\" width=\"300\" style=\"width: 300px; height: 150px;\"> \r\n```\r\nIs there anything else I need to do to make this work?\r\n\r\nThanks\r\n"},"comment":{"url":"https://api.github.com/repos/petermelias/angular-chartjs/issues/comments/174665318","html_url":"https://github.com/petermelias/angular-chartjs/issues/25#issuecomment-174665318","issue_url":"https://api.github.com/repos/petermelias/angular-chartjs/issues/25","id":174665318,"user":{"login":"ketsugi","id":5138942,"avatar_url":"https://avatars.githubusercontent.com/u/5138942?v=3","gravatar_id":"","url":"https://api.github.com/users/ketsugi","html_url":"https://github.com/ketsugi","followers_url":"https://api.github.com/users/ketsugi/followers","following_url":"https://api.github.com/users/ketsugi/following{/other_user}","gists_url":"https://api.github.com/users/ketsugi/gists{/gist_id}","starred_url":"https://api.github.com/users/ketsugi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ketsugi/subscriptions","organizations_url":"https://api.github.com/users/ketsugi/orgs","repos_url":"https://api.github.com/users/ketsugi/repos","events_url":"https://api.github.com/users/ketsugi/events{/privacy}","received_events_url":"https://api.github.com/users/ketsugi/received_events","type":"User","site_admin":false},"created_at":"2016-01-25T21:14:58Z","updated_at":"2016-01-25T21:14:58Z","body":"I'm facing the same error.\r\n\r\n    <canvas class=\"chart chart-bar\" chart-data=\"chart.data\" chart-labels=\"chart.labels\">\r\n\r\n    app.controller('dashboardController', function($scope, Sales) {\r\n    $scope.chart = {\r\n        labels: [],\r\n        data: []\r\n    }\r\n\r\n    Sales.get().then(function(data) { // async data call via REST API\r\n        for (i = data.length - 1; i >= 0; i--) {\r\n            date = moment().month(data[i].month).year(data[i].year).format('MMM YYYY');\r\n            \r\n            $scope.chart.labels.push(date);\r\n            $scope.chart.data.push(data[i].total);\r\n        }\r\n    });\r\n});\r\n\r\nAs you can see I've already initialised the two arrays at the top of the controller, but am still getting the same `cannot read property 'length' of undefined` error"}}