From bc8cc500cb5caa2dcf2e8720ccee3fd3b420402b Mon Sep 17 00:00:00 2001 From: sietse jonker Date: Thu, 7 Mar 2024 13:00:22 +0100 Subject: [PATCH] Refactor code to dynamically create node data and live graphs --- web/main.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/web/main.js b/web/main.js index 7c39a74..dad1607 100644 --- a/web/main.js +++ b/web/main.js @@ -192,13 +192,10 @@ function updateNodeData(node, temperature, humidity, eCO2, TVOC) { } // Call the function to create the HTML structure -createNodeData(1); -createNodeData(2); -createNodeData(3); -createNodeData(4); - -// Create a new liveGraph object -liveGraphs.push(new liveGraph(1)); +for (let i = 1; i <= 4; i++) { + createNodeData(i); + liveGraphs.push(new liveGraph(i)); +} // make the graphs liveGraphs.forEach((graph) => {