0

I am using https://github.com/pablojim/highcharts-ng to build Highcharts in my angularjs app. As suggested on that site I am configuring my chart configs in my controller as follows:

$scope.chartConfig6 = {
    options: {
        chart: {
            type: 'bar'
        }
    },
    series: [{
        data: [33, 55, 10, 18, 17]
    }],
    title: {
        text: 'Agent FNOL Ranking'
    },  
    loading: false
}

Now I have a json file: http://pastebin.com/SEu8dHkB if you do a search you can find the field called "highChart" on the json which contains the configurations for a highchart. Now I want to be able to use these configurations directly from the json to to my highcharts config either in the controller or as a directive. This is how I get the json file via http in my service:

.factory('Swoop',function($http,$filter,$q){
  return {
    all: function(){
    var deferred = $q.defer();
    $http.get("swoop.json").success(
            function(data){
                // angular.copy(data, studies);
                deferred.resolve(data);
            }
        );
      return deferred.promise;
    }
}})

However, I am not sure how I could render this data(under the highChart object in the json) to the $scope.chartConfig6 like I did above. Can someone please show me how this could be done?

C1pher
  • 1,933
  • 6
  • 33
  • 52
user1585869
  • 301
  • 3
  • 11
  • In your factory, json is loaded ? If yes, in controller you should have a reference to json. Then assign $scope.chartConfig6 = yourjson.highChart; Let me know about results – Sebastian Bochan Jul 24 '15 at 09:35
  • So I tried this `Swoop.all().then(function(data) { $scope.chartConfig2 = data.asset.data.highChart; console.log(data.asset.data.highChart); });` It displays the chart but it only displays the first data label in the "series" . The one with the name "SYN 13" as you can see in the json file. – user1585869 Jul 24 '15 at 15:52
  • Edit: It only displays the first value "SYN 13" and the last value "SYN 14" – user1585869 Jul 24 '15 at 15:55
  • Can you recreate that as live demo ? – Sebastian Bochan Jul 27 '15 at 08:32

0 Answers0