Data points and ticks in the scaleBand axis are not aligned

穿精又带淫゛_ 提交于 2019-12-01 07:33:01

The band scale is the wrong tool in this situation. The main reason is that a band scale has an associated bandwidth.

You can tweak the paddingInner and paddingOuter values of the band scale to give you the expected result. However, the easiest solution is using a point scale instead. Point scales:

...are a variant of band scales with the bandwidth fixed to zero. (emphasis mine)

So, it should be:

var yScale = d3.scalePoint()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!