2

I want to make a graph on my web app.

I don't understand how angular with highcharts works.

I use this lib : github.com/pablojim/highcharts-ng and this framework : ionicframework.com/

I think it can be the same with apache cordova.

I made a simple page with :

<highchart id="chart1" config="chartConfig"></highchart>

then, on my app.js :

var app = angular.module('myApp', ['ionic', 'ui.router', 'highcharts-ng']);

then on my controller js page :

angular.module('myApp').controller('Dashboard',....) 
{
    $scope.chartConfig = {
        options: {
            chart: {
                type: 'bar'
            }
        },
        series: [{
            data: [10, 15, 12, 8, 7]
        }],
        title: {
            text: 'Hello'
        },

        loading: false
    };

}

and of course : no graph, an error on the js 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 questions :

  • If I put the dependency on

    angular.module('myApp', ['highcharts-ng']).controller('Dashboard',....)
    

blank page, so I assume that it's on app.js only.... right or wrong ?

  • How to solve my problem ?

PS : To JSFiddle or CodePen user, here is your graal : http://codepen.io/anon/pen/ateyI

Is not exactly my project but reproduce this problem. Thanks !

2
  • At the beginning, attach a jquery, but next error is in te ionic.bundle.js 30705 line, so maybe update ionic framework. Commented Sep 1, 2014 at 12:08
  • @FrPolymer have you solved it ? ? ? Commented Jan 30, 2016 at 14:23

3 Answers 3

2

Debug it using chrome's web inspector. For me, when i had the same error, the addEvent function was the culprit. Checking the definition made me realise that I had forgotten to include jquery. I suspect it's the same case for you.

Sign up to request clarification or add additional context in comments.

Comments

1

Have you included standalone-frameform.js?

<script src="lib/highcharts-release/adapters/standalone-framework.js"></script>

Hope this will help.

Comments

1

Vlad is right. You need to include standalone-framework.js. Moreover, you don't need to load Angular, since the Ionic Bundle includes it.

So, the scripts are:

<script src="http://code.ionicframework.com/1.0.0-beta.10/js/ionic.bundle.js"></script>
<script src="http://code.highcharts.com/adapters/standalone-framework.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="https://rawgit.com/pablojim/highcharts-ng/master/src/highcharts-ng.js"></script>

Here is a working version of your Codepen: http://codepen.io/anon/pen/VYrvvV

2 Comments

It needs to be clearer in highcharts documentation that you need both highcharts.js and standalone framework included
@zambono Note that it's the case only if you don't include jQuery in your page, as stated in the "Installation" page of the documentation (option 2). It is true, though, that mentioning it in the README of highcharts-ng would be useful. I just submitted a pull request :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.