Currently experimenting with highchart.js.
Here is the code snippet:
$.ajax({ type: "POST",
url: "api/getListWeight",
dataType: "json",
data : {idBoxeur : idBoxeur}
}).done(function( dataWeightList ) {
var data = [];
$.each(dataWeightList, function( dataWeightList_index, dataWeightList_value ) {
var splitDateRes = dataWeightList_value.weight_date.split("/");
data.push("["+Date.UTC(splitDateRes[2],parseInt(splitDateRes[1], 10)-1,parseInt(splitDateRes[0], 10))+","+dataWeightList_value.weight_poids+"]");
});
var serie = data.join(",");
}
The output of the code snippet resembles this:
[1330300800000,76.8],[1347235200000,78.8],[1347580800000,77.4]
exactly as expected.
Now moving on to creating the chart
$('#graph').highcharts({
chart: {
type: 'spline',
zoomType: 'x'
},
xAxis: {
type: 'datetime'
},
series: [{
name: 'serie Name',
data: [
//pass in the 'serie' variable from above snippet
serie
]
}]
});
Issue: no chart displayed. The chart remains empty.
I am certain that replacing serie
with
[1330300800000,76.8],[1347235200000,78.8],[1347580800000,77.4],[1348444800000,76.8]
inside the code leads to it working perfectly.
Where am I going wrong? Any suggestions for a solution?
Thank you for your attention.