I am using a d3.js time.scale
like this:
var xScale = d3.time.scale()
.domain(d3.extent(data, function(d) { return d.date; }))
.rang
If you want the ticks to show the month name and the year, add this to the axis:
.tickFormat(d3.time.format("%B %Y"));
Alternatively, you can display the abbreviated month name:
.tickFormat(d3.time.format("%b %Y"));
Here is the updated jsbin: http://jsbin.com/wikafuluqu/1/edit?js,output
PS: To show the first tick, add nice()
to the scale. This is the jsbin with nice()
:
http://jsbin.com/loyupelazu/1/edit?js,output