0
我在找到一种方法将我从javascript文件中的另一个函数中获取的数据插入我的线图中。我只是想确保这是支持的,我不必切换到不同的图形包。这里是我当前的代码,我猜你必须将for循环添加到数据系列中,但我不确定如何实现这一点。将数据从数组插入到线图中的高图表
function displayGraph(){
//data to insert
var x =new Array(0, 1, 2, 3, 4); //array of x coordinates
var y =new Array(1, 1.8, 1.5, 2.5, 6.3);//array of y coordinates
$(function() {
$('#container').highcharts({
title: {
text: 'Glaicer Elevations',
x: -20 //center
},
xAxis: {
title: {
text: 'xAxis'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
yAxis: {
title: {
text: 'yAxis'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: 'km'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
// want to insert another data series using outside arrays
series: [{
name: 'Line1',
data: [[5, 2], [6, 3], [8, 2]]
}]
});
});
}
一旦我准备好这样的数据,我将如何调用它来在data:tag中进行图形化呢? – user2461876
我将它重命名为xy,所以你没有任何冲突。你简单设置'data:xy' – Asped
非常感谢!你帮了我很多。 – user2461876