Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
How do i change color of label? Chart.js

I'm implementing a website in django and on it I have a dashboard page. I have a graph that shows the billing of the months but I can't change the color that is marked in the photo below.

Chart js bars

$(function () {
  var $populationChart = $("#faturamento-mes");
  $.ajax({
    url: $populationChart.data("url"),
    success: function (data) {

    const backgroundcolor = []

    for(i=0; i < data.data.length; i++){
        if (data.data[i] < 6500){backgroundcolor.push('red')}
        if (data.data[i] >=6500){backgroundcolor.push('green')}
    }

      var ctx = $populationChart[0].getContext("2d");

      new Chart(ctx, {
        type: 'bar',
        data: {
          labels: data.labels,
          datasets: [{
            label: 'Faturamento',
            backgroundColor: backgroundcolor,
            data: data.data
          }]
        },
        options: {
          responsive: true,
          legend: {
            position: 'top',
          },
          title: {
            display: true,
            text: 'Faturamento por mês'
          }
        }
      });

    }
  });

});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda