javascript - Highchart.js pass array doesnt work -


i'm trying use highchart.js.

here code

$.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(",");         } 

code snippet above result :

[1330300800000,76.8],[1347235200000,78.8],[1347580800000,77.4] 

just expected.

now chart

$('#graph').highcharts({     chart: {         type: 'spline',         zoomtype: 'x'     },     xaxis: {         type: 'datetime'     },     series: [{         name: 'serie name',         data: [                 //pass serie snippet above                 serie         ]     }] }); 

result : nothing happened..chart empty.

only thing i'm pretty sure, if replace serie [1330300800000,76.8],[1347235200000,78.8],[1347580800000,77.4],[1348444800000,76.8] inside code, work charm.

what i'm doing wrong ? how can solve ?

thx reading

you passing string while should js object.

that line:

data.push("["+date.utc(splitdateres[2],parseint(splitdateres[1], 10)-1,parseint(splitdateres[0], 10))+","+dataweightlist_value.weight_poids+"]"); 

should be:

data.push([date.utc(splitdateres[2],parseint(splitdateres[1], 10)-1,parseint(splitdateres[0], 10)),dataweightlist_value.weight_poids]); 

and line:

var serie = data.join(","); 

what for? remove line or @ least remove join, please.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -