[英]How to use google chart in angularjs with dynamic 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;
但是我從服務器獲取數據-
$http.get("http://someurl")
.success(function(response) {
$scope.data = response;});
});
現在如何將response data
推送到chart1.data
以使其正常工作。
我假設成功響應回調函數與chart
定義在同一控制器中。
$http.get("http://someurl")
.success(function(response) {
$scope.chart.data = response;
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.