Select which columns from CSV to graph with HighChart -



Select which columns from CSV to graph with HighChart -

as looking @ question how select columns csv chart highchart? tried apply using csv file not work!

what doing wrong? give thanks in advance:

$(function () { //var info = "year,month,day,hour,time,kwh,savings,total kwh\n2013,02,06,11,11:00,0,0,308135\n2013,02,06,11,11:59,15,1.875,308150\n2013,02,06,12,12:59,27,3.375,308177\n2013,02,06,13,13:59,34,4.25,308211\n2013,02,06,14,14:59,32,4,308243"; var options = { chart: { renderto: 'example', defaultseriestype: 'line' }, title: { text: 'current temperature', x: -20 //center }, subtitle: { text: 'source: hassayampa.csv', x: -20 }, xaxis: { type: 'datetime' }, yaxis:{ title: { text: 'temperature (\xb0c)' }, //min: 0 }, legend:{ layout: 'vertical', //backgroundcolor: '#ffffff', //floating: true, align: 'left', //x: 100, verticalalign: 'top', //y: 70, borderwidth: 0 }, series: [{ name: 'prim out temp', data: [] }, { name: 'sec out temp', data: [] }] }; // info variable $.get() $.get('http://www.geoinc.org/dropbox/geo/sites/gc_room/example.csv', function(data){ var lines = data.split('\n'); $.each(lines, function (lineno, line) { var items = line.split(','); if(lineno !== 0) { var x = + new date(items[1]+'/'+items[2]+'/'+items[0]+' '+items[4]), kwh = parsefloat(items[5]), savings = parsefloat(items[6]); if(!isnan(kwh) && !isnan(savings)){ options.series[0].data.push([x,kwh]); options.series[1].data.push([x,savings]) } } }); }); new highcharts.chart(options); });

here jsfiddle:http://jsfiddle.net/tonystinge/3bqne/1223/

i got now...

// info variable $.get() $.get('http://www.geoinc.org/dropbox/geo/sites/gc_room/example.csv', function(data){ // parsing here... }); new highcharts.chart(options); });

your problem placement of new highcharts.chart(options) call. $.get (like ajax calls) asynchronous new highcharts called before completes.

change this:

// info variable $.get() $.get('http://www.geoinc.org/dropbox/geo/sites/gc_room/example.csv', function(data){ var lines = data.split('\n'); $.each(lines, function (lineno, line) { var items = line.split(','); if(lineno !== 0) { var x = + new date(items[1]+'/'+items[2]+'/'+items[0]+' '+items[4]), kwh = parsefloat(items[5]), savings = parsefloat(items[6]); if(!isnan(kwh) && !isnan(savings)){ options.series[0].data.push([x,kwh]); options.series[1].data.push([x,savings]) } } }); new highcharts.chart(options); // in $.get callback function });

csv highcharts

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -