0
votes

How can I create an axis (in my case a Y-axis) that represents the seven days of the week? They are not related to any specific dates, it just needs to literally represent Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

The idea is then to associate some data to the respective day of the week (data that occurred on Mondays in the Monday label, etc.)

I searched about d3.ticks and and other d3 time scales associated with axes, but it seems the week scale only draws ticks one one certain day of each week, and I do not want that. Any ideas? Thanks.

1

1 Answers

2
votes

If you are aggregating your data by day then you would create this axis as you would for any other categorical/ordinal data in d3. Take a look at http://bl.ocks.org/mbostock/3259783

var y = d3.scale.ordinal()
    .domain(["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"])
    .rangePoints([0, width]);

var yAxis = d3.svg.axis()
    .scale(y)
    .orient("left");