Refactor graph classes and add data processor

This commit is contained in:
sietse jonker
2024-03-31 21:08:40 +02:00
parent 28cc13484f
commit e94f12e13c
2 changed files with 117 additions and 81 deletions

View File

@@ -1,6 +1,6 @@
// Sample data - you can replace this with your actual dataset
const data = [];
processor = new DataProcessor();
// Function to create checkbox with label
function createCheckBox(id, label) {
const checkbox = document.createElement("input");
@@ -109,19 +109,28 @@ function createFilterContainer() {
// Get request to fetch data from the server
function fetchData() {
fetch("http://145.92.8.114/getMeasurements")
fetch("http://145.92.8.114/getMeasurements?dateStart=2024-03-27%2011:47:11&dateEnd=2024-03-27%2011:47:11")
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
})
.then((measurements) => {
.then((data) => {
createFilterContainer();
processor.update(data);
processor.graph();
})
.catch((error) => {
console.error("Error fetching data:", error);
});
}
fetchData();
fetchData();
// Function to create the graph
function createGraph() {
const graph = new Graph("graph");
graph.updateGraph();
}