I need to draw axis with time scale and show only days on it. Here is my code:
var xScale = d3.time.scale.utc()
.domain([beginning, ending])
.range([margin.left, availableWidth - margin.right]);
var xAxis = d3.svg.axis()
.scale(xScale)
.orient(orient)
.tickFormat(tickFormat)
.ticks(d3.time.days.utc, 1)
.tickSize(tickSize);
But on long intervals it is bad overlapping (because I show every tick):
https://pp.vk.me/c620728/v620728099/16ab9/HdJByiakoKA.jpg
I make some math operations and calculate acceptable amount of ticks:
var xAxis = d3.svg.axis()
...
.ticks(d3.time.days.utc, stepTick) // for example 20 for a year interval
.tickSize(tickSize);
So every 20th tick on axis will be shown for a year and it looks great! Except joint of month:
https://pp.vk.me/c620728/v620728099/16aaf/PjM4KJ0ofTM.jpg (31.05/01.06)
Labels on joint of month are still overlapping, because in docs for d3.time.days we can see that
If step is specified, then every step'th date will be returned, based on the day of the month.
How should I do to prevent labels overlapping ?