d3 ticks only shows Sundays:
d3.js
Solution
I was just faced with a very similar problem and I was not able to find an answer in the d3 documentation. However, I took a peek at the d3 source code (https://github.com/mbostock/d3/blob/master/d3.js) and I was able to find the following line:
d3.time.weeks = d3.time.sunday.range;
With this hint in mind: Note that, as described in the documentation,
var xAxis = d3.svg.axis()
.scale(x)
.ticks(d3.time.weeks, 1);
gives an axis with a tick on every Sunday — and so
var xAxis = d3.svg.axis()
.scale(x)
.ticks(d3.time.xxxday.range, 1);
gives an axis with a tick on every `xxxday`, where `xxxday` is `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, or `sunday`.
Problem
I would like for my scale to start on the first day and end on the last day rather than just show Sundays: I would like for the data to start at : 28 (not 3) but it starts on a 3 which is Sunday: How can i start my scale on any day of the week? I want the days shown to match the data I give the graph not show Sundays. Link to example: http://jsfiddle.net/3LZua/2/ Thanks in advance. P.S. Here is the code: (there would be a in the html) ``` followerLineGraph = function(data) { var width = 400; var x = d3.time.scale() .domain([data[0].date, data[data.length - 1].date]) .range([0, width]); var chart = d3.select("#test").append("svg").attr("class", "chart"); //Date Label var xAxis = d3.svg.axis() .scale(x) .ticks(data.length) .tickFormat(d3.time.format('%m/%d-%a')) .tickSize(0) .tickPadding(8); chart.append('g') .attr('fill', '#1ff') .call(xAxis); } var data = [ { date: new Date(2013, 1, 28), TotalLikes: 18 }, { date: new Date(2013, 2, 14), TotalLikes: 15 }, { date: new Date(2013, 2, 21), TotalLikes: 17 }, { date: new Date(2013, 2, 28), TotalLikes: 17 }, { date: new Date(2013, 3, 4), TotalLikes: 20 } ]; followerLineGraph(data); ```