I am trying to create a graph on my web application.
However, I am struggling to understand how to integrate Angular with Highcharts.
I am utilizing the highcharts-ng library from github.com/pablojim and the Ionic framework from ionicframework.com.
I believe the process would be similar with Apache Cordova.
So far, I have created a basic page with :
<highchart id="chart1" config="chartConfig"></highchart>
Then, in my app.js file :
var app = angular.module('myApp', ['ionic', 'ui.router', 'highcharts-ng']);
Next, in my controller JS file :
angular.module('myApp').controller('Dashboard',....)
{
$scope.chartConfig = {
options: {
chart: {
type: 'bar'
}
},
series: [{
data: [10, 15, 12, 8, 7]
}],
title: {
text: 'Hello'
},
loading: false
};
}
Despite setting everything up correctly, there is no graph displayed, and an error appears on the console:
TypeError: undefined is not a function
at Object.Xa.init (http://localhost:63342/www/js/highcharts.js:190:242)
at Object.Xa (http://localhost:63342/www/js/highcharts.js:15:293)
at link.m (http://localhost:63342/www/js/highcharts-ng.min.js:8:2964)
at link (http://localhost:63342/www/js/highcharts-ng.min.js:8:3058)
at http://localhost:63342/www/lib/ionic/js/ionic.bundle.js:15996:44
at nodeLinkFn (http://localhost:63342/www/lib/ionic/js/ionic.bundle.js:15605:13)
at compositeLinkFn (http://localhost:63342/www/lib/ionic/js/ionic.bundle.js:15009:15)
at nodeLinkFn (http://localhost:63342/www/lib/ionic/js/ionic.bundle.js:15599:24)
at compositeLinkFn (http://localhost:63342/www/lib/ionic/js/ionic.bundle.js:15009:15)
at compositeLinkFn (http://localhost:63342/www/lib/ionic/js/ionic.bundle.js:15012:13) <div id="chart1" config="chartConfig">
My queries are:
If I include the dependency on
angular.module('myApp', ['highcharts-ng']).controller('Dashboard',....)
The page remains blank, leading me to think that the issue lies only in the app.js file...is this assumption correct?
PS : For JSFiddle or CodePen users, you can find a working example here: http://codepen.io/anon/pen/ateyI
This may not be an exact replica of my project but it illustrates the same issue. Thank you!