added dynamic refresh interval depending on zoom

This commit is contained in:
Steffen Vogel 2011-01-16 00:12:22 +01:00
parent 1549eb00c9
commit 4a7323998b
3 changed files with 8 additions and 8 deletions

View file

@ -92,16 +92,16 @@ vz.wui.init = function() {
// auto refresh
if (vz.options.refresh) {
$('#refresh').attr('checked', true);
vz.wui.interval = window.setInterval(vz.wui.refresh, vz.options.refreshInterval);
vz.wui.timeout = window.setTimeout(vz.wui.refresh, 3000);
}
$('#refresh').change(function() {
if ($(this).attr('checked')) {
vz.options.refresh = true;
vz.wui.interval = window.setInterval(vz.wui.refresh, vz.options.refreshInterval);
vz.wui.timeout = window.setTimeout(vz.wui.refresh, 3000);
}
else {
vz.options.refresh = false;
window.clearInterval(vz.wui.interval);
window.clearTimeout(vz.wui.timeout);
}
});
@ -167,9 +167,12 @@ vz.wui.initEvents = function() {
*/
vz.wui.refresh = function() {
var delta = vz.options.plot.xaxis.max - vz.options.plot.xaxis.min;
vz.options.plot.xaxis.max = new Date().getTime(); // move plot
vz.options.plot.xaxis.min = vz.options.plot.xaxis.max - delta; // move plot
vz.entities.loadData();
vz.wui.timeout = window.setTimeout(vz.wui.refresh, (delta / 100 < 3000) ? 3000 : delta / 100); // TODO update timeout after zooming
};
/**
@ -527,7 +530,7 @@ vz.wui.dialogs.error = function(error, description, code) {
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
$(this).dialog('close');
}
}
});

View file

@ -80,12 +80,10 @@ Array.prototype.clear = function() {
Array.prototype.unique = function () {
var r = new Array();
this.each(function(key, value) {
if (!r.contains(value)) {
r.push(value);
}
});
return r;
}

View file

@ -32,9 +32,8 @@ vz.options = {
rounding: 1,
render: 'lines',
refresh: false,
refreshInterval: 5*1000, // 5 secs
defaultInterval: 24*60*60*1000, // 1 day
timezoneOffset: -(new Date().getTimezoneOffset() * 60*1000) // TODO add option with timezone dropdown
timezoneOffset: -(new Date().getTimezoneOffset() * 60000) // TODO add option with timezone dropdown
};
vz.options.plot = {