Javascript AngularJS+;在amCharts中更新图形
在服务返回查询后,angularJS很难正确更新图形 基本上,在查询返回后,我需要根据返回显示图表,但图表似乎不再加载,如何在amcharts图表中重新加载 这里有一个例子Javascript AngularJS+;在amCharts中更新图形,javascript,html,angularjs,angularjs-directive,dom-events,Javascript,Html,Angularjs,Angularjs Directive,Dom Events,在服务返回查询后,angularJS很难正确更新图形 基本上,在查询返回后,我需要根据返回显示图表,但图表似乎不再加载,如何在amcharts图表中重新加载 这里有一个例子 var app = angular.module('myApp', ['amChartsDirective']); app.controller('myCtrl', function($scope,$http) { function getDataJSON(){ return {
var app = angular.module('myApp', ['amChartsDirective']);
app.controller('myCtrl', function($scope,$http) {
function getDataJSON(){
return {
data: [{ year: 2007, income: 30.1, expenses: 23.9 }, { year: 2008, income: 29.5, expenses: 25.1 }],
type: "serial", categoryField: "year", categoryAxis: { gridPosition: "start",parseDates: false },
valueAxes: [{ position: "top", title: "Million USD" }], graphs: [{ type: "column", fillAlphas: 1 }] };
};
$scope.amChartOffLine = getDataJSON();
$scope.amChartOnLine = '';
$http({ url: 'https://apps.widenet.com.br/busca-cep/api/cep/06233-030.json', method: 'GET' })
.then(function successCallback(response) {
console.log('return: '+response.data.city);
$scope.amChartOnLine = getDataJSON();
console.log('Display graph ?');
});
});
console.log('finish.');
您的预期回报率是多少osasco’?@alphapilgrim忘记osasco吧,我只是用它来举例说明。我只想在http.get返回之后显示图形。请注意,图表不是在http.get返回之后创建的。
<div ng-app="myApp" ng-controller="myCtrl">
<div style="height: 300px; width: 400px;">
<am-chart id="OffLine" options="amChartOffLine"></am-chart>
</div>
<div style="height: 300px; width: 400px;">
<am-chart id="OnLine" options="amChartOnLine"></am-chart>
</div>
</div>