Add createDiv() method to Graph class and update graph-classes.js, graphs.html, and graph-styles.css

This commit is contained in:
Sietse Jonker
2024-04-02 16:39:32 +02:00
parent 5316e2d647
commit b69b029628
4 changed files with 27 additions and 12 deletions

View File

@@ -8,11 +8,16 @@ class Graph {
this.tvocArray = [];
}
createDiv() {
let div = document.createElement("div");
let graphDiv = document.createElement("div");
div.setAttribute("class", "graphBody");
graphDiv.setAttribute("id", this.id);
div.appendChild(graphDiv);
document.body.appendChild(div);
}
// Function to create a graph
makeGraph(line, lineColor, name) {
let div = document.createElement("div");
div.setAttribute("id", this.id);
document.graphBody.appendChild(div);
let lineArray;
switch (line) {
case "temp":
@@ -132,6 +137,7 @@ class DataProcessor {
makeGraph() {
this.graph = new Graph(1);
this.graph.createDiv();
this.graph.makeGraph("temp", "red", "Temperature");
this.graph.makeGraph("humi", "blue", "Humidity");
this.graph.makeGraph("eco2", "green", "eCO2");