Skip to main content

Module calendar

Module calendar 

Source
Expand description

Calendar heatmap layout (stat_calendar / GGPlot::geom_calendar): a date column becomes week-column × weekday-row tiles.

Structs§

CalendarGrid
The calendar grid shared by StatCalendar and geom_calendar: which day is column 0 / row 0, and the (clipped) first/last day.
StatCalendar
Lays a date x out as calendar cells: x = week column, y = weekday row (first weekday on top, y = 6 … 0), unit xmin/xmax/ymin/ymax extents, and the ISO date in DATE_KEY_COL. Other columns (fill, label, …) pass through. Dates older than MAX_CALENDAR_YEARS before the newest are dropped.

Constants§

DATE_KEY_COL
Column holding each cell’s ISO date (YYYY-MM-DD); geom_tile uses it as the hover key (data-x and tooltip) instead of the week/weekday position.
MAX_CALENDAR_YEARS
Longest span laid out, in years. Older dates are clipped (with a build warning from geom_calendar) so a stray 1900-01-01 cannot blow up the layout or allocate thousands of month boundaries.

Functions§

civil_from_days
Civil (year, month, day) of a day number (Hinnant).
day_number
Days since 1970-01-01 for a date value: DateTime (epoch seconds), a number (epoch seconds, as DateTime coerces), or an ISO YYYY-MM-DD… string. None for anything else / out of range.
days_from_civil
Days since 1970-01-01 of a civil date (Hinnant).
month_boundaries
Month boundary segments (x, y, xend, yend) separating consecutive months (GitHub/ECharts style step outlines), in calendar coordinates.
month_breaks
Month-start x breaks/labels for a calendar grid: the week column of each month’s first day. Over two years, only Januaries are labelled (with the year); a multi-year range adds the year to each January.
weekday
Weekday of a day number, 0-based from the week start (Sunday or Monday).