diff --git a/static/monitor.html b/static/monitor.html
index 60b03ae..faa7c0c 100644
--- a/static/monitor.html
+++ b/static/monitor.html
@@ -47,6 +47,13 @@
const maxPoints = 100; // Number of time points to keep
const time = () => new Date(); // Timestamp for x-axis
+ function getLastMinuteRange() {
+ const now = new Date();
+ const oneMinuteAgo = new Date(now.getTime() - 60 * 1000);
+ return [oneMinuteAgo, now];
+ }
+
+
async function updatePlots() {
try {
const response = await fetch('/monitor');
@@ -80,7 +87,14 @@
Plotly.extendTraces('mv07-plot', { x: [[t]], y: [[mv.MV07]] }, [0]);
Plotly.extendTraces('mv08-plot', { x: [[t]], y: [[mv.MV08]] }, [0]);
+ const range = getLastMinuteRange();
+ // Update X-axis for all plots
+ ['flow-plot', 'pressure-plot', 'mv02-plot', 'mv03-plot', 'mv04-05-plot', 'mv06-plot', 'mv07-plot', 'mv08-plot'].forEach(id => {
+ Plotly.relayout(id, {
+ 'xaxis.range': range
+ });
+ });
} catch (error) {
console.error("Error updating plots:", error);
@@ -162,9 +176,5 @@
window.onload = initPlots;
-
- // Initialize plots when the page loads
- window.onload = initPlots;
-