graphs: set x-axis using absolute time in advance()

setInterval() won't be reliably fired by the browser when the tab
is backgrounded!
This commit is contained in:
Girish Ramakrishnan
2025-10-15 22:43:04 +02:00
parent 0502779a29
commit 0c7e810bd3
+4 -2
View File
@@ -200,8 +200,10 @@ function pruneGraphData(dataset, options) {
}
function advance() {
graph.options.scales.x.min += LIVE_REFRESH_INTERVAL_MSECS;
graph.options.scales.x.max += LIVE_REFRESH_INTERVAL_MSECS;
// advance is called in a timer and when the browser tab is in the background , it is unreliable. Use absolute time to set the scale
const now = Date.now();
graph.options.scales.x.min = now - 5*60*1000;
graph.options.scales.x.max = now;
graph.update('none');
}