starting gauge
This commit is contained in:
20
web/new website/gauge.js
Normal file
20
web/new website/gauge.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// JavaScript
|
||||
function updateGauge(value) {
|
||||
const gaugeValue = document.getElementById('gaugeValue');
|
||||
const maxGaugeValue = 100; // Maximum value the gauge can display
|
||||
const rotationDegree = ((value / maxGaugeValue) * 180) - 90; // Convert value to degree (-90 to 90)
|
||||
|
||||
gaugeValue.style.transform = `rotate(${rotationDegree}deg)`;
|
||||
|
||||
// Change color based on value
|
||||
if (value <= 40) {
|
||||
gaugeValue.style.backgroundColor = 'green';
|
||||
} else if (value <= 80) {
|
||||
gaugeValue.style.backgroundColor = 'orange';
|
||||
} else {
|
||||
gaugeValue.style.backgroundColor = 'red';
|
||||
}
|
||||
}
|
||||
|
||||
// Example usage:
|
||||
updateGauge(50); // Rotates the gauge to 0 degrees (50 out of 100) and changes color to orange
|
BIN
web/new website/gauge.png
Normal file
BIN
web/new website/gauge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
32
web/new website/index.html
Normal file
32
web/new website/index.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="style.css"
|
||||
<title>bruh</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="Node">
|
||||
<div class="Sensorvalues">
|
||||
<div id="gaugeContainer" class="gaugeContainer">
|
||||
<img src="gauge.png" class="gaugeImage">
|
||||
|
||||
<div id="gaugeValue" class="gaugeValue">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- HTML -->
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<script src="gauge.js"></script>
|
59
web/new website/style.css
Normal file
59
web/new website/style.css
Normal file
@@ -0,0 +1,59 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
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 {
|
||||
width: 8px;
|
||||
height: 280px;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
/* CSS */
|
||||
/* CSS */
|
||||
.gaugeContainer {
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
border: 3px solid black;
|
||||
border-radius: 50%;
|
||||
margin: 50px auto;
|
||||
position: relative;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.gaugeValue {
|
||||
width: 10px;
|
||||
height: 150px;
|
||||
position: absolute;
|
||||
bottom: 50%;
|
||||
left: 50%;
|
||||
transform-origin: bottom;
|
||||
transition: transform 0.3s ease, background-color 0.3s ease; /* Smooth transition for rotation and color change */
|
||||
}
|
||||
|
||||
.gaugeImage {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 100%;
|
||||
}
|
Reference in New Issue
Block a user