commit 6453b63ec7212321aad373f3f1e0a1a8045513d4
parent 872a841f6aefd6ee812a362b7873b6183a88e6bb
Author: Kninteman <[email protected]>
Date: Mon, 12 Jun 2023 15:25:00 +0200
Merge branch 'datatowebsite' of https://github.com/friedelschoen/iwa-panda into datatowebsite
Diffstat:
2 files changed, 51 insertions(+), 44 deletions(-)
diff --git a/Model/Key.php b/Model/Key.php
@@ -58,7 +58,7 @@ Class Key{
JOIN geolocation geo ON geo.country_code = co.country_code
JOIN contract c ON cs.contract_id = c.contract_id
WHERE c.token = 'ae9c50dc5cd58c538a0d6aedb17fffedcaffd568d22381dab3ae72baaeb24684'
- group by nl.name";
+ ";
$stmt = mysqli_prepare($db, $query);
$stmt->execute();
$data = $stmt->get_result();
diff --git a/js/panda.js b/js/panda.js
@@ -42,48 +42,56 @@ function jsonSorter(key) {
var ctx = document.getElementById('myChart').getContext('2d');
// Create the chart
-var myChart = new Chart(ctx, {
- type: 'line',
- data: {
- labels: ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'],
- datasets: [
- {
- label: 'Dataset 1',
- data: [1, 2, 3, 4, 5],
- backgroundColor: 'rgba(176, 204, 207, 1)',
- borderColor: 'rgba(176, 204, 207, 1)',
- borderWidth: 2
- },
- {
- label: 'Dataset 2',
- data: [6, 7, 8, 9, 10],
- backgroundColor: 'rgba(195, 176, 207, 1)',
- borderColor: 'rgba(195, 176, 207, 1)',
- borderWidth: 2
- }
- ]
- },
- options: {
- responsive: true,
- scales: {
- y: {
- beginAtZero: true,
- ticks: {
- color: 'white'
- }
+fetch(`http://localhost:8080/api/:ae9c50dc5cd58c538a0d6aedb17fffedcaffd568d22381dab3ae72baaeb24684`)
+.then(response => response.json())
+ .then(data=> {
+ let array = []
+ data.forEach(point=>{
+ array.push(point['humidity'])
+ })
+ var myChart = new Chart(ctx, {
+ type: 'line',
+ data: {
+ labels: ['Measurement 1', 'Measurement 2', 'Measurement 3', 'Measurement 4', 'Measurement 5'],
+ datasets: [
+ {
+ label: 'Dataset 1',
+ data: array,
+ backgroundColor: 'rgba(176, 204, 207, 1)',
+ borderColor: 'rgba(176, 204, 207, 1)',
+ borderWidth: 2
+ },
+ {
+ label: 'Dataset 2',
+ data: [6, 7, 8, 9, 10],
+ backgroundColor: 'rgba(195, 176, 207, 1)',
+ borderColor: 'rgba(195, 176, 207, 1)',
+ borderWidth: 2
+ }
+ ]
},
- x: {
- ticks: {
- color: 'white'
+ options: {
+ responsive: true,
+ scales: {
+ y: {
+ beginAtZero: true,
+ ticks: {
+ color: 'white'
+ }
+ },
+ x: {
+ ticks: {
+ color: 'white'
+ }
+ }
+ },
+ plugins: {
+ legend: {
+ labels: {
+ color: 'white'
+ }
+ }
}
}
- },
- plugins: {
- legend: {
- labels: {
- color: 'white'
- }
- }
- }
- }
-});
-\ No newline at end of file
+ });
+ })