Skip to main content
100%

Monday-based Calendar

✓ Published0🌍 Public
EElisaDnr
Last edited Jan 6, 2018
Created on Jan 6, 2018

An annual heatmap displays traffic accident counts for each day of 2016, arranged in a single calendar grid. The visualization uses a color scale to encode the number of accidents per day, with the year laid out in columns of weeks and rows for days of the week. The code adapts a D3 calendar view to start weeks on Monday, using the `d3.time.format` function with the `%W` directive to compute week numbers. It loads daily accident data from a CSV file and renders the calendar as SVG, with month outlines drawn via the `monthPath` function.

AI-generated description

An example adaption of D3’s calendar-view using weeks that start on Monday. The only change is the definition of the day number and week number methods. For a Sunday-based week, use:

var day = function(d) { return d.getDay(); },
    week = d3.time.format("%U");

For a Monday-based week, use:

var day = function(d) { return (d.getDay() + 6) % 7; },
    week = d3.time.format("%W");

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/1648635'>Monday-based Calendar</a>

gpl-3.0 Licensed

Similar vizzes