简体   繁体   中英

How to use google chart in angularjs with dynamic data

Im using angular google chart in my application, it is working fine with static data -.

    var chart1 = {};
  chart1.type = "GeoChart";
  chart1.data = [
        ['Locale', 'Count'],
        ['Germany', 22],
        ['United States', 34],
        ['Brazil', 42],
        ['Canada', 57],
        ['France', 6],
        ['RU', 72]
      ];

  chart1.options = {
      width: 600,
      height: 300,
      chartArea: {left:10,top:10,bottom:0,height:"100%"},
      colorAxis: {colors: ['#aec7e8', '#1f77b4']},
      displayMode: 'regions'
  };

  chart1.formatters = {
     number : [{
       columnNum: 1,
       pattern: "$ #,##0.00"
     }]
   };

  $scope.chart = chart1;

but im getting data from server -

$http.get("http://someurl")
    .success(function(response) {
$scope.data = response;});
});

Now how can i push the response data to chart1.data to get it working.

I assume that success response callback function is in same controller as chart define.

$http.get("http://someurl")
    .success(function(response) {
         $scope.chart.data = response;
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM