问题
for one value the bar width is width of canvas so i want only to change the width of bar
how to fix the width of bar size ?
回答1:
Check this out
barThickness
Manually set width of each bar in pixels. If not set, the base sample widths are calculated automatically so that they take the full available widths without overlap. Then, the bars are sized using barPercentage and categoryPercentage.
Your code should be something like this:
var myBarChart = new Chart(ctx, {
type: 'bar',
data: data,
options: {
scales: {
xAxes: [{
barThickness: 10
}]
}
});
I made this example for you
来源:https://stackoverflow.com/questions/48906453/how-to-set-width-of-bar-dynamically-in-chart-js