尝试为angular,highcharts-ng使用highcharts指令。https://github.com/pablojim/highcharts-ng
我在更新数据时遇到了一些问题。更新序列值是没有问题的。但是我不能更新X轴的标题。我这里有一个js小提琴,http://jsfiddle.net/user1572526/3stqK/2/
我的工厂里有chartConfig:
myapp.factory('Chart', function () {
var chartConfig = {
options: {
chart: {
type: 'column'
}
},
series: [{
data: [10, 15, 12, 8, 7]
}],
xAxis: [{
categories: ['old bar title', 'old bar title 2 ']
}],
title: {
text: 'Hello'
},
loading: false
}
return chartConfig;
});然后我在我的控制器中公开它:
myapp.controller('myctrl', function ($scope, Chart) {
$scope.chartConfig = Chart;最后是一个用于设置一些新值的函数
$scope.update = function () {
$scope.chartConfig.title.text = "Setting new title"; //Works
$scope.chartConfig.series = [{ //Works
"name": "Updated data",
"data": [1, 2, 4, 7, 3]
}];
$scope.chartConfig.xAxis = [{ //NOT WORKING
categories: ['new bar title', 'new bar title2']
}]
console.log($scope.chartConfig);
}除X轴外,其他所有操作均可正常工作。
你知道这里会出什么问题吗?
发布于 2014-01-18 05:20:46
xAxis应该是对象,而不是数组。配置应该这样设置:
xAxis: {
categories: ['old bar title', 'old bar title 2 ']
}更新应该是:
$scope.chartConfig.xAxis.categories = ['new bar title', 'new bar title2'];https://stackoverflow.com/questions/21195328
复制相似问题