datetime - date time plotting in highcharts -


i have 15 min interval date wise data plot. dates might not consistent in case.

sample format: var row = ["2012-02-29", " 00:15", "0"]

i getting array java class plotting.

i tried few options :

    var tempval = new array();      for(var i=0;i<row.length;i++){          var record = row[i].split(",");         tempval[i]=date.utc(record[0].substring(0,4), record[0].substring(5,7),   record[0].substring(8,10), record[1].substring(1,3), record[1].substring(4,7)), record[2];  } 

in highcharts : series: [{ data: tempval }]

but unable plot on highcharts.

any guidance helpful.

to plot date time on highcharts need date time value , y value. should following:

data: [                 [date.utc(2010, 0, 1), 29.9],                  [date.utc(2010, 2, 1), 71.5],                  [date.utc(2010, 3, 1), 106.4]             ] 

or replace date.utc(2010, 0, 1) equivalent javascript time value.

date.utc() can accept several different formats. see here.

so need combine date value , time value 1 single time value.

edit after looking @ example code have couple of issues. 1 data array tempval declared wrong. should be:

var tempval = []; 

you should using array.push data tempval array.

the other issue time series not appear in chronological order - when had series set correctly got area "line" going , forth.

all being said came need fix data array declaration , how assigning data array. simple method , can of course made faster verbose:

for (var = 0; < row.length; i++) {     var record = row[i].split(",");     var xval = date.utc(parseint(record[0].substring(0, 4)), parseint(record[0].substring(5, 7)), parseint(record[0].substring(8, 10)), parseint(record[1].substring(1, 3)), parseint(record[1].substring(4, 7)));     var yval = math.random() * 10;     var x = [xval, yval];     tempval.push(x); } 

see updated example here. note lines go , forth - said has time series not being in chronological order. note months 0-based jan = 0 , dec = 11.


Comments