Lokendra Singh Panwar
Lokendra Singh Panwar

Reputation: 511

How to pass dynamic data in highchart using angularjs?

I have used line chart. Here is the link of line chart http://jsfiddle.net/highcharts/qyntd1xa/ I have stuck in pass dynamically data in line chart. How to pass dynamically data in line chart. i am new in angular js here is my controller function code-

$scope.updatedays   =   function(){ 
        $scope.data =   $scope.getdata();
        console.log($scope.data);

        Highcharts.chart('cont2', {
            xAxis: {
                categories: ['MON 12', 'TUE 13', 'WED 14', 'THU 15', 'FRI 16', 'SAT 17', 'SUN 18']
            },

            series: [{
                data: [1.5, 5.5, 3.0, 2.5, 4.5, 3, 2]
            }]
        });
    }

I tryed pass dynamically data but i getting error in Highcharts.

Upvotes: 0

Views: 1661

Answers (1)

Timothy Chen
Timothy Chen

Reputation: 374

Store your data and your categories in two separate arrays that match up by index and then use those two arrays as your values.

For example:

xAxis: {
    categories: myCategoriesArray
},

series: [{
    data: myDataArray
}]

If you want to pass the arrays into your function, check out this post.

Upvotes: 1

Related Questions