I have a highchart
and currently it shows only one value. I want to show an array of data. This is my current a javascript method and it's only showing one data.
$(function () {
//alert("myValues"+myValues);
//console.log("deviceName"+deviceName);
$('#container').highcharts({
chart: {
type: 'line'
},
title: {
text: 'Daily Power Consumption'
},
subtitle: {
text: 'Device : '+deviceName
},
xAxis: {
type: 'datetime',
tickInterval: 3600 * 2000, // two hour
tickWidth: 0,
gridLineWidth: 1,
labels: {
align: 'center',
x: -3,
y: 20,
formatter: function() {
return Highcharts.dateFormat('%l%p', this.value);
}
}
},
yAxis: {
min: 0,
title: {
text: 'power ( W )'
}
},
tooltip: {
formatter: function() {
// return Highcharts.dateFormat('%l%p', this.x-(1000*3600)) +'-'+ Highcharts.dateFormat('%l%p', this.x) +': <b>'+ this.y + '</b>'+this.series.name;
return Highcharts.dateFormat('%l%p', this.x-(1000*3600)) +'-'+ Highcharts.dateFormat('%l%p', this.x) +':'+ this.y + '';
}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Time Period',
// name: deviceName,
data: [myValues]
}]
});
});
But then I need to loop through the arrays somehow, pushing everything into the series data and I don't know how to do that.
If I use a for loop with this data, how do I insert into the highcharts
series data?