Skip to documentation content

Contribution Graph

A composable calendar heatmap for showing daily activity across weeks and months.

Basic Contribution Graph

Overview

Use a contribution graph to show daily activity over a long period: commits, workouts, orders, or support load. Each day is a cell in a week column, so streaks, weekly rhythms, quiet seasons, and holidays stand out at a glance. It answers "how consistent was this?" better than a line chart, which hides the day-of-week pattern.

Anatomy

ContributionGraph owns the daily data, the date range, the first day of the week, and the loading state. Every day in the range is drawn; days without data are empty. Add Cells for size, gaps, and levels, Months and Weekdays for labels, Legend for the "Less … More" scale, and Tooltip for the date and value of a day. Rows on the same day add up.

Cells take discrete levels from the value's config color: a single color steps from 30% to full opacity, and a multi-stop color uses one stop per level. The empty level is a faint wash of the foreground.

Accessibility

When ariaLabel is omitted, the generated name gives the date range, the total, and the number of active days. Levels differ in lightness as well as hue, and the legend shows every level in order. The tooltip is pointer-operated, so summarize streaks, totals, or busy days in nearby text when people need them.

Installation

npm install honestui

Usage

The data has one row per day, or several rows per day that add up. dateKey holds a YYYY-MM-DD string, a timestamp, or a Date.

import { ContributionGraph, type ChartConfig } from "honestui/charts";
<ContributionGraph
  data={data}
  config={chartConfig}
  dateKey="date"
  valueKey="commits"
  range={2025}
>
  <ContributionGraph.Months />
  <ContributionGraph.Weekdays />
  <ContributionGraph.Legend />
  <ContributionGraph.Tooltip />
  <ContributionGraph.Cells />
</ContributionGraph>

Without range, the graph shows the 52 weeks ending on the latest day in data. Cells grow to fill the container's width, up to maxSize, and the whole block is centered.

Thresholds and Week Start

thresholds and weekStart={1}

By default, levels split the range from zero to the busiest day evenly. Pass thresholds to set the lower bound of each level yourself, which keeps levels stable as data changes. This example starts weeks on Monday, labels every weekday, uses a four-stop color, and renames the legend ends.

Loading State

isLoading='true'

Pass isLoading to reserve the layout with a neutral cell pattern and the same loading treatment as the other Honest UI charts.

API Reference

ContributionGraph
PropTypeDefaultDescription
data*TData[]–

Rows with a day and a value. Several rows on one day add up.

config*ChartConfig–

Defines the label and theme colors for valueKey.

dateKey*keyof TData & string–

The field holding each row's day: a YYYY-MM-DD string, a timestamp, or a Date.

valueKey*keyof TData & string–

The numeric field counted on each day.

rangenumber | [start, end]–

A year, or a pair of days. Defaults to the 52 weeks ending on the latest day in data.

weekStart0 | 1 | 2 | 3 | 4 | 5 | 60

First day of each week column, where 0 is Sunday and 1 is Monday.

classNamestring–

Additional CSS classes for the chart container. Give the chart an explicit height.

animationbooleantrue

Enables the intro animation. Reduced-motion preferences disable it automatically.

isLoadingbooleanfalse

Replaces the data with a neutral cell pattern and a progress label.

ariaLabelstring–

Accessible name for the canvas chart. A summary of the range and total is generated when omitted.

onDayClick(day: ContributionDay<TData>) => void–

Fires when a day is selected and Cells has isClickable.

chartOptionsRecord<string, unknown>–

Escape hatch merged over the generated ECharts option object.

Cells
PropTypeDefaultDescription
radiusnumber2

Cell corner radius in pixels.

gapnumber2

Space between cells in pixels.

levelsnumber4

Number of colored levels above the empty level.

thresholdsnumber[]–

Lower bound of each colored level, ascending. Overrides levels.

maxSizenumber14

Largest cell size in pixels. Cells shrink to fit the container.

isClickablebooleanfalse

Enables the pointer cursor and onDayClick.

Months
PropTypeDefaultDescription
tickFormatter(month: number, year: number) => string–

Formats a month label, given the month index (0 is January) and year.

Weekdays
PropTypeDefaultDescription
showalternate|all"alternate"

Labels every other row, like Mon, Wed, Fri, or every row.

labelsstring[]–

Seven day labels, Sunday first.

Legend
PropTypeDefaultDescription
lessLabelstring"Less"

Label before the lowest level.

moreLabelstring"More"

Label after the highest level.

alignleft|right"right"

Aligns the legend to the grid's left or right edge.

Tooltip
PropTypeDefaultDescription
variantdefault|frosted-glass"default"

Tooltip surface treatment.

roundnesssm|md|lg|xl"lg"

Tooltip corner radius.

positionfixed|variable"variable"

Pins the tooltip to the top or lets it follow the pointer.

valueFormatter(value: number) => string–

Formats the value shown in the tooltip.

dateFormatter(date: Date) => string–

Formats the day shown as the tooltip title.