因此,当我在高级图表中使用我想要的数据时,我可以直接输入它并且它可以工作:
$(function () {
$('#container').highcharts({
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},
xAxis: {
},
yAxis: {
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '°C'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'Tokyo',
data: [0.818883519277839, 0.8118310020160356, 0.8292750491048191, 0.8207364844853503, 0.8187873450691459, 0.8098962769401326, 0.8060550491107373, 0.7960675107192992, 0.7798022181293245, 0.7747131667969733, 0.77704753581292, 0.780881503288139, 0.7808802272036436, 0.7828232760186384, 0.7745154579263632, 0.7858447215087305, 0.7903196602781966, 0.7904203695573747, 0.7842096993261638, 0.7736738976551895]
}]
});
});
但是,当我尝试用穿过我的数组的for循环替换它时,它不起作用。是否有适当的方法将数组用于数据?
例如:
myArray = [0.818883519277839, 0.8118310020160356, 0.8292750491048191, 0.8207364844853503, 0.8187873450691459, 0.8098962769401326, 0.8060550491107373, 0.7960675107192992, 0.7798022181293245, 0.7747131667969733, 0.77704753581292, 0.780881503288139, 0.7808802272036436, 0.7828232760186384, 0.7745154579263632, 0.7858447215087305, 0.7903196602781966, 0.7904203695573747, 0.7842096993261638, 0.7736738976551895]
然后
series: [{
name: 'Tokyo',
data: myArray,
}]
谢谢!
答案 0 :(得分:0)
你的y轴值是多少?
此外,必须越来越多地订购x轴的数据,以使highcharts正常工作。检查您的控制台,看看Sebastian是否有任何错误。
答案 1 :(得分:0)
它应该按照你尝试的方式工作。 请参阅小提琴:http://jsfiddle.net/c4arw1se/
series: [{
name: 'Tokyo',
data: myArray
}]
你可以发布你用来生成数据数组的函数吗?