javascript - How to modify the color of a specified bar in chart.js
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-07-05 11:05:48
0
2
773

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:'访问次数',
            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.

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
Ty80

Declare the variable array externally, then write the color you set in it, and then pass the parameters into the setting item

过去多啦不再A梦

fillColor property

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template