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
|
Reference in New Issue
Block a user