Updated html to only plot the last minute of data
This commit is contained in:
parent
ba982e3a4e
commit
c13048eca6
|
|
@ -47,6 +47,13 @@
|
||||||
const maxPoints = 100; // Number of time points to keep
|
const maxPoints = 100; // Number of time points to keep
|
||||||
const time = () => new Date(); // Timestamp for x-axis
|
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() {
|
async function updatePlots() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/monitor');
|
const response = await fetch('/monitor');
|
||||||
|
|
@ -80,7 +87,14 @@
|
||||||
Plotly.extendTraces('mv07-plot', { x: [[t]], y: [[mv.MV07]] }, [0]);
|
Plotly.extendTraces('mv07-plot', { x: [[t]], y: [[mv.MV07]] }, [0]);
|
||||||
Plotly.extendTraces('mv08-plot', { x: [[t]], y: [[mv.MV08]] }, [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) {
|
} catch (error) {
|
||||||
console.error("Error updating plots:", error);
|
console.error("Error updating plots:", error);
|
||||||
|
|
@ -162,9 +176,5 @@
|
||||||
window.onload = initPlots;
|
window.onload = initPlots;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
// Initialize plots when the page loads
|
|
||||||
window.onload = initPlots;
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user