From 598dd545217e967aabee310f2828b4769354f318 Mon Sep 17 00:00:00 2001 From: sietse jonker Date: Thu, 7 Mar 2024 13:18:12 +0100 Subject: [PATCH] Add new lines for temperature, humidity, eCO2, and TVOC in liveGraph class --- web/classes.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/classes.js b/web/classes.js index bea7d93..2067bfc 100644 --- a/web/classes.js +++ b/web/classes.js @@ -9,9 +9,9 @@ class liveGraph { this.cnt = 0; this.nodeId = "liveGraph" + id; } - // Fuction to create a graph makeGraph() { + // Create a new line for temperature Plotly.plot(this.nodeId, [ { x: this.timeArray, // Use timeArray as x values @@ -21,6 +21,7 @@ class liveGraph { name: "Temperature", }, ]); + // Create a new line for humidity Plotly.plot(this.nodeId, [ { x: this.timeArray, // Use timeArray as x values @@ -30,6 +31,7 @@ class liveGraph { name: "Humidity", }, ]); + // Create a new line for eCO2 Plotly.plot(this.nodeId, [ { x: this.timeArray, // Use timeArray as x values @@ -39,6 +41,7 @@ class liveGraph { name: "eCO2 / 10", }, ]); + // Create a new line for TVOC Plotly.plot(this.nodeId, [ { x: this.timeArray, // Use timeArray as x values @@ -50,7 +53,7 @@ class liveGraph { ]); } - // Function to update the graph with new values + // Function to update the graph with new values got from updateData function updateGraph() { let time = new Date(); this.timeArray.push(new Date()); @@ -71,7 +74,7 @@ class liveGraph { Plotly.relayout(this.nodeId, minuteView); if (this.cnt === 10) clearInterval(interval); } - + // function to get the new data for graph updateData(temperature, humidity, eCO2, TVOC) { // Update the graph this.tempArray.push(temperature);