I want to populate two arrays in javascript to simulate timely updating chart. For this I want two charts to be populate.
var array1 = [1,2,3,...] //time in seconds var array2 = [10,15,12,...] //any random number
Each element should be pushed to the arrays with one second of interval.
Tried this but arrays are not getting updated as I want.
var time = [];
var value = [];
$(document).ready(function() {
update();
});
function update() {
var index = 0;
setTimeout(function () {
index++;
time.push(index);
value.push(Math.random() * (0 - 200));
console.log(time)
console.log(value)
update();
}, 1000);
}