Krizaka
Documentation

Geo map

Where: a world choropleth in one sequential hue, bubbles on places, country names in the reader's language — plain SVG, the world loaded on demand.

WebBetaCharts

Web only — React, from @krizaka/charts/geo. Beta: its API may still change in a minor version.

When to use

  • An audience by country: a creator's viewers, a service's users.
  • Places with an amount: cities, data centres, as bubbles.

When not to use

  • Deployment regions and the links between them, as a showpiece.Use instead: Globe
  • A precise comparison between a few countries.Use instead: Bar chart

Installation

Install

npm install @krizaka/charts

Import

import { GeoMap } from "@krizaka/charts/geo";

Examples

Viewers by country

A creator's viewers by country, the top cities as bubbles.

Viewers by country, last 90 days

Map, 12. France 48.2K (32%), Canada 31.5K (21%), United States 15.3K (10%), Morocco 12.9K (8.6%), Belgium 9.8K (6.5%). Total 150K.

Viewers by country, last 90 days — data
CountryViewers%
France48.2K32%
Canada31.5K21%
United States15.3K10%
Morocco12.9K8.6%
Belgium9.8K6.5%
Switzerland7.4K4.9%
Senegal6.1K4.1%
Tunisia5.6K3.7%
Côte d’Ivoire4.9K3.3%
Germany4.2K2.8%
Brazil2.3K1.5%
Japan1.8K1.2%
Paris21.4K
Montréal17.8K
Casablanca6.3K
Dakar3.9K

Props

PropTypeDefaultDescription
datarequiredreadonly T[]—One row per region with a value.
regionrequiredstring | ((datum: T, index: number) => string)—The field (or function) of the region's ISO 3166-1 alpha-2 code ("FR", "US").
titlerequiredstring—What the chart shows, in a few words: its accessible name, and its heading unless hideTitle.
valuerequiredstring | ((datum: T, index: number) => number)—The field (or function) of its value.
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 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".
onSelect((datum: T, index: number) => void)—Called with the row when a region is clicked (or Enter is pressed on it).
pointsreadonly GeoPoint[]—Bubbles on places, their area by value.
regionLabelstring—The header of the regions and of the values in the table (“Country”, “Viewers”).
stepsnumber—The number of colour steps of the scale. Default 5.
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).
valueLabelstring—The header of the values (“Viewers”).

Accessibility

  • The summary names the five largest regions with their shares; the table lists every region and place.
  • The Equal Earth projection keeps areas true: no country looks larger than it is.
  • The world's countries (~38 kB) are loaded only when a map is drawn; a skeleton holds the height meanwhile.

Keyboard

KeysAction
Arrow keysWalk the regions that have data, largest first, then the places.
Home / EndJump to the largest or the last item.
EscClears the active region.

Best practices

  • Key the regions by ISO 3166-1 alpha-2 (FR, US): the names come from Intl.DisplayNames in the reader's locale.
  • Map rates (per viewer, per capita) rather than raw counts when the countries' sizes differ widely.
  • Pair it with a ranked table or bars when the exact order matters.

Generated from the code of @krizaka/ui 2.4.0: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page