Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!