Krizaka
Documentation

Heatmap

A measure across two dimensions — activity by weekday and hour — in one sequential hue, with a step legend.

WebBêtaGraphiques

Web uniquement — React, depuis @krizaka/charts/heatmap. Bêta : son API peut encore changer à une version mineure.

Quand l’utiliser

  • When something happens: uploads by weekday and hour, errors by service and day.
  • A matrix of two categorical dimensions with a value in each cell.

Quand ne pas l’utiliser

  • One value per day over a year.À la place : Calendar heatmap
  • Exact values matter more than the pattern.À la place : Bar chart

Installation

Installer

npm install @krizaka/charts

Importer

import { Heatmap } from "@krizaka/charts/heatmap";

Exemples

Activity by hour

Uploads by weekday and hour of the day: when a community is awake.

Uploads by day and hour

Last 4 weeks, Montréal time

Heatmap, 8 × 7. Peak 73 (Sat, 18:00), 56 with a value.

Uploads by day and hour — data
Day / Hour00:0003:0006:0009:0012:0015:0018:0021:00
Mon69123123444750
Tue131682730404346
Wed912152326475042
Thu168113022434649
Fri121572629504245
Sat1215183538707365
Sun1911144245666972

Props

PropTypeDéfautDescription
datarequisreadonly T[]—One row per cell.
titlerequisstring—What the chart shows, in a few words: its accessible name, and its heading unless hideTitle.
valuerequisstring | ((datum: T, index: number) => number)—The field of the cell's value.
xrequisstring | ((datum: T, index: number) => unknown)—The field of the column (an hour, a day) and of the row (a weekday, a team).
yrequisstring | ((datum: T, index: number) => unknown)—The field of the row (a weekday, a team).
brandBrandId—The brand whose palette the charts use. Without it, a chart follows a .brand-<id> ancestor, else Krizaka. Set it when the app loads a brand stylesheet on :root (@krizaka/tokens/brands/orazaka.css).
classNamestring—A class on the figure (layout: margins, grid placement).
dataTableboolean—The "Show data" button (the table is in the page for screen readers either way). Default true.
descriptionReactNode—A sentence under the title: the period, the unit, the source.
emptyReactNode—What to show when there is nothing to draw (default: the empty label). An EmptyState of @krizaka /ui fits.
errorReactNode—The data could not be loaded: true says the default words, a node says yours (a retry button…).
exportableboolean | readonly ExportFormat[]—Export buttons: true for PNG, SVG and CSV, or the formats you want.
formatValueFormat—How the values, the columns and the rows are written.
heightnumber—The height of the plot in pixels. Default 280 (a sparkline: 32).
hideTitleboolean—Visually hide the title (it stays the chart's accessible name): a card that already has its heading.
idstring—The id of the figure.
labelsChartLabelsInput—The words, translated: the buttons, the states, the written summary.
liveboolean—Streaming data (a job queue, an auction): no entrance on updates, no announcement of every new point.
loadingboolean—The data is on its way: a skeleton of the chart, announced once.
localeLocale—The locale of every figure and date ("fr-FR"). Default "en-US".
rendererRenderer—svg (default): sharp, exportable as SVG. canvas: for tens of thousands of marks.
styleCSSProperties—Inline style on the figure (layout only: colours come from the tokens).
summary"hidden" | "visible"—The written summary: read by screen readers only ("hidden", default), or shown under the chart ("visible").
summaryTextstring—Your own summary instead of the generated one (still read first by screen readers).
xCategoriesreadonly unknown[]—The order of the columns and the rows. Default: as they first appear.
xFormatCategoryFormat—How the columns are written.
xLabelstring—The headers of the data table.
yCategoriesreadonly unknown[]—The order of the rows. Default: as they first appear.
yFormatCategoryFormat—How the rows are written.
yLabelstring—The header of the rows in the data table.

Accessibilité

  • The plot is a group named by the title and described by a summary written from the data, read before anything else.
  • The data table is always in the page for assistive technology; “Show data” reveals it for everyone.
  • The engine (ECharts core and this one chart type) loads when the chart nears the screen; a skeleton of the same height holds its place, so nothing shifts.
  • Under reduced motion the chart is drawn without animation.
  • The cells are walked row by row; each is read with its row, column and value.

Clavier

TouchesAction
TabMoves the focus to the plot (one tab stop), then to the data and export buttons.
Arrow keysWalk the items one by one: each is announced and highlighted, its tooltip shown.
Home / EndJump to the first or the last item.
EscHides the tooltip and clears the highlight.

Bonnes pratiques

  • Give the order of the rows and columns (xCategories, yCategories): weekdays in order, not as they appear.
  • Keep empty cells empty: a missing value is not a zero.

Générée depuis le code de @krizaka/ui 2.4.0 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page