Chart card


Install
npx shadcn add @klarhimmel/app-dashboard-chartDetailsAbout, usage, props and more
A chart card for a dashboard: a bar or line chart drawn as plain SVG from a short list of readings, a sentence that says what it shows, and a value axis, negative…
States
chart card in 6 forms: filled, empty, loading, error, line chart, negative readings.
state: filled
Name the topic
Name what the chart measures
Say what is measured, for whom and over what period.
Say in one sentence how the value moved from the first point to the peak and where it ended. See the data as a table
Period Measure P1 31200kr P2 34800kr P3 29900kr P4 38500kr P5 41200kr P6 44800kr P7 47100kr P8 43600kr Say there is more to the side
Say it is loading
Say there is nothing to show for these periods yet.
Say the chart did not load and to retry.state: empty
Name the topic
Name what the chart measures
Say what is measured, for whom and over what period.
Say in one sentence how the value moved from the first point to the peak and where it ended. See the data as a table
Period Measure P1 31200kr P2 34800kr P3 29900kr P4 38500kr P5 41200kr P6 44800kr P7 47100kr P8 43600kr Say there is more to the side
Say it is loading
Say there is nothing to show for these periods yet.
Say the chart did not load and to retry.state: loading
Name the topic
Name what the chart measures
Say what is measured, for whom and over what period.
Say in one sentence how the value moved from the first point to the peak and where it ended. See the data as a table
Period Measure P1 31200kr P2 34800kr P3 29900kr P4 38500kr P5 41200kr P6 44800kr P7 47100kr P8 43600kr Say there is more to the side
Say it is loading
Say there is nothing to show for these periods yet.
Say the chart did not load and to retry.state: error
Name the topic
Name what the chart measures
Say what is measured, for whom and over what period.
Say in one sentence how the value moved from the first point to the peak and where it ended. See the data as a table
Period Measure P1 31200kr P2 34800kr P3 29900kr P4 38500kr P5 41200kr P6 44800kr P7 47100kr P8 43600kr Say there is more to the side
Say it is loading
Say there is nothing to show for these periods yet.
Say the chart did not load and to retry.line chart
Name the topic
Name what the chart measures
Say what is measured, for whom and over what period.
Say in one sentence how the value moved from the first point to the peak and where it ended. See the data as a table
Period Measure P1 31200kr P2 34800kr P3 29900kr P4 38500kr P5 41200kr P6 44800kr P7 47100kr P8 43600kr Say there is more to the side
Say it is loading
Say there is nothing to show for these periods yet.
Say the chart did not load and to retry.negative readings
Name the topic
Name what the chart measures
Say what is measured, for whom and over what period.
Say in one sentence how the value moved from the first point to the peak and where it ended. See the data as a table
Period Measure Q1 4 000kr Q2 -2 500kr Q3 1 500kr Q4 -500kr Say there is more to the side
Say it is loading
Say there is nothing to show for these periods yet.
Say the chart did not load and to retry.
Notes
When to use it
A card with a bar or line chart of one short series and a table behind a disclosure. For headline figures without a trend use app-dashboard-stats; for many rows of data use app-data-table.
Writing for it
- Give 3 to 12 points, with labels of 12 characters or less such as Jan, and values written as text like 4 200 or -5 000. A value with no number is drawn as a gap.
- summary (200) is the sentence under the chart and also its description for screen readers, so state the finding, like which month was highest.
- unit (10) shows after each value in the table only, not on the chart axis, so put the unit in the title or summary too.
Watch out for
Labels past 12 characters are cut by the schema, and with 12 points they sit tightly on the axis. In the empty state messages.empty is required, while loading and error show no chart at all, only the message.
Pairs well with
Usage
The block in a page, with its default content (long lists shortened). Every prop is in the table below.
Props
The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.
| Prop | Type | Default | Description |
|---|---|---|---|
eyebrow | string | 'Name the topic' | Text, up to 60 characters. Optional; empty is not rendered. |
title | string | 'Name what the chart measures' | Text, up to 120 characters. |
description | string | 'Say what is measured, for whom and …' | Text, up to 300 characters. Optional; empty is not rendered. |
kind | 'bar' | 'line' | 'bar' | One of 'bar', 'line'. |
points | { label, value }[] | 8 items | List of 3 to 12. Each item: label, value. |
unit | string | 'kr' | Text, up to 10 characters. Optional; empty is not rendered. |
summary | string | 'Say in one sentence how the value m…' | Text, up to 200 characters. |
tableLabel | string | 'See the data as a table' | Text, up to 40 characters. |
scrollHint | string | 'Say there is more to the side' | Text, up to 40 characters. |
tableHead | { label, value } | {…} | Fields: label, value. |
state | 'filled' | 'empty' | 'loading' | 'error' | 'filled' | One of 'filled', 'empty', 'loading', 'error'. |
messages | { loading, empty, error, retry } | {…} | Fields: loading, empty, error, retry. |
headingLevel | '1' | '2' | - | One of '1', '2'. Optional; empty is not rendered. |
Install
Installs
- Banner
- Button
- EmptyState
- Skeleton
- About
- A chart card for a dashboard: a bar or line chart drawn as plain SVG from a short list of readings, a sentence that says what it shows, and a value axis, negative values below a zero line, and a data table behind a disclosure so nobody…
- States
- Bar or line from a list of readings, drawn as SVG. Filled, empty, loading and error. The data is also a table behind a disclosure. New project? Set it up once: /get-started/installation.