student student - 3 months ago 5
CSS Question

Chart bars not aligning with x axis values in d3.js

Trying to learn and implement d3.js for the first time.

In the fiddle, we needed to reduce the width of each bar from

line 46

to

.attr('width', '10')
line 50

When doing so, the horizontal x axis labels are getting dis-aligned with vertical bars which is not needed.

Tried to see a few solutions:



Any suggestions, kind folks?

Answer

Try this code:

.rangeBands([0, width], someValue)

Comments