如何在Chart.js中单独更改条形宽度?

时间:2019-09-24 09:37:50

标签: chart.js

enter image description here

如何像示例图片一样更改条形图的背景和宽度。

1 个答案:

答案 0 :(得分:0)

尝试一下

this.myChart = new Chart(ctx, {
    type: 'bar',
    data: {
        datasets: [{
            backgroundColor: [
            'rgba(0,128,0,0.2)',
            'rgba(0,0,0,0)'
            ],
        }]
    },
    options: {
        scales: {
            yAxes: [{
                barPercentage: 0.5,
                barThickness: 6,
                maxBarThickness: 8,
                minBarLength: 2
            }]
        }
    }
});