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.
Web only — React, from @krizaka/charts/card. Beta: its API may still change in a minor version.
Why it is here. The one frame of every chart of Orazaka's dashboard and usage pages (#253).
When to use
- 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.
When not to use
Installation
Install
npm install @krizaka/chartsImport
import { ChartCard } from "@krizaka/charts/card";Examples
Jobs per day
Stacked bars by outcome, an insight, a footer and the actions menu.
Jobs per day
195 jobs · +24 % vs the week before
Bar chart, 2 × 8 (Oct 3 – Oct 10). Completed: from 12 to 41, lowest 9 (Oct 5), highest 41 (Oct 10), up 242%. Failed: from 1 to 2, lowest 0 (Oct 4), highest 3 (Oct 7), up 100%.
| Day | Completed | Failed |
|---|---|---|
| Oct 3 | 12 | 1 |
| Oct 4 | 18 | 0 |
| Oct 5 | 9 | 2 |
| Oct 6 | 22 | 1 |
| Oct 7 | 31 | 3 |
| Oct 8 | 27 | 0 |
| Oct 9 | 35 | 1 |
| Oct 10 | 41 | 2 |
Read from your own jobs — nothing estimated.
What you made
A donut whose legend chips carry values and filter the ring.
What you made
195 jobs, most of them images
Jobs by kind, last 7 days.
Donut chart, 4. Images 96 (49%), Video 41 (21%), Audio 33 (17%), Text 25 (13%). Total 195.
| Kind | Jobs | % |
|---|---|---|
| Images | 96 | 49% |
| Video | 41 | 21% |
| Audio | 33 | 17% |
| Text | 25 | 13% |
| Total | 195 | 100% |
Sparse and empty
The time axis zoomed on the active period, and a calm empty state.
Jobs per day
100 jobs on Sep 28
Bar chart, 7 (Sep 22 – Sep 28). Jobs: from 0 to 100, lowest 0 (Sep 22), highest 100 (Sep 28).
| Category | Jobs |
|---|---|
| Sep 22 | 0 |
| Sep 23 | 0 |
| Sep 24 | 0 |
| Sep 25 | 0 |
| Sep 26 | 0 |
| Sep 27 | 0 |
| Sep 28 | 100 |
Failed jobs
Nothing failed yet
No data for this period yet.
Before and after
The same chart bare, then in a ChartCard.
Before
Jobs per day
Bar chart, 7 (Mon – Sun). Jobs: from 12 to 35, lowest 9 (Wed), highest 35 (Sun), up 192%.
| Category | Jobs |
|---|---|
| Mon | 12 |
| Tue | 18 |
| Wed | 9 |
| Thu | 22 |
| Fri | 31 |
| Sat | 27 |
| Sun | 35 |
After
Jobs per day
154 jobs · busiest on Sunday
Bar chart, 7 (Mon – Sun). Jobs: from 12 to 35, lowest 9 (Wed), highest 35 (Sun), up 192%.
| Category | Jobs |
|---|---|
| Mon | 12 |
| Tue | 18 |
| Wed | 9 |
| Thu | 22 |
| Fri | 31 |
| Sat | 27 |
| Sun | 35 |
Source: your own jobs.
Props
The frame of a chart: title, insight, actions, chart, footer — used everywhere a chart is shown.
| Prop | Type | Default | Description |
|---|---|---|---|
childrenrequired | ReactNode | — | The chart (LineChart, BarChart, DonutChart…), without its own title. |
titlerequired | 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. |
Accessibility
- 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.
Best practices
- 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.
Related components
Generated from the code of @krizaka/ui 3.19.0: its meta.ts, its examples and its types.Edit this documentation on GitHub