使用HighCharts的setData多个变量? [英] Using HighCharts setData for multiple variables?
本文介绍了使用HighCharts的setData多个变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
高图表API http://api.highcharts.com/highcharts#Series.setData()
javascript
....
$('#button')。click(function(){
chart.series [0] .setData(//如何使用此方法添加数据?
['Firefox',55.0],
['IE',16.8],
['Safari',7.5],
['Opera',7.2] ,
['Others',0.7]
);
和jfiddle上的例子 http://jsfiddle.net/bK7fh/
这是一个例子:
$('#button')。click(函数(){
chart.series [0] .setData([
['Firefox',55.0],
['IE',16.8],
['Safari' ,7.5],
['Opera',7.2],
['Others',0.7]
]);
});
这里是你的小提琴,并且工作: http://jsfiddle.net/bK7fh/2/
High Charts API http://api.highcharts.com/highcharts#Series.setData()
javascript
....
$('#button').click(function() {
chart.series[0].setData( //How can I use this method to add the data?
['Firefox', 55.0],
['IE', 16.8],
['Safari', 7.5],
['Opera', 7.2],
['Others', 0.7]
);
See full code and example on jfiddle http://jsfiddle.net/bK7fh/
解决方案
You forgot that set data takes an array of data, not lots of arrays.
Here is an example:
$('#button').click(function () {
chart.series[0].setData([
['Firefox', 55.0],
['IE', 16.8],
['Safari', 7.5],
['Opera', 7.2],
['Others', 0.7]
]);
});
Here is your fiddle, and working: http://jsfiddle.net/bK7fh/2/
这篇关于使用HighCharts的setData多个变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文