Each chart contains the code below.
(GRAPH1, GRAPH2...etc - just copy of this code for each chart.)
Part of the code
Code: Select all
chart:
{zoomType: 'x',
events:
{
load: function () {
//not optimal, need a loop?
var GRAPH1series_0 = this.series[0];
var GRAPH1series_1 = this.series[1];
var GRAPH1series_2 = this.series[2];
var GRAPH1series_3 = this.series[3];
var GRAPH1series_4 = this.series[4];
var GRAPH1series_5 = this.series[5];
setInterval(function ()
{
$.each(GRAPH1names, function (i, name) {
current_time=(new Date()).getTime()+17400000; // current time
$.getJSON('actions.php?get_live_data&cryptocurrency_id_name='+name, function(GRAPH1live_data) {
if (i==0) GRAPH1series_0.addPoint([current_time, GRAPH1live_data], true, true);
if (i==1) GRAPH1series_1.addPoint([current_time, GRAPH1live_data], true, true);
if (i==2) GRAPH1series_2.addPoint([current_time, GRAPH1live_data], true, true);
if (i==3) GRAPH1series_3.addPoint([current_time, GRAPH1live_data], true, true);
if (i==4) GRAPH1series_4.addPoint([current_time, GRAPH1live_data], true, true);
if (i==5) GRAPH1series_5.addPoint([current_time, GRAPH1live_data], true, true);
});
});
}, 10000); //timer (update interval)
}
}
When several charts are placed on a page they are not updated synchronously. And this is understandable - the timer starts only when the script is inserted. This is a fraction of a second. But the longer the auto-update of several charts, the more the difference is visible.
Perhaps I need a single timer for all graphs. Or an appropriate event (like load_all: function?) for all charts. Not for everyone as it is now.
Is there such an event, option or example?
Is there a way to synchronize auto-update (multiple charts)?