arrays - How to write a Javascript function with ability to preserve values between calls -
Actually I am underlining a graph in which I first offer 30 or so such as the chart loads and then I am giving a call to any other function which will give a new random value with additional property, if this number is high then in the graph, its immediate predecessor or the number of wards that come in the next number adds additional properties like that Different Color
Here is my code
Events: {load: function () {// set every other var series = this.series [0] update of chart Do; SetInterval (function () {var x = (New date ()). GetTime (), // current time color = 'red', // default color y = getYData (); // This function is supplying values // Condifiton if the situation is true follwoing series .addpoint ({x: x, y: y, color: color // pass color}, true, true); else series.addpoint ({x: x, y: Y // no color is required}, true, true);}, 1000); How can the code get the function getYValue () {// yValue? }
But in this I should be able to preserve the value between calls.
Is it possible JavaScript?
Thank you
You will find your y
Variable is required to be declared, so that the value between its interval call is:
{var series = this.series [0]; Var y = 0; SetInterval (function () {var newy = getYData (); // in do not smile // y - old value, in new - new y = new; ...}}