diff --git a/web/classes.js b/web/classes.js index 0c9f96a..50e0e26 100644 --- a/web/classes.js +++ b/web/classes.js @@ -19,8 +19,7 @@ class node { updateConnection() { if (connectedNodes[this.nodeId]) { this.connected = true; - } - else { + } else { this.connected = false; } } @@ -31,7 +30,7 @@ class feedbackNode extends node { constructor(nodeId) { super(nodeId); this.feedback = {}; - this.answers = 0; + this.answers = 0; } // Function to update the feedback updateFeedback(feedback) { @@ -39,16 +38,16 @@ class feedbackNode extends node { } } -class liveGraph extends node{ +class liveGraph extends node { // Constructor to initialize the graph constructor(id) { - super(id, live); - this.timeArray = []; + super(id); this.tempArray = []; this.humiArray = []; this.eco2Array = []; this.tvocArray = []; this.cnt = 0; + this.nodeId = "liveGraph" + id; } // Fuction to create a graph makeGraph() { @@ -101,7 +100,12 @@ class liveGraph extends node{ let update = { x: [[this.timeArray]], - y: [[this.tempArray], [this.humiArray], [this.eco2Array], [this.tvocArray]] + y: [ + [this.tempArray], + [this.humiArray], + [this.eco2Array], + [this.tvocArray], + ], }; let olderTime = time.setMinutes(time.getMinutes() - 1); @@ -127,28 +131,23 @@ class liveGraph extends node{ class graph { // Constructor to initialize the graph - constructor(id, graph) { - if (graph === "live") { - this.nodeId = "liveGraph" + id; - } - else { - this.nodeId = "graph" + id; - } + constructor(id) { + this.nodeId = "graph" + id; + this.timeArray = []; } // Function to create a graph makeGraph(amountOfGraphs, array1, array2, array3, array4) { for (let i = 0; i < amountOfGraphs; i++) { - - // Create a new line for temperature - Plotly.plot(this.nodeId, [ - { - x: this.timeArray, // Use timeArray as x values - y: array + i, - mode: "lines", - line: { color: "#FF0000" }, - name: "Temperature", - }, - ]); + // Create a new line for temperature + Plotly.plot(this.nodeId, [ + { + x: this.timeArray, // Use timeArray as x values + y: array + i, + mode: "lines", + line: { color: "#FF0000" }, + name: "Temperature", + }, + ]); } } // Function to update the graph with new values got from updateData function @@ -158,7 +157,7 @@ class graph { let update = { x: [[this.timeArray]], - y: [array1, array2, array3, array4] + y: [array1, array2, array3, array4], }; let olderTime = time.setMinutes(time.getMinutes() - 1); @@ -166,9 +165,8 @@ class graph { let minuteView = { xaxis: { type: "date", - range: + range: [olderTime, futureTime], }, }; - + } } -} \ No newline at end of file