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.
$(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'
}
}
});
}
});
});