I created a bar chart (fiddle) using D3.js.
I have one (probably very simple) question for which I would be glad to get some support:
Why is the x-axis too short?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Older question, and my first answer attempt on Stack, but hopefully still useful:
From what I can tell your X domain only goes to XMax, which will be the bottom-left point of the last bar of the graph – it’s not coming up “short”, it just doesn’t know how wide the bar is after XMax.
(It does not account for you adding the barWidth of 20 pixels, and your text placement does account for the additional width, which seems to be why you’re seeing the problem only with the Axis.)
In order to extend the axis all the way to the end, you’ll have to account for the additional barWidth in your domain, or append the additional barWidth another way. That might be possible by adding another half day or so on to your xMax, or by shifting each bar to the left of its X position (-barWidth) instead of +barWidth.