Fix graph update bug and optimize data processing
This commit is contained in:
@@ -42,8 +42,7 @@ class Graph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateData(type, value, timestamp) {
|
updateData(type, value, timestamp) {
|
||||||
this.timeArray.push(timestamp);
|
// this.timeArray.push(timestamp);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "Temp":
|
case "Temp":
|
||||||
this.tempArray.push(value);
|
this.tempArray.push(value);
|
||||||
@@ -67,7 +66,7 @@ class Graph {
|
|||||||
x: [this.timeArray],
|
x: [this.timeArray],
|
||||||
y: [this.tempArray, this.humiArray, this.eco2Array, this.tvocArray],
|
y: [this.tempArray, this.humiArray, this.eco2Array, this.tvocArray],
|
||||||
};
|
};
|
||||||
|
console.log(update);
|
||||||
Plotly.update(this.id, update);
|
Plotly.update(this.id, update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,12 +139,13 @@ class DataProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateGraph() {
|
updateGraph() {
|
||||||
for (let i = 0; i < this.data.length; i + 3) {
|
for (let i = 0; i < this.data.length; i++) {
|
||||||
for (let i = 0; i < 4; i++) {
|
if (i % 4 == 0){
|
||||||
this.graph.updateData(this.data[i].Type, this.data[i].Value, this.data[i].TimeStamp);
|
this.graph.timeArray.push(this.data[i].TimeStamp);
|
||||||
console.log(this.data[i].Type, this.data[i].Value, this.data[i].TimeStamp);
|
|
||||||
this.graph.updateGraph();
|
|
||||||
}
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user