Calendar
Lay a daily value out as a grid of weeks and weekdays, one colored cell per day, to read seasonality and streaks across a year or several.
A calendar heatmap draws one cell per day, with weeks as columns and weekdays as rows, and colors each cell by that day’s value. It suits daily data where seasonality, streaks and weekday patterns matter more than exact values.
Use a line chart when the reader needs to read values off an axis or compare a few series, and a heatmap when the two axes are categories rather than dates. A calendar has no axes at all, so the color legend is the only way to read a number.
A basic calendar
x is the daily date with type: "temporal", one row per day, and color is the quantitative value. There is no y channel, because the calendar computes its own weeks-by-weekdays layout. Days with no data row render as empty cells, so the grid always shows the whole year, and these demos fill a few weeks of it.
A diverging scheme such as redBlue suits values that run above and below a normal, and reverse: true makes warm days red. The scale spans the data’s minimum to maximum, so set a symmetric domain to put the neutral color at zero. format sets how the legend prints values.
Daily temperature anomaly over five weeks. This chart is drawn in the browser.
{
"mark": "calendar",
"data": [
{
"date": "2024-06-03",
"anomaly": 0.1
},
{
"date": "2024-06-04",
"anomaly": -0.9
},
{
"date": "2024-06-05",
"anomaly": 1.2
},
{
"date": "2024-06-06",
"anomaly": -0.9
},
{
"date": "2024-06-07",
"anomaly": 0.7
},
{
"date": "2024-06-08",
"anomaly": 0.7
},
// … 29 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "Five summer weeks of daily temperature anomalies",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. One cell per day, weeks run left to right."
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "calendar",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "Five summer weeks of daily temperature anomalies",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. One cell per day, weeks run left to right."
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "calendar",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "Five summer weeks of daily temperature anomalies",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. One cell per day, weeks run left to right."
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "calendar",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "Five summer weeks of daily temperature anomalies",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. One cell per day, weeks run left to right."
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "calendar",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "Five summer weeks of daily temperature anomalies",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. One cell per day, weeks run left to right."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Sunday weeks and rounder cells
Two mark options change the grid. weekStart sets which weekday sits in the top row, "monday" by default or "sunday". cellRadius sets the corner radius of each day cell in pixels. Default 2. This demo also swaps in a sequential scheme, "blues", because the values here run from low to high rather than around a midpoint.
{
"mark": {
"type": "calendar",
"weekStart": "sunday",
"cellRadius": 6
},
"data": [
{
"date": "2024-06-02",
"reading": 3.2
},
{
"date": "2024-06-03",
"reading": 1.6
},
{
"date": "2024-06-04",
"reading": 1.8
},
{
"date": "2024-06-05",
"reading": 1.3
},
{
"date": "2024-06-06",
"reading": 1.8
},
{
"date": "2024-06-07",
"reading": 1.2
},
// … 22 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "reading",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Weeks start on Sunday and cells have rounder corners",
"subtitle": "Daily reading, one cell per day. weekStart: sunday, cellRadius: 6."
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 28 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "calendar",
"weekStart": "sunday",
"cellRadius": 6
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "reading",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Weeks start on Sunday and cells have rounder corners",
"subtitle": "Daily reading, one cell per day. weekStart: sunday, cellRadius: 6."
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 28 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "calendar",
"weekStart": "sunday",
"cellRadius": 6
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "reading",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Weeks start on Sunday and cells have rounder corners",
"subtitle": "Daily reading, one cell per day. weekStart: sunday, cellRadius: 6."
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 28 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "calendar",
"weekStart": "sunday",
"cellRadius": 6
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "reading",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Weeks start on Sunday and cells have rounder corners",
"subtitle": "Daily reading, one cell per day. weekStart: sunday, cellRadius: 6."
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 28 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "calendar",
"weekStart": "sunday",
"cellRadius": 6
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "reading",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Weeks start on Sunday and cells have rounder corners",
"subtitle": "Daily reading, one cell per day. weekStart: sunday, cellRadius: 6."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Several years
Data that spans several years splits into one band per year, each a full calendar year, stacked one above the other with the year as a label. The bands share a single color scale and a single legend, so colors compare across years. This demo puts the same four June weeks of 2023 and 2024 in two bands.
The same June weeks in two years. This chart is drawn in the browser.
{
"mark": "calendar",
"data": [
{
"date": "2023-06-05",
"anomaly": -0.1
},
{
"date": "2023-06-06",
"anomaly": 0
},
{
"date": "2023-06-07",
"anomaly": 1
},
{
"date": "2023-06-08",
"anomaly": 1
},
{
"date": "2023-06-09",
"anomaly": 0.9
},
{
"date": "2023-06-10",
"anomaly": 1.1
},
// … 50 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "June 2023 and June 2024, one band per year",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. Both bands share one color scale."
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 56 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "calendar",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "June 2023 and June 2024, one band per year",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. Both bands share one color scale."
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 56 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "calendar",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "June 2023 and June 2024, one band per year",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. Both bands share one color scale."
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 56 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "calendar",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "June 2023 and June 2024, one band per year",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. Both bands share one color scale."
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 56 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "calendar",
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"color": {
"field": "anomaly",
"type": "quantitative",
"scale": {
"scheme": "redBlue",
"reverse": true,
"domain": [
-2.5,
2.5
]
},
"format": "+.1f"
}
},
"chrome": {
"title": "June 2023 and June 2024, one band per year",
"subtitle": "Daily temperature anomaly against the seasonal normal, degrees C. Both bands share one color scale."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Fields that matter
| Field | What it does |
|---|---|
mark |
"calendar", or an object with weekStart and cellRadius. |
encoding.x |
The date of each day, type: "temporal". |
encoding.color |
The quantitative value that colors each cell. It also drives the legend. |
encoding.color.scale.scheme |
A named color scheme, such as "redBlue" or "blues". |
encoding.color.scale.reverse |
Flips the direction of the scheme. |
encoding.color.format |
A d3-format string for the legend values. |
mark.weekStart |
"monday" or "sunday": the weekday in the top row. |
mark.cellRadius |
Corner radius of day cells, in pixels. Default 2. |
Related
- Line for daily values read against an axis.
- Sparkline for a small trend without a calendar layout.
- Heatmap for color over two categorical axes.
- Histogram for how often each value occurs.
- Marks reference lists the channels and options each mark type takes.