From 24aaf29bce5180a0097237e415897bbea3c8643a Mon Sep 17 00:00:00 2001 From: Bram Barbieri Date: Tue, 2 Apr 2024 17:05:55 +0200 Subject: [PATCH] beginning with getting data --- web/newWebsite/questions-main.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/web/newWebsite/questions-main.js b/web/newWebsite/questions-main.js index 06bf47e..8703471 100644 --- a/web/newWebsite/questions-main.js +++ b/web/newWebsite/questions-main.js @@ -1,5 +1,30 @@ //For now create dummy data to show on the website. -let dummydata1 = [40, 30, 20]; +let awa; + +data(); + + +async function data(){ +fetch("http://145.92.8.114/getQuestionData") +.then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); +}) +.then(data => { + console.log(data); + let Q1Array = data.filter(item => item.Question_QuestionID == 1); + console.log(Q1Array); + let R1Array = Q1Array.filter(item => item.Result == 0); + awa = R1Array.length; + graph() +}) + +} +// for each(Result == 0) in +async function graph() { +let dummydata1 = [awa, 3, 5]; let questionOptionsDummy1 = ['disgusting','clean', 'fine']; let dummydata2 = [25, 35, 40]; @@ -52,3 +77,4 @@ const myChart4 = new Chart(ctx4, chartConfigArray[3].chartConfig); const ctx5 = document.getElementById('chart5').getContext('2d'); const myChart5 = new Chart(ctx5, chartConfigArray[4].chartConfig); +} \ No newline at end of file