// Hrishi Hiraskar // 3 October 2016 var chart_id_list = []; var points_list = []; var INTERVAL = 50; var eventSource; var create_new_chart = function(id){ // Function to create a new chart $('#charts').append("
"); $('#chart-'+id.toString()).highcharts({ chart: { type: 'spline', animation: false }, title : { text: 'Figure '+id.toString() }, xAxis : { title: { text: 'x' }, min: 0, max: 30, tickInterval: 2 }, yAxis : { title: { text: 'y' }, plotLines: [{ width: 1, color: '#808080' }] }, plotOptions : { marker: { enabled: false, } }, legend : { enabled: false }, exporting : { enabled: false }, series : [{ name: "Series "+id.toString(), data: [] }] }); chart_id_list.push(id); points_list.push(new Queue()); } function init(){ eventSource = new EventSource('/SendLog'); // Start listening to server eventSource.addEventListener("log", function(event){ var data = event.data.split(' '); var id = parseInt(data[2]), x = parseFloat(data[8]), y = parseFloat(data[9]), z = parseFloat(data[10]); if(chart_id_list.indexOf(id)<0) create_new_chart(id); var index = chart_id_list.indexOf(id); points_list[index].enqueue([x,y]); }, false); // Stop listening eventSource.addEventListener("DONE", function(event){ eventSource.close(); // Close connection }, false); setInterval(function(){ for(var i=0;i