ro如何降低条形高度-Chart.js [英] How ro reduce bar height - Chart.js
问题描述
我正在使用带有引导程序的chart.js中的条形图. canvas
被包装在具有class col-md-8
的div中.它工作正常,但栏的高度过高.
I'm using bar-chart from chart.js with bootstrap. canvas
is wrapped within a div having class col-md-8
. It works fine but the height of bar is too high.
我发现可以更改的 barWIdth
属性,但是找不到任何 barHeight
属性.那么如何收取小巴高度呢?
I found barWIdth
property that could be changed but was unable to find any barHeight
property. So how to charge the bar-height?
这是屏幕截图:
通过CSS更改其高度后,标签将被压缩
After change its height via css, labels are compress
推荐答案
理想情况下,将 maintainAspectRatio
设置为 false
Ideally, set maintainAspectRatio
to false
type: 'bar',
options: {
maintainAspectRatio: false
}
然后,如果您想要保持一定的高度(不会影响标签),或者保持原样,则可以使用CSS来处理图表的高度.
Then, you can play with the chart's height using CSS if you want to maintain a certain height (that will not affect the labels), or leave it as it is.
这篇关于ro如何降低条形高度-Chart.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!