I am struggling to figure out how to incorporate data from an array obtained from another function in my javascript file into my line graph. I want to confirm that this is feasible without switching to a different graphing package. Below is my current code, and I believe I need to include a for loop in the data series, but I am unsure about how to go about it.
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
},
// planning to add a new data series using external arrays
series: [{
name: 'Line1',
data: [[5, 2], [6, 3], [8, 2]]
}]
});
});
}