Diferencia entre revisiones de «Usuario:RubiVGM/statsDynamicColors»

De Unión PokéPRO - Wiki
Ir a la navegaciónIr a la búsqueda
Página creada con «// Función para cambiar el color de las barras según su valor document.addEventListener('DOMContentLoaded', function() { document.querySelectorAll('.stat-bar').forEach(function(bar) { var value = parseInt(bar.getAttribute('data-value')); // Obtiene el valor de la estadística if (value < 50) { bar.style.backgroundColor = '#ff5959'; // Rojo } else if (value >= 50 && value < 100) { bar.style.backgroundColor = '#fae078'; // Naranja } el…»
 
Sin resumen de edición
Línea 1: Línea 1:
// Función para cambiar el color de las barras según su valor
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function() {
  document.querySelectorAll('.stat-bar').forEach(function(bar) {
  document.querySelectorAll('.stat-bar').forEach(function(bar) {
    var value = parseInt(bar.getAttribute('data-value'));  // Obtiene el valor de la estadística
    var value = parseInt(bar.getAttribute('data-value'));  // Obtiene el valor de la estadística
    if (value < 50) {
    if (value < 50) {
      bar.style.backgroundColor = '#ff5959';  // Rojo
      bar.style.backgroundColor = '#ff5959';  // Rojo
    } else if (value >= 50 && value < 100) {
    } else if (value >= 50 && value < 100) {
      bar.style.backgroundColor = '#fae078';  // Naranja
      bar.style.backgroundColor = '#fae078';  // Naranja
    } else {
    } else {
      bar.style.backgroundColor = '#a7db8d';  // Verde
      bar.style.backgroundColor = '#a7db8d';  // Verde
    }
    }
  });
  });
});
});

Revisión del 21:30 28 ene 2025

document.addEventListener('DOMContentLoaded', function() {
  document.querySelectorAll('.stat-bar').forEach(function(bar) {
    var value = parseInt(bar.getAttribute('data-value'));  // Obtiene el valor de la estadística
    if (value < 50) {
      bar.style.backgroundColor = '#ff5959';  // Rojo
    } else if (value >= 50 && value < 100) {
      bar.style.backgroundColor = '#fae078';  // Naranja
    } else {
      bar.style.backgroundColor = '#a7db8d';  // Verde
    }
  });
});