# App, chart card

- **[Sections](/blocks/)**
- **[Application](/blocks/app/)**
- **App, chart card**

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…

## Import

- **CLI**

  ```
  npx shadcn add @klarhimmel/app-dashboard-chart
  ```
- **Import**

  ```
  import Block from '@/components/klarhimmel/blocks/app-dashboard-chart';
  ```

Also called

- app/dashboard-chart

- **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…
- **Category**: Interface sections for signed-in products. New project? Set it up once: /get-started/installation.

## 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

- **[App, stat panel row](/blocks/app/dashboard-stats)**
- **[App, data table](/blocks/app/data-table)**
- **[App, filter bar](/blocks/app/data-filters)**

## Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import AppDashboardChart from '@/components/klarhimmel/blocks/app-dashboard-chart';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <AppDashboardChart props={{
          "eyebrow": "Name the topic",
          "title": "Name what the chart measures",
          "description": "Say what is measured, for whom and over what period.",
          "kind": "bar",
          "points": [
            {
              "label": "P1",
              "value": "31200"
            },
            {
              "label": "P2",
              "value": "34800"
            },
            {
              "label": "P3",
              "value": "29900"
            }
          ],
          "unit": "kr",
          "summary": "Say in one sentence how the value moved from the first point to the peak and where it ended.",
          "tableLabel": "See the data as a table",
          "scrollHint": "Say there is more to the side",
          "tableHead": {
            "label": "Period",
            "value": "Measure"
          },
          "state": "filled",
          "messages": {
            "loading": "Say it is loading",
            "empty": "Say there is nothing to show for these periods yet.",
            "error": "Say the chart did not load and to retry.",
            "retry": "Try again"
          }
        }} />
      </BlockSurface>
    </Theme>
  );
}
```

## 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.

- **eyebrow**: Text, up to 60 characters. Optional; empty is not rendered.
- **title**: Text, up to 120 characters.
- **description**: Text, up to 300 characters. Optional; empty is not rendered.
- **kind**: One of 'bar', 'line'.
- **points**: List of 3 to 12. Each item: label, value.
- **unit**: Text, up to 10 characters. Optional; empty is not rendered.
- **summary**: Text, up to 200 characters.
- **tableLabel**: Text, up to 40 characters.
- **scrollHint**: Text, up to 40 characters.
- **tableHead**: Fields: label, value.
- **state**: One of 'filled', 'empty', 'loading', 'error'.
- **messages**: Fields: loading, empty, error, retry.
- **headingLevel**: One of '1', '2'. Optional; empty is not rendered.

[Previous](/blocks/app/comments-thread)

[Next](/blocks/app/dashboard-stats)
