Skip to content
LIBRARYCharts

Heatmap ​

RC.12.1

Included in RC.12.1 for Vue + Vite, Nuxt and NativeScript.

Web preview
Open example ↗
vue
<MHeatmap v-model="selected" :start="start" :end="end" :values="values" label="Practice" />
PropTypeDefaultContract
start / endCivilDaterequiredInclusive ISO civil dates; range 1–366 days. No time zone conversion.
valuesreadonly HeatmapValue[]requiredUnique date, nonnegative finite value or null; optional label and disabled. Missing differs from zero.
modelValueCivilDate | nullnullControlled selected day.
colors / cellSize / weekStartsOnstring[] / number / 0|1theme / 28 / 1Theme scale or 2–8 six-digit HEX colors; 28–80px/DIP cells; Sunday or Monday first.
localeen-US | pt-BRen-USLanguage of month and weekday labels. weekStartsOn controls the first day.
animated / disabled / formatValueboolean / boolean / functiontrue / false / StringJolt color interpolation, selection lock and value formatting.
label / idstringrequired / optionalAccessible component name and optional stable ID.

Dates are laid out in week columns with month and weekday labels. The default five-color scale follows the active theme’s elevated and primary colors, including theme changes; set colors for an explicit palette. Each day is a named control with its exact value; View data exposes a linear text alternative. Arrow keys move by day/week, Home/End to the first/last day. The first color is reserved for zero; positive values use the remaining stops; absent or null values remain unpainted. Jolt interpolates the cell paint while accessible values update immediately. Reduced motion settles immediately. Long periods scroll horizontally inside the component.

update:modelValue → CivilDate.

Motion ​

The first time the calendar is on screen, the days light up in a wave across the weeks, with a slight lean down each column. It plays once; a theme change or new values repaint the cells instead. A heatmap below the fold waits until it is scrolled into view. Pointing at a day lifts it slightly, and a newly selected day gives a small bump. Motion uses Jolt and respects reduced motion, which shows the calendar complete. Use :animated="false" for static presentation.

vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import { civilDate, addCivilDays, calendarDayLabel } from '@getcortexlabs/mavis-core'
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const t = (en: string, pt: string) => ((props.lang ?? locale.value) === 'pt' ? pt : en)
const animated = ref(true)
const { theme } = useMavisTheme()
const dateLocale = computed(() => t('en-US', 'pt-BR') as 'en-US' | 'pt-BR')
const start = civilDate('2026-09-01'),
  end = civilDate('2026-11-30'),
  selected = ref<ReturnType<typeof civilDate> | null>(civilDate('2026-11-19')),
  week = ref(0)
const values = computed(() =>
  Array.from({ length: 91 }, (_, i) => ({
    date: addCivilDays(start, i),
    value: i % 13 === 0 ? null : (i * 7 + week.value * 3) % 11,
  })),
)
const total = computed(() => values.value.reduce((sum, day) => sum + (day.value ?? 0), 0))
const activeDays = computed(() => values.value.filter((day) => (day.value ?? 0) > 0).length)
const selectedDay = computed(() => values.value.find((day) => day.date === selected.value))
const selectedSummary = computed(() => {
  if (!selected.value)
    return t('Select a square to explore the day.', 'Toque em um quadrado para explorar o dia.')
  const value = selectedDay.value?.value
  return value == null
    ? t('No activity recorded for this day.', 'Sem registro de atividade neste dia.')
    : `${value} ${t(value === 1 ? 'creative session' : 'creative sessions', value === 1 ? 'sessão criativa' : 'sessões criativas')}`
})
</script>
<template>
  <MColumn gap="lg">
    <MColumn gap="sm">
      <MText
        :text="t('THE CREATIVE PRACTICE', 'A PRÁTICA CRIATIVA')"
        variant="overline"
        tone="primary"
      />
      <MText :text="t('A little, every day.', 'Um pouco, todos os dias.')" variant="title" />
      <MText
        :text="
          t(
            'Three months of ideas taking shape. Every square, a day in the studio.',
            'Três meses de ideias tomando forma. Cada quadrado, um dia no estúdio.',
          )
        "
        tone="muted"
      />
    </MColumn>
    <MCard padding="lg" gap="lg">
      <MRow justify="between" align="end" gap="md" wrap>
        <MColumn gap="xs">
          <MText :text="String(total)" variant="display" />
          <MText :text="t('creative sessions', 'sessões criativas')" tone="muted" />
        </MColumn>
        <MColumn gap="xs" align="end">
          <MText :text="t('SEP — NOV 2026', 'SET — NOV 2026')" variant="overline" tone="muted" />
          <MText :text="`${activeDays} ${t('active days', 'dias de atividade')}`" weight="600" />
        </MColumn>
      </MRow>
      <MSeparator />
      <MHeatmap
        id="studio-heatmap"
        v-model="selected"
        :start="start"
        :end="end"
        :values="values"
        :locale="dateLocale"
        :animated="animated"
        :label="t('Your daily rhythm', 'Seu ritmo, dia a dia')"
        :dataLabel="t('View data', 'Ver dados')"
        :missingLabel="t('No data', 'Sem dados')"
        :lessLabel="t('Less', 'Menos')"
        :moreLabel="t('More', 'Mais')"
      />
      <MSeparator />
      <MRow gap="md" align="center">
        <MBox padding="sm" radius="sm" :backgroundColor="theme.colors.primarySoft">
          <MIcon name="calendar" :size="20" tone="primary" />
        </MBox>
        <MColumn gap="xs" :grow="1">
          <MText :text="selectedSummary" weight="600" />
          <MText
            :text="
              selected
                ? calendarDayLabel(selected, dateLocale)
                : t('Choose a day', 'Escolha um dia')
            "
            variant="caption"
            tone="muted"
          />
        </MColumn>
      </MRow>
    </MCard>
    <MRow gap="sm" wrap justify="between" align="center">
      <MButton
        :text="t('Another chapter', 'Outro capítulo')"
        variant="secondary"
        icon="refresh-cw"
        @click="week++"
      />
      <MText id="heatmap-value" :text="selected ?? '—'" variant="caption" tone="muted" />
    </MRow>
    <MCard padding="md" elevation="none">
      <MSwitch v-model="animated" :label="t('Animate changes', 'Animar mudanças')" />
    </MCard>
  </MColumn>
</template>

Desktop ​

On desktop the calendar is one control: the arrow keys move a day or a week at a time and announce the day, Return selects it, moving the focus elsewhere clears the day the keys reached, and the pointer shows the day in a tooltip. Days that cannot be chosen are skipped, the data list keeps every day reachable as a button, and the calendar fades in once instead of lighting up in a wave; see Desktop components.

Components for NativeScript and Web. Starting with Vue.