如何在Chartjs 2条形图中修改条宽 [英] How to modify bar width in Chartjs 2 bar charts

查看:964
本文介绍了如何在Chartjs 2条形图中修改条宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人告诉我如何在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 globally

Chart.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 and barDatasetSpacing to make the bars closer. This will automatically increase their width.

这篇关于如何在Chartjs 2条形图中修改条宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆