I have a line graph plotting an array of data, but i would like the data to scroll - as new data is read from the micrcontroller, the existing graph moves left, and the new data is plotted on the right, so a continuous scrolling image is formed. is there anyway to do this? My attempt is in the code below, but it just plots the original data, not the new array.
/* * This file is provided for custom JavaScript logic that your HTML files might need. * GUI Composer includes this JavaScript file by default within HTML pages authored in GUI Composer. */ require(["dojo/ready"], function(ready){ ready(function(){ // logic that requires that Dojo is fully initialized should go here }); }); var no_of_seconds = 10; graph_data = new Array(stored_results*no_of_seconds).fill(0); gdLength = graph_data.length; function post( valueToTarget) { var result = [valueToTarget.length/no_of_seconds]; //create result with same number of datapoints as input array for (var i = 0; i < result.length; ++i) { result[i] = valueToTarget[valueToTarget.length - result.length + i]; //store the last result.length number of points from graph data to restore oringial array } return result; } function pre( valueFromTarget) { for (var i = 0; i < valueFromTarget.length; ++i) { graph_data.shift() //remove point from start of array graph_data.push(valueFromTarget[i]); //add new point to end } return graph_data; }