I'm currently working on integrating highcharts ng into my Angular project, but I'm encountering issues with data not populating. It seems like there might be a problem related to the loading of the DOM and the function call.
Here's my HTML snippet:
<div style="width: 49%; float:right;"><highchart id="chart12" config="highchartsNG"></highchart></div>
Module section:
myApp = angular.module('myApp', ['LocalStorageModule', 'ui.bootstrap', 'highcharts-ng', 'ngAnimate', 'ui.router', 'angular-loading-bar', 'hc.marked', 'ngToast', 'angularMoment', 'slick', 'app-templates']);
Controller portion:
myApp.controller('ReportController', ['$scope', 'CompanyService', function ($scope, CompanyService) {
(function () {
loadReport();
})();
function loadReport() {
CompanyService.getReportData().then(function (data) {
if (data.status === 200){
$scope.dates = data.data.date;
$scope.counts = data.data.count;
$scope.fetchedData = {
data: data.data.count
};
...
}
}, function (error) {
});
};
$scope.dates = ['2017-03-19', '2017-03-18', '2017-03-17', '2017-03-16', '2017-03-15', '2017-03-14', '2017-03-13'];
$scope.counts = [2,10,20, 25, 5, 15, 8];
$scope.$watchGroup(['counts', 'dates'], function(newValues, oldValues) {
...
}]);
I've consulted resources, but I'm still facing console errors like "TypeError: Cannot set property 'getChartObj' of undefined".
I believe a function needs to be triggered after the DOM is fully loaded, which should be handled by the $watchGroup
. However, I'm struggling to implement it properly.
Any tips or suggestions would be greatly appreciated.