Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
690 views
in Technique[技术] by (71.8m points)

javascript - How to change the width of barchart div in chartjs?

I'm currently doing the Barchart in chartjs and I'm having a hard time finding the correct props that will change the width of the cell.

I want to set the cell/div of barchart to 100px. I have tried these option props e.g. categoryPercentage, barPercentage, but it does not allow me to set it to 100px. Someone could help how to do it?

Here's a sample codepen

Demo picture: enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are searching for barThickness

Note: It's only available in Chart.js 2.2.0+

data: {
    datasets: [{
        barThickness: 100,
        data: [10, 20, 30, 40, 50, 60, 70]
    }]
};

Demo


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...