Chart card
The frame of a chart: title, one line of insight, the chart, a footer, and the actions menu (view as table, download, copy) — used everywhere a chart is shown.
- Domaine
- Affichage de données
- Niveau de support
- Taille
- Non mesurée
- Qui l'utilise
- Aucun produit en production ne l'importe encore
import { ChartCard } from "@krizaka/charts/card";Web uniquement — React, depuis @krizaka/charts/card. Bêta : son API peut encore changer à une version mineure.
- Mobile · ✗ à construire. A phone dashboard frames its charts in a Card by hand today. issue #275
Pourquoi il est là. The one frame of every chart of Sovkora's dashboard and usage pages (#253).
Quand l’utiliser
- Every chart of a dashboard or a usage page: the same frame, the same hierarchy, the same actions.
- A chart that needs a period switch or a filter beside its actions menu.
Quand ne pas l’utiliser
Installation
Installer
npm install @krizaka/chartsImporter
import { ChartCard } from "@krizaka/charts/card";Exemples
Jobs per day
Stacked bars by outcome, an insight, a footer and the actions menu.
What you made
A donut whose legend chips carry values and filter the ring.
Sparse and empty
The time axis zoomed on the active period, and a calm empty state.
Before and after
The same chart bare, then in a ChartCard.
Props
The frame of a chart: title, insight, actions, chart, footer — used everywhere a chart is shown.
| Prop | Type | Défaut | Description |
|---|---|---|---|
childrenrequis | ReactNode | — | The chart (LineChart, BarChart, DonutChart…), without its own title. |
titlerequis | string | — | What the chart shows, in a few words (a heading and the chart's accessible name). |
actions | ReactNode | — | Controls beside the actions menu: a period switch, a filter. |
className | string | — | A class on the card (layout: grid placement). |
description | ReactNode | — | The period, the unit, the source — under the insight. |
footer | ReactNode | — | A line under the chart: the source, the freshness, a link. |
id | string | — | The id of the card. |
insight | ReactNode | — | One line that says what the chart shows: “100 jobs · +100 % vs last week”. Written by the app, from its data. |
Accessibilité
- The chart keeps its data table in the page, its written summary and its keyboard walk inside the card.
- The actions menu is a real menu: arrow keys, Escape, focus returned to the ⋯ button; the table opens in a sheet with a focus trap.
- Legend chips are toggle buttons (
aria-pressed); the last visible series cannot be switched off.
Bonnes pratiques
- Write the insight from the data, in one line: the figure first, then the change (
100 jobs · +100 % vs last week). - Leave the chart without a title: the card hands it its own, which stays the chart's accessible name.
- Zoom the time axis on the period that has data with
autoRangerather than drawing empty days. - Keep the footer for the source and the freshness; never a second insight.
Composants liés
Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub