I am using chart.js to make a bar chart, and I hope to modify the color of a certain data bar. Does anyone know how to do it?
My code is as follows
function drawChart(chartid,datalist,label){
var ctx = document.getElementById(chartid).getContext("2d");
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: label,
datasets: [{
label:'訪問(wèn)次數(shù)',
data: datalist,
backgroundColor: [
'rgba(54, 162, 235, 0.5)'
],
}]
},
options
});
}
For example, if I want to modify the color of the first data, how should I write it in js? Thank you all.
Declare the variable array externally, then write the color you set in it, and then pass the parameters into the setting item