How to set custom width of bar in NDV3 Discreate bar chart

你说的曾经没有我的故事 提交于 2019-12-05 03:04:44

If 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.

ALAN ALBY

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,
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!