Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Calendar heatmap

Since 0.1.0-alpha.22
Shows a year of daily activity at a glance, such as a contributions graph, with busy days darker.

Use a calendar heatmap to spot daily rhythms, streaks and standout days, such as orders over a year. It shows patterns, not amounts. For exact values or the trend, use a line or bar chart of the same days. A few weeks of data looks sparse.

A value for each day

Give CalendarHeatmap the Items, each one's Date and Value, and a Title.

Static

Preview

Commits in 2025
  • 0 to 5
  • 5 to 10
  • 10 to 15
Arrow keys move between values; Escape hides the tooltip.

Code

Usage.razor
@* A developer's commits on each day of 2025: steady weekdays, few weekends, two weeks off in August, a quiet holiday week. *@
<CalendarHeatmap Items="_days" Date="d => d.Day" Value="d => d.Commits"
                 From="new DateOnly(2025, 1, 1)" To="new DateOnly(2025, 12, 31)"
                 Title="Commits in 2025" />

@code {
    private record DayCommits(DateOnly Day, int Commits);

    private readonly DayCommits[] _days = Build();

    private static DayCommits[] Build()
    {
        var start = new DateOnly(2025, 1, 1);
        var days = new List<DayCommits>();
        for (var d = 0; d < 365; d++)
        {
            var day = start.AddDays(d);
            var weekend = day.DayOfWeek is DayOfWeek.Saturday or DayOfWeek.Sunday;
            var away = day >= new DateOnly(2025, 8, 4) && day <= new DateOnly(2025, 8, 15) || day >= new DateOnly(2025, 12, 24);
            // A spread from quiet days to busy ones; a weekend now and then.
            var noise = (d * 7919 + 13) % 97 / 97.0;
            var commits = away ? 0
                : weekend ? (noise > 0.8 ? (int)(noise * 6) : 0)
                : (int)(1 + 11 * noise * noise + (day.Month is 3 or 10 ? 4 : 0));
            // Days without commits aren't in the data, as a query by day would return them.
            if (commits > 0) days.Add(new DayCommits(day, commits));
        }

        return [.. days];
    }
}

Add this example to a page with the izzy CLI:

bash
izzy add component CalendarHeatmap --at <file>:<line>

From and To set the range, here the whole year, so the quiet weeks at its end still show; without them it runs from the first item's day to the last's. Weeks start on the culture's first day, Sunday here, or FirstDayOfWeek.

A day with no value is gray, not the lightest shade: an empty day isn't a zero. Here days without commits aren't in the items, so the shades start at one commit and the quiet days read as gaps. To shade zeros instead, include them.

Point at a day, or move with the arrow keys, for its date and value.

Diverging colors

For values on either side of a meaningful middle, such as each day's temperature against the normal, set Palette to ChartPalette.Diverging. The scale turns gray at Midpoint (0 by default).

Static

Preview

Chicago against normal, 2025 (°C)
  • −15.0 to −10.0
  • −10.0 to −5.0
  • −5.0 to 0.0
  • 0.0 to +5.0
  • +5.0 to +10.0
  • +10.0 to +15.0
Arrow keys move between values; Escape hides the tooltip.

Code

Diverging.razor
@* How far each day's average temperature in Chicago was from its 1991–2020 normal, in °C: a warm spell, a cold snap. *@
<CalendarHeatmap Items="_days" Date="d => d.Day" Value="d => d.Difference"
                 Palette="ChartPalette.Diverging(Color.Primary, Color.Danger)"
                 ValueFormat="+0.0;−0.0;0.0" FirstDayOfWeek="DayOfWeek.Monday"
                 Title="Chicago against normal, 2025 (°C)" />

@code {
    private record DayTemperature(DateOnly Day, double Difference);

    private readonly DayTemperature[] _days = Build();

    private static DayTemperature[] Build()
    {
        var start = new DateOnly(2025, 1, 1);
        var days = new List<DayTemperature>();
        var drift = 0.0;
        for (var d = 0; d < 365; d++)
        {
            // Weather comes in spells: each day keeps most of the day before's difference.
            var hash = Math.Sin(d * 12.9898) * 43758.5453;
            var kick = (hash - Math.Floor(hash) - 0.5) * 3.5;
            drift = 0.8 * drift + kick;
            // A cold snap in late January, a hot spell in July.
            var spell = d is >= 20 and < 30 ? -9 : d is >= 185 and < 196 ? 6 : 0;
            days.Add(new DayTemperature(start.AddDays(d), Math.Round(drift + spell + 0.6, 1)));
        }

        return [.. days];
    }
}

Here the weeks start on Monday (FirstDayOfWeek). To compare years, draw one calendar per year with the same Min and Max, so their colors mean the same values.

Details

The range runs from the first item's day to the last's, or From to To. Weeks start on the culture's first day, or FirstDayOfWeek. A day in the range with no item, or a null value, is drawn as no data, never as a zero. The colors are a HeatmapChart's: five even steps from round bounds by default (Steps, Min, Max), a diverging palette's two sides of Midpoint, your own HeatmapRange children, or a continuous blend (Steps 0). The legend is the scale.

Parts

Written inside CalendarHeatmap. The API page lists their parameters.

  • HeatmapRange: a class of values on a HeatmapChart<T>'s or CalendarHeatmap<T>'s scale, with its own color and name, in place of the chart's even steps: <HeatmapRange From="0" To="10" Color="Color.Of("#dbeafe")" Label="Quiet" />.
  • HeatmapTooltip<TItem>: a HeatmapChart<T>'s or CalendarHeatmap<T>'s tooltip content, in place of the cell's row, column and value: <HeatmapTooltip Context="c">@c.Row, @c.Column: @c.Text orders</HeatmapTooltip>.

Mode support

What works in each mode, Calendar heatmap
FeatureStaticInteractive
A column per week and a row per weekday, from the culture's first day or one you chooseYesYes
Months named along the top, thinning as the calendar narrowsYesYes
Days with no data told apart from zeros, and days outside the range left outYesYes
A HeatmapChart's colors: even steps, a diverging scale, named ranges or a blendYesYes
Square days that fit the widthYesYes
Legend keys that hide and show the days in their classYesYes
A table of the values, a column per month, in a "Show data" disclosureYesYes
Tooltips on hover and from the keyboard, day by dayYesYes

Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.

Without JavaScript

Every page starts as plain HTML: before IzzyBlazor's script loads on a static page, while an interactive page prerenders, and with JavaScript off.

  • Legend keys that hide and show the days in their class: waits for the script
  • Tooltips on hover and from the keyboard, day by day: waits for the script

Accessibility

  • The chart is a figure captioned by Title, or named by a heading on the page with TitledBy.
  • The calendar is one image named by the caption. The legend lists the scale's classes.
  • "Show data" under the chart opens the values as a table, a column per month and a row per day of the month (DataTable).
  • With script, the calendar is one Tab stop: the arrow keys move from day to day and say each one's date and value.

Keyboard navigation

On the calendar

CalendarHeatmap keys, On the calendar
Press this keyTo do this
Down or UpMove to the next or previous day
Right or LeftMove a week later or earlier (reversed on right-to-left pages)
Home or EndGo to the first or last day in the row
Ctrl+Home or Ctrl+EndGo to the first or last day
EscapeHide the tooltip

Parameters

CalendarHeatmap parameters
PropTypeDefault
RefreshHow often the chart reads its data again, at least a second, such as Refresh="TimeSpan.FromSeconds(30)".TimeSpan?
RefreshFromOn a static page with Refresh: a lighter page to fetch than this one, which renders the same chart with the same id.string?
ItemsThe items, a day each: each names its day and its value.IEnumerable<TItem>?Required
DateEach item's day, such as c => c.Day: a DateOnly, DateTime or DateTimeOffset (the time is ignored).Expression<Func<TItem, object?>>Required
ValueEach item's value, such as c => c.Count: any number, or null for no data.Expression<Func<TItem, object?>>Required
FromThe first day shown: the earliest item's day by default.DateOnly?
ToThe last day shown: the latest item's day by default.DateOnly?
FirstDayOfWeekThe day each week's column starts on, at the top: the culture's by default (Sunday in en-US, Monday in most of Europe).DayOfWeek?
TitleThe chart's title, such as "Commits this year", shown above it as its caption.string?
HideTitleHides the title, which still names the chart for screen readers.boolfalse
DownloadShows a button across from the title that saves the chart as a PNG, named after its title, in the color scheme on screen.boolfalse
TitleAlignWhere the title sits: at the start by default (the left, in a left-to-right page); ChartAlign.Center or ChartAlign.End.ChartAlignChartAlign.Start
TitledByThe id of a heading already on the page that titles the chart, such as a card's, in place of Title: the chart takes its name from it and shows no title of its own.string?
ValueFormatA .NET format string for the values, such as N0 or P0: in the legend, the tooltips and the table.string?
PaletteThe colors: Shades of the primary color by default, light to dark for low to high; Shades of another color; Diverging for values above and below Midpoint, such as each day's temperature against normal; or your own ramp with Of, one class per color.ChartPalette?
StepsHow many classes the values fall into, each a shade: 5 by default, 2 to 9, even steps between round bounds around the values (or from Min to Max).int5
MidpointThe value a Diverging scale turns at, gray in the middle: 0 by default.double?
MinThe scale's low end, so calendars side by side, such as one per year, share a scale.double?
MaxThe scale's high end.double?
CellSizeThe largest a day grows to: 2rem by default.Length?
LegendWhere the legend, the color scale, goes: above the calendar by default (ChartLegend.Auto or ChartLegend.Top), ChartLegend.Bottom, or upright beside it with ChartLegend.Start or ChartLegend.End (above it under 30rem); ChartLegend.None leaves it out.ChartLegendChartLegend.Auto
LegendAlignThe legend's place along its edge: the start by default, the center or the end.ChartAlign?
TooltipThe tooltip for the day under the pointer or the keyboard (with script), beside its cell: on by default.booltrue
DataTableThe values as a table, a column per month and a row per day of the month: by default behind a "Show data" button that opens it over the chart; ChartDataTable.Collapsed puts it in a disclosure under the chart.ChartDataTableChartDataTable.Popover
ChildContentHeatmapRanges, your own classes, and a HeatmapTooltip<T> (its Date the day, Column the day as text, Row the weekday).RenderFragment?
OnRefreshOn an interactive page with Refresh: raised at each interval, to load new data.EventCallback

See also

  • HeatmapChart: shows where values run high or low across two dimensions, such as the busiest hours of the week.
  • Chart: draws a chart on the server from a list of items, with axes, value labels, reference lines, trends and a table of the values, for every chart type.

Connection lost

Rejoining the server…