Skip to content

Contribution Heatmaps

ContributionGraph and CalendarHeatmap render calendar-style activity charts from date/count rows. The core geometry maps dates into deterministic week and weekday cells, so timezone, leap-year, and week-start behavior can be tested without React Native.

import { ContributionGraph } from "react-native-chart-kit/v2";

const endDate = "2026-05-03";
const numDays = 154;
const values = Array.from({ length: numDays }, (_, index) => {
  const end = new Date(`${endDate}T00:00:00.000Z`);
  const date = new Date(
    end.valueOf() - (numDays - 1 - index) * 24 * 60 * 60 * 1000
  );
  const weekday = date.getUTCDay();
  const cycle = (index * 7 + weekday * 3) % 17;
  const launchWeekBoost = index > 110 && index < 126 ? 8 : 0;
  const weekendDip = weekday === 0 || weekday === 6 ? -4 : 0;

  return {
    date: date.toISOString().slice(0, 10),
    count: Math.max(0, cycle + launchWeekBoost + weekendDip)
  };
});

<ContributionGraph
  values={values}
  endDate={endDate}
  numDays={numDays}
  width={360}
  height={162}
  weekStartsOn={1}
  preset="analytics"
/>;

Custom Color Scale

<ContributionGraph
  values={values}
  endDate="2026-05-03"
  numDays={154}
  width={340}
  height={150}
  colors={["#dbeafe", "#93c5fd", "#3b82f6", "#1d4ed8"]}
/>

Use onDayPress to connect cells to native tooltips, bottom sheets, or app-level detail panels.

Empty Ranges

An empty values array still renders the requested date range as zero-count cells. This keeps loading, quiet-period, and newly created workspace states visually stable.

<ContributionGraph
  values={[]}
  endDate="2026-05-03"
  numDays={154}
  width={340}
  height={150}
  weekStartsOn={1}
/>

Props

ContributionGraph / CalendarHeatmap

CalendarHeatmap is exported as an alias of ContributionGraph and accepts the same props.

PropTypeDescription
valuesTData[]Source contribution rows.
endDatestring, number, or DateLast date included in the rendered range.
numDaysnumberNumber of days to render, counting backward from endDate.
widthnumberOuter chart width in pixels.
heightnumberOuter chart height in pixels.
accessorkeyof TDataRow key used for contribution values when not using the default count.
cellSizenumberSize of each day cell in pixels.
gutterSizenumberGap between day cells in pixels.
weekStartsOnnumberFirst day of the week, where 0 is Sunday and 1 is Monday.
showMonthLabelsbooleanShows or hides month labels above the heatmap.
showWeekdayLabelsbooleanShows or hides weekday labels beside the heatmap.
showOutOfRangeDaysbooleanRenders calendar cells outside the requested date range.
theme"light", "dark", "system", or CartesianChartThemeTheme mode or inline theme tokens for this chart.
presetCartesianChartPresetValueBuilt-in or registered preset name used to seed chart colors and typography.
colorsstring[]Color scale used for non-empty contribution values.
emptyColorstringFill color used for zero or missing values.
colorForValue(props) => stringCustom color resolver for each rendered cell.
getMonthLabel(monthIndex, date) => stringCustom month label formatter.
getWeekdayLabel(dayIndex) => stringCustom weekday label formatter.
onDayPress(event) => voidCalled when a day cell is pressed.
rendererContributionGraphRendererRenderer implementation used for SVG-compatible primitives.
accessibilityLabelstringOverrides the generated accessible chart summary.
testIDstringTest identifier applied to the chart surface.