我正在尝试带角度的剑道图表,但显示数据时遇到问题,这是我的代码:
HTML:
<div kendo-chart="rchart" data-k-options="chartOptions" data-role="chart" class="k-chart" style="position: relative;"></div>
Javascript:
resultService.getResult().then(function (resultResponse) {
$scope.data = resultResponse.data;
$scope.oldReps = _.pluck($scope.data.TreningScores.Item1, 'Item2');
$scope.newReps = _.pluck($scope.data.TreningScores.Item2, 'Item2');
$scope.categories = _.pluck($scope.data.TreningScores.Item1, 'Item1');
});
$scope.chartOptions = {
legend: {
position: "bottom"
},
seriesDefaults: {
type: "column"
},
series: [{
name: "Total Visits",
data: $scope.oldReps
}, {
name: "Unique visitors",
data: $scope.newReps
}],
valueAxis: {
line: {
visible: false
}
},
tooltip: {
visible: true,
format: "{0}"
}
};
问题是从服务器获取数据后图表没有更新,我尝试过像这样刷新图表(但没有运气):
$scope.chart = {
refreshChart : function() {
$scope.rchart.refresh();
},
};
并在以下位置调用此方法:
resultService.getResult().then(function (resultResponse) {});
而且我也尝试$scope.chartOptions
在同一个函数内部定义,但没有。有没有什么办法解决这一问题 ?