admin管理员组文章数量:1279186
Am trying to build vertical bar chart using nvd3 charts.
Problem : If chart has single record, bar width reaches 3/4 of the chart width.
Question : How to change width of the bars in Discrete bar chart?
Have attached chart please guide me..
Am trying to build vertical bar chart using nvd3 charts.
Problem : If chart has single record, bar width reaches 3/4 of the chart width.
Question : How to change width of the bars in Discrete bar chart?
Have attached chart please guide me..
Share Improve this question asked Mar 13, 2013 at 10:18 MohanMohan 88710 gold badges20 silver badges32 bronze badges2 Answers
Reset to default 9If you look at the source here. You'll see that the width of the rectangle is calculated based on the number of items using rangeBand. There doesn't appear to be a way to set the width of the rectangle though the library's API.
If you didn't want to patch the library, you could create additional fake bars with zero data and provide a label formatter that would return an empty string if the value was zero, but that assumes zero is not a valid number in your data set.
Use the follwing code to set the width
dispatch: {
renderEnd: function (e) {
d3.selectAll("rect.nv-bar").attr('rx', 4).attr('ry', 4).attr('width', 15)
}
}
or you can use
groupSpacing : 0.57,
本文标签: javascriptHow to set custom width of bar in NDV3 Discreate bar chartStack Overflow
版权声明:本文标题:javascript - How to set custom width of bar in NDV3 Discreate bar chart - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741230582a2362033.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论