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