如何在Chartjs 2条形图中修改条宽 [英] How to modify bar width in Chartjs 2 bar charts
问题描述
有人告诉我如何在Chartjs 2条形图中修改条宽。文档中没有任何内容。
https://github.com/nnnick/Chart.js/tree/v2.0-dev/docsI 不知道该怎么做。
注意,似乎有一些变化。
对于版本2.0.0-alpha
为xAxes设置 categorySpacing
。
Chart.defaults.bar.scales.xAxes [0] .categorySpacing = 0
或者您可以通过图表进行。
...
scale:{
xAxes:[{
categorySpacing:0
}],
...
小提琴 - http:/ /jsfiddle.net/beehe4eg/
对于版本1.0.2 / p>
调整选项
barValueSpacing
和barDatasetSpacing
更近。这将自动增加其宽度。Can someone told me how to modify bar width in Chartjs 2 bar charts. There is nothing about it in the documentation.
https://github.com/nnnick/Chart.js/tree/v2.0-dev/docsI don't know what to do.
解决方案Note that there seems to be some changes going on. The actual configuration would depend on which v2.0 you are using.
For Version 2.0.0-alpha
Set
categorySpacing
for the xAxes. You can do this globallyChart.defaults.bar.scales.xAxes[0].categorySpacing = 0
or you can do it by chart
... scales: { xAxes: [{ categorySpacing: 0 }], ...
Fiddle - http://jsfiddle.net/beehe4eg/
For Version 1.0.2
Adjust the options
barValueSpacing
andbarDatasetSpacing
to make the bars closer. This will automatically increase their width.这篇关于如何在Chartjs 2条形图中修改条宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!