Merge branch 'main' of gitlab.fdmci.hva.nl:propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-3/qaajeeqiinii59

This commit is contained in:
Bram Barbieri
2024-03-27 20:03:10 +01:00
3 changed files with 98 additions and 39 deletions

View File

@@ -1,10 +1,12 @@
// JavaScript // JavaScript
function updateGauge(value) { function updateGauge(value) {
const gaugeValue = document.getElementById('gaugeValue'); const gaugeValue = document.getElementById('gaugeValue');
const gaugeText = document.getElementById('gaugeText');
const maxGaugeValue = 100; // Maximum value the gauge can display const maxGaugeValue = 100; // Maximum value the gauge can display
const rotationDegree = ((value / maxGaugeValue) * 180) - 90; // Convert value to degree (-90 to 90) const rotationDegree = ((value / maxGaugeValue) * 180) - 90; // Convert value to degree (-90 to 90)
gaugeValue.style.transform = `rotate(${rotationDegree}deg)`; gaugeValue.style.transform = `rotate(${rotationDegree}deg)`;
gaugeText.textContent = value; // Update the text
// Change color based on value // Change color based on value
if (value <= 40) { if (value <= 40) {
@@ -17,4 +19,4 @@ function updateGauge(value) {
} }
// Example usage: // Example usage:
updateGauge(50); // Rotates the gauge to 0 degrees (50 out of 100) and changes color to orange updateGauge(50); // Rotates the gauge to 0 degrees (50 out of 100), changes color to orange, and updates the text to "50"

View File

@@ -1,32 +1,60 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css" <link rel="stylesheet" href="style.css">
<title>bruh</title> <title>bruh</title>
</head> </head>
<body> <body>
<div class="gaugeGroup">
<h2 class="groupTitle">Gauge Group</h2> <!-- Title above the gauges -->
<div class="Node"> <div class="Node">
<div class="Sensorvalues"> <div class="Sensorvalues">
<div id="gaugeContainer" class="gaugeContainer"> <div id="gaugeContainer" class="gaugeContainer">
<img src="gauge.png" class="gaugeImage"> <img src="gauge.png" class="gaugeImage">
<div id="gaugeValue" class="gaugeValue"> <div id="gaugeValue" class="gaugeValue"></div>
<div id="gaugeText" class="gaugeText">0</div>
<div class="gaugeCover"></div>
</div>
</div>
<div class="Sensorvalues">
<div id="gaugeContainer" class="gaugeContainer">
<img src="gauge.png" class="gaugeImage">
<div id="gaugeValue" class="gaugeValue"></div>
<div id="gaugeText" class="gaugeText">0</div>
<div class="gaugeCover"></div>
</div>
</div>
<div class="Sensorvalues">
<div id="gaugeContainer" class="gaugeContainer">
<img src="gauge.png" class="gaugeImage">
<div id="gaugeValue" class="gaugeValue"></div>
<div id="gaugeText" class="gaugeText">0</div>
<div class="gaugeCover"></div>
</div>
</div>
<div class="Sensorvalues">
<div id="gaugeContainer" class="gaugeContainer">
<img src="gauge.png" class="gaugeImage">
<div id="gaugeValue" class="gaugeValue"></div>
<div id="gaugeText" class="gaugeText">0</div>
<div class="gaugeCover"></div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- HTML -->
</body> </body>
</html> </html>
<script src="gauge.js"></script> <script src="gauge.js"></script>

View File

@@ -4,24 +4,6 @@
box-sizing: border-box; box-sizing: border-box;
} }
.gaugeContainer {
width: 300px;
height: 300px;
border: 3px solid black;
border-radius: 50%;
margin: 50px auto;
position: relative;
}
.center-point {
width: 20px;
height: 20px;
background-color: black;
border-radius: 50%;
position: absolute;
top: 137px;
left: 137px;
}
.speedometer-scale { .speedometer-scale {
width: 8px; width: 8px;
@@ -29,16 +11,15 @@
background-color: black; background-color: black;
} }
/* CSS */
/* CSS */ /* CSS */
.gaugeContainer { .gaugeContainer {
width: 300px; width: 30vw;
height: 300px; height: 300pxx;
border: 3px solid black; border: 3px solid black;
border-radius: 50%; fill: grey;
margin: 50px auto; margin: 50px auto;
position: relative; position: relative;
display: block; overflow: hidden; /* Hide the first half of the gauge */
} }
.gaugeValue { .gaugeValue {
@@ -48,12 +29,60 @@
bottom: 50%; bottom: 50%;
left: 50%; left: 50%;
transform-origin: bottom; transform-origin: bottom;
transition: transform 0.3s ease, background-color 0.3s ease; /* Smooth transition for rotation and color change */ transition: transform 0.3s ease, background-color 0.3s ease;
}
.gaugeText {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
text-align: center;
z-index: 2; /* Bring the value to the front */
} }
.gaugeImage { .gaugeImage {
display: block; display: block;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
width: 100%; width: auto;
z-index: 2; /* Bring the value to the front */
}
.gaugeContainer {
width: 80%; /* Adjust this value as necessary */
height: 80%; /* Adjust this value as necessary */
border: 3px solid black;
fill: grey;
margin: 10% auto;
position: relative;
overflow: hidden;
}
.Node {
display: flex; /* Use Flexbox */
justify-content: space-between; /* Distribute the items evenly along the horizontal line */
flex-wrap: wrap; /* Allow the items to wrap onto multiple lines if necessary */
}
.Sensorvalues {
flex: 1 0 20%; /* Allow the items to grow and shrink as necessary, and set the base width to 20% */
margin: 10px; /* Add some margin around the items */
background-color: #333; /* Dark background color */
color: #fff; /* Light text color */
padding: 20px; /* Some padding around the gauges */
border-radius: 10px; /* Round borders */
}
.gaugeGroup {
background-color: #333; /* Dark background color */
color: #fff; /* Light text color */
padding: 20px; /* Some padding around the gauges */
margin-bottom: 20px; /* Some margin below the group */
}
.groupTitle {
text-align: center; /* Center the title */
margin-bottom: 20px; /* Some margin below the title */
} }