Fix graph update bug and optimize data processing

This commit is contained in:
sietse jonker
2024-04-01 13:50:49 +02:00
parent 59377aa2b5
commit c539bb2edf

View File

@@ -42,8 +42,7 @@ class Graph {
}
updateData(type, value, timestamp) {
this.timeArray.push(timestamp);
// this.timeArray.push(timestamp);
switch (type) {
case "Temp":
this.tempArray.push(value);
@@ -67,7 +66,7 @@ class Graph {
x: [this.timeArray],
y: [this.tempArray, this.humiArray, this.eco2Array, this.tvocArray],
};
console.log(update);
Plotly.update(this.id, update);
}
}
@@ -140,12 +139,13 @@ class DataProcessor {
}
updateGraph() {
for (let i = 0; i < this.data.length; i + 3) {
for (let i = 0; i < 4; i++) {
this.graph.updateData(this.data[i].Type, this.data[i].Value, this.data[i].TimeStamp);
console.log(this.data[i].Type, this.data[i].Value, this.data[i].TimeStamp);
this.graph.updateGraph();
for (let i = 0; i < this.data.length; i++) {
if (i % 4 == 0){
this.graph.timeArray.push(this.data[i].TimeStamp);
}
this.graph.updateData(this.data[i].Type, this.data[i].Value, this.data[i].TimeStamp);
console.log(this.data[i].Type, this.data[i].Value, this.data[i].TimeStamp);
}
}
this.graph.updateGraph();
}
}