javascript - How to create a Highstock chart for Xively datastream? -


i'm trying create highstock chart xively data.

i'm able create regular line chart historic query of xively datastream , basic data format adaptation able pass highcharts.chart().

i have tried making highstock chart without success.

i'm new using highcharts , i'm not familiar javascript.

in basic highcharts example have bit of code adapts data format. code takes array of datapoint objects value/at keys , making two-dimensional array.

it maps this:

[   { value: "59", at: "2013-05-01t00:59:45.645022z" },   { value: "59", at: "2013-05-01t01:59:48.550144z" },   { value: "59", at: "2013-05-01t02:59:51.313604z" } ] 

to this:

[   ["2013-05-01t00:59:45.645022z", 59],   ["2013-05-01t01:59:48.550144z", 59],   ["2013-05-01t02:59:51.313604z", 59] ] 

i can using simple for-loop , used date.parse() parsefloat() ensure highcharts understand data correctly:

    var xively_datapoints = data.datapoints;     var chartdata = [];      (i = 0; < xively_datapoints.length; i++) {         chartdata.push([             date.parse(xively_datapoints[i].at),             parsefloat(xively_datapoints[i].value)         ]);     } 

i pass chartdata array highcharts so:

    $('#container').highcharts('stockchart', {         rangeselector : {             selected : 1         },         series : [{             name : 'highstock+xively',             data : chartdata, // reformatted data             tooltip: {                 valuedecimals: 2             }         }]     }); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -