Add new lines for temperature, humidity, eCO2, and TVOC in liveGraph class
This commit is contained in:
@@ -9,9 +9,9 @@ class liveGraph {
|
|||||||
this.cnt = 0;
|
this.cnt = 0;
|
||||||
this.nodeId = "liveGraph" + id;
|
this.nodeId = "liveGraph" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fuction to create a graph
|
// Fuction to create a graph
|
||||||
makeGraph() {
|
makeGraph() {
|
||||||
|
// Create a new line for temperature
|
||||||
Plotly.plot(this.nodeId, [
|
Plotly.plot(this.nodeId, [
|
||||||
{
|
{
|
||||||
x: this.timeArray, // Use timeArray as x values
|
x: this.timeArray, // Use timeArray as x values
|
||||||
@@ -21,6 +21,7 @@ class liveGraph {
|
|||||||
name: "Temperature",
|
name: "Temperature",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
// Create a new line for humidity
|
||||||
Plotly.plot(this.nodeId, [
|
Plotly.plot(this.nodeId, [
|
||||||
{
|
{
|
||||||
x: this.timeArray, // Use timeArray as x values
|
x: this.timeArray, // Use timeArray as x values
|
||||||
@@ -30,6 +31,7 @@ class liveGraph {
|
|||||||
name: "Humidity",
|
name: "Humidity",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
// Create a new line for eCO2
|
||||||
Plotly.plot(this.nodeId, [
|
Plotly.plot(this.nodeId, [
|
||||||
{
|
{
|
||||||
x: this.timeArray, // Use timeArray as x values
|
x: this.timeArray, // Use timeArray as x values
|
||||||
@@ -39,6 +41,7 @@ class liveGraph {
|
|||||||
name: "eCO2 / 10",
|
name: "eCO2 / 10",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
// Create a new line for TVOC
|
||||||
Plotly.plot(this.nodeId, [
|
Plotly.plot(this.nodeId, [
|
||||||
{
|
{
|
||||||
x: this.timeArray, // Use timeArray as x values
|
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() {
|
updateGraph() {
|
||||||
let time = new Date();
|
let time = new Date();
|
||||||
this.timeArray.push(new Date());
|
this.timeArray.push(new Date());
|
||||||
@@ -71,7 +74,7 @@ class liveGraph {
|
|||||||
Plotly.relayout(this.nodeId, minuteView);
|
Plotly.relayout(this.nodeId, minuteView);
|
||||||
if (this.cnt === 10) clearInterval(interval);
|
if (this.cnt === 10) clearInterval(interval);
|
||||||
}
|
}
|
||||||
|
// function to get the new data for graph
|
||||||
updateData(temperature, humidity, eCO2, TVOC) {
|
updateData(temperature, humidity, eCO2, TVOC) {
|
||||||
// Update the graph
|
// Update the graph
|
||||||
this.tempArray.push(temperature);
|
this.tempArray.push(temperature);
|
||||||
|
Reference in New Issue
Block a user