Build a calendar heatmap: interpret daily patterns and missing dates
A calendar heatmap places dates on a calendar grid and encodes a measure with color. Define daily aggregation, color range, and missing-date handling before interpreting patterns.
What one calendar cell means
A calendar heatmap places dates on a week-by-week grid and colors each date by a measure. One cell should represent one date in a chosen time zone and one measure aggregated for that date. Define the date rule, aggregation and meaning of blank dates before coloring the grid.
Raw events may have many rows per day. Aggregate to one row per date first. Sum count measures; for a rate, calculate the defined daily numerator divided by its denominator rather than averaging row-level rates. State whether “day” follows event time or processing time and when timestamps are converted to local dates.
Define the date and daily measure
The event time and collection time may differ. Set the reporting time zone, day boundary, business-day rule and data cutoff. Late events can change recent dates at the next refresh, so show the data-as-of time.
| Measure | Daily aggregation example | Check |
|---|---|---|
| Order count | Count daily order IDs | How are duplicate events and cancellations handled? |
| Revenue | Sum amounts for the defined date | What about refunds, tax, currency and business-day rules? |
| Rate | Daily numerator ÷ daily denominator | Follow the metric definition; do not blindly average precomputed rates. |
Keep zero separate from missing
No row does not prove that activity was zero. Fill a date with zero only when the source is complete and its data contract says no row means no activity. If collection failed, data is late or a filter excluded the date, keep it unknown and show it differently from zero.
The following fictional values illustrate the distinction:
| Date | Source state | Display value | Meaning |
|---|---|---|---|
| Apr 1 | Complete; 8 orders | 8 | Observed count |
| Apr 2 | Complete; no orders | 0 | Confirmed zero |
| Apr 3 | Refresh failed; no date row | Missing | Data state unknown, not zero |
| Apr 4 | Complete; 15 orders | 15 | Observed count |
A blank white cell can be mistaken for no activity. Explain zero, missing and refresh delay in the legend; provide a table or labels so color is not the only cue.
Check week layout and year boundaries
Columns usually represent weeks and rows weekdays, but a week may start Sunday or Monday depending on convention. Choose and state the week-number rule. Dates near New Year may belong to the next year's first week or the prior year's last week under that rule. Check leap years, 53-week years, and empty cells in the first and last weeks against a real calendar.
Use the same color domain across years when comparing them. Otherwise, the darkest color in one year may represent a smaller value than a lighter color in another. Explain the range and bins when a distribution is strongly skewed.
What the Vega example shows—and does not
The official Vega calendar example uses daily S&P 500 changes since 2000. It sorts dates, brings in the prior close, calculates change, derives year/week/weekday, lays out a grid per year, draws one rectangle per date and shows date and change in a tooltip. Its color domain is −6%, 0 and +6%; values outside are clamped to the end colors. This is a Vega implementation example, not a default feature of every BI tool or live market data.
For the first record, the example calculates change as zero when no previous close exists. In real data this can mean “no comparison value,” not an observed unchanged day. Decide from the metric definition whether to mark it missing or exclude it. With color clamping, several extreme values may share an endpoint color; show the actual value and scale in the tooltip.
Vega-Lite also documents that rect marks with discrete x and y fields create a heatmap. Calendar coordinates and week/year calculations still need to be prepared correctly.
Validate before publishing
Record the date, time zone, day boundary, measure definition and aggregation for one cell.
Build a complete date spine, join the daily values and distinguish confirmed zeros from missing dates.
Fix the week start and numbering rule; compare year boundaries, leap days and 53-week years with a calendar.
Keep the color domain stable across comparable periods; explain zero, missing, extremes and clamped values in the legend.
Reconcile selected cells against source totals and check refresh time. Make date and value available through a table or text as well as hover.
Official references
[Vega: Calendar Example](https://vega.github.io/vega/examples/calendar-view/)
[Vega-Lite: Rect mark](https://vega.github.io/vega-lite/docs/rect.html)
[W3C WCAG 2.2: Use of Color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color)