javascript - Highcharts JS getting very slow when updating with many data points -
i have static local webpage supposed updated data csv file (so data written file, page should update , display new data). issue many data pointys, becomes slow , after number of points not update @ all.
currently, way page updates reads file every 3 seconds , updates accordingly. imagine more efficient way see recent additions file , append new points current data set. i'm not sure how that.
code below parses csv file , separates data arrays used in charts:
function parsecsvdata(csvfile) { time = []; altitude = []; outsidetemp = []; insidetemp = []; voltage = []; state = []; velocity = []; degrees = []; // cut csv datafiles lines var lines = csvfile.split("\n"); $.each(lines, function (linenumber, line) { if (linenumber != 0) { // skip header line var fields = line.split(","); var missiontime = parseint(fields[1]); var altitude2 = parseint(fields[2]); var outsidetemp2 = parseint(fields[3]); var insidetemp2 = parseint(fields[4]); var voltage2 = parseint(fields[5]); var state2 = parseint(fields[6]); var velocity2 = parseint(fields[7]); var degrees2 = parseint(fields[8]); time.push(missiontime); altitude.push(altitude2); outsidetemp.push(outsidetemp2); insidetemp.push(insidetemp2); voltage.push(voltage2); state.push(state2); velocity.push(velocity2); degrees.push(degrees2); } }); }
this code update charts every 3 seconds:
setinterval(function blah() { var file = filename+'?q='+math.random(); fillcharts(file);//which calls parsecsvdata function , fills charts }, 3000);
edit: pastebin entire code: http://pastebin.com/qmzn8azy
edit2: sample csv data:
team_id,mission_time,alt_sensor,outside_temp,inside_temp,voltage,fsw_state,velocity,degrees ubartemis,0,36,20,20,9,1,0,0 ubartemis,1,45,18,20,9,1,6,2 ubartemis,2,200,16,20,9,1,10,5 ubartemis,3,65,14,19,9,1,15,3 ubartemis,4,79,12,17,8,2,22,4 ubartemis,5,100,10,16,8,3,30,2 ubartemis,6,120,8,15,8,4,39,0
Comments
Post a Comment