Data points and ticks in the scaleBand axis are not aligned

前端 未结 1 802
自闭症患者
自闭症患者 2021-01-13 18:52

My data points and the values in the scaleBand y axis are not aligned. I am not able to align them properly, when I read the documentation, saw that by default the alignment

1条回答
  •  离开以前
    2021-01-13 19:00

    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()
    

    0 讨论(0)
提交回复
热议问题