Komponenten
Diagramme (Charts)
StabilVerläufe und Verteilungen als Flächen-, Balken-, Linien- und Ringdiagramm – mit Textalternative.
Ein Diagramm zeigt Zahlen als Form: die Bettenbelegung über mehrere Wochen, die Tickets pro Kategorie, den Verlauf eines Tages. Die Form macht eine Entwicklung schneller sichtbar als eine Spalte voller Werte. Genaue Zahlen stehen weiterhin als Text bereit.
Wann verwenden
- Für einen Verlauf über mehrere Zeitpunkte, etwa die Belegung pro Woche.
- Für den Vergleich mehrerer Kategorien, etwa Tickets pro Station.
- Wenn eine Entwicklung wichtiger ist als der einzelne Wert.
- Wenn die Aussage auch ohne Farbe lesbar bleibt – die Legende nennt jede Reihe beim Namen.
Wann nicht
- Für einen einzelnen Wert genügt eine Kennzahl; ein Diagramm mit einem Balken sagt nichts aus.
- Für genaue Einzelwerte, die verglichen oder kopiert werden, ist eine Tabelle die bessere Wahl.
- Bei mehr als vier bis fünf Reihen wird die Fläche unruhig. Fasse Reihen zusammen oder teile sie auf mehrere Diagramme.
- Für einen Anteil an einem Ganzen mit zwei Werten genügt ein Fortschritt.
Fläche: Belegung pro Woche
AreaChart betont die Fläche unter dem Verlauf. Mehrere categories werden
übereinandergelegt; die Reihenfolge bestimmt die Farbe aus den
--chart-*-Tokens. index benennt die Achse der Kategorien.
| woche | Station 1 | Station 2 | Station 3 |
|---|---|---|---|
| KW 40 | 82 % | 88 % | 74 % |
| KW 41 | 86 % | 90 % | 79 % |
| KW 42 | 91 % | 87 % | 83 % |
| KW 43 | 88 % | 93 % | 86 % |
import { AreaChart } from "@neodin-eu/ui";
const belegung = [
{ woche: "KW 40", "Station 1": 82, "Station 2": 88, "Station 3": 74 },
{ woche: "KW 41", "Station 1": 86, "Station 2": 90, "Station 3": 79 },
{ woche: "KW 42", "Station 1": 91, "Station 2": 87, "Station 3": 83 },
{ woche: "KW 43", "Station 1": 88, "Station 2": 93, "Station 3": 86 },
];
function Belegung() {
return (
<AreaChart
className="w-full max-w-2xl"
title="Bettenbelegung pro Woche"
data={belegung}
index="woche"
categories={["Station 1", "Station 2", "Station 3"]}
valueFormatter={(value) => `${value} %`}
/>
);
}Balken: Tickets pro Kategorie
BarChart eignet sich für Vergleiche zwischen Kategorien. Jede Kategorie
bekommt eine eigene Reihe; valueFormatter hängt eine Einheit an Achse,
Tooltip und Textalternative an.
| woche | Notaufnahme | Innere | Chirurgie |
|---|---|---|---|
| KW 44 | 18 | 11 | 7 |
| KW 45 | 15 | 13 | 9 |
| KW 46 | 21 | 10 | 6 |
| KW 47 | 17 | 12 | 8 |
import { BarChart } from "@neodin-eu/ui";
const tickets = [
{ woche: "KW 44", Notaufnahme: 18, Innere: 11, Chirurgie: 7 },
{ woche: "KW 45", Notaufnahme: 15, Innere: 13, Chirurgie: 9 },
{ woche: "KW 46", Notaufnahme: 21, Innere: 10, Chirurgie: 6 },
{ woche: "KW 47", Notaufnahme: 17, Innere: 12, Chirurgie: 8 },
];
function Tickets() {
return (
<BarChart
className="w-full max-w-2xl"
title="Tickets pro Kategorie"
data={tickets}
index="woche"
categories={["Notaufnahme", "Innere", "Chirurgie"]}
/>
);
}Linie: Verlauf über Tage
LineChart zeigt eine Entwicklung ohne Fläche. Zwei Reihen wie Eingang und
Erledigt lassen sich so direkt gegenüberstellen.
| tag | Eingang | Erledigt |
|---|---|---|
| Montag | 14 | 11 |
| Dienstag | 18 | 15 |
| Mittwoch | 12 | 14 |
| Donnerstag | 16 | 17 |
| Freitag | 9 | 12 |
import { LineChart } from "@neodin-eu/ui";
const verlauf = [
{ tag: "Montag", Eingang: 14, Erledigt: 11 },
{ tag: "Dienstag", Eingang: 18, Erledigt: 15 },
{ tag: "Mittwoch", Eingang: 12, Erledigt: 14 },
{ tag: "Donnerstag", Eingang: 16, Erledigt: 17 },
{ tag: "Freitag", Eingang: 9, Erledigt: 12 },
];
function Verlauf() {
return (
<LineChart
className="w-full max-w-2xl"
title="Tickets im Tagesverlauf"
data={verlauf}
index="tag"
categories={["Eingang", "Erledigt"]}
/>
);
}Ring: Verteilung
DonutChart zeigt Anteile eines Ganzen. index benennt das Segment, die
erste category trägt den Wert. Jedes Segment bekommt der Reihe nach eine
Farbe aus den --chart-*-Tokens.
| station | Tickets |
|---|---|
| Station 1 | 24 |
| Station 2 | 18 |
| Station 3 | 13 |
| Notaufnahme | 9 |
import { DonutChart } from "@neodin-eu/ui";
const verteilung = [
{ station: "Station 1", Tickets: 24 },
{ station: "Station 2", Tickets: 18 },
{ station: "Station 3", Tickets: 13 },
{ station: "Notaufnahme", Tickets: 9 },
];
function Verteilung() {
return (
<DonutChart
className="w-full max-w-md"
title="Tickets pro Station im November"
data={verteilung}
index="station"
categories={["Tickets"]}
/>
);
}Gemeinsamer Rahmen
Alle Diagramme bauen auf ChartContainer auf: Er setzt die feste Höhe,
rendert die Legende und den Tooltip und erzeugt die Textalternative. Wer ein
eigenes Diagramm aus recharts zusammensetzt, legt es in ChartContainer und
erhält dieselben Eigenschaften.
Barrierefreiheit
- Jedes Diagramm ist eine Figur mit zugänglichem Namen:
role="figure"undaria-labeltragen dentitle. Im Komponententest wird die Figur übergetByRole("figure", { name: "Umsatz" })gefunden. - Unter dem Diagramm liegt eine visuell ausgeblendete Datentabelle mit
Beschriftung (
caption) und Kopfzellen. Sie enthält dieselben Werte wie die Zeichnung; im Test wird geprüft, dass die Tabelle die Kategorien und Werte enthält undsr-onlygesetzt ist. - Die Zahlen werden mit der Sprache der Anwendung formatiert (
de-ATergibt1.234). Ein eigenesvalueFormatterersetzt die Formatierung überall – Achse, Tooltip und Textalternative. Beides ist im Komponententest abgesichert. - Die Reihen zeichnen sich nicht allein durch Farbe aus: Die Legende nennt jeden Namen, der Tooltip wiederholt Name und Wert als Text.
- Die Diagramme sind im Komponententest in hell und dunkel frei von axe-Verstößen.
Props
| Prop | Typ | Standard | Pflicht | Beschreibung |
|---|---|---|---|---|
| categories | string[] | – | Ja | Keys of the value series, coloured in `--chart-1` … `--chart-5` order. |
| children | ReactElement<unknown, string | JSXElementConstructor<any>> | – | Ja | The recharts chart element rendered inside the responsive container. |
| className | string | – | Nein | – |
| data | ChartDatum[] | – | Ja | Rows of the data set; keys are looked up by `index` and `categories`. |
| height | number | 288 | Nein | Height of the chart canvas in pixels. |
| index | string | – | Ja | Key of the category axis (e.g. the month). |
| title | string | – | Ja | Accessible name of the figure and caption of the fallback data table. |
| valueFormatter | ((value: number) => string) | – | Nein | Formats numbers in axes, tooltip and the fallback table; defaults to the provider locale. |
| Prop | Typ | Standard | Pflicht | Beschreibung |
|---|---|---|---|---|
| categories | string[] | – | Ja | Keys of the value series, coloured in `--chart-1` … `--chart-5` order. |
| className | string | – | Nein | – |
| data | ChartDatum[] | – | Ja | Rows of the data set; keys are looked up by `index` and `categories`. |
| height | number | – | Nein | Height of the chart canvas in pixels. |
| index | string | – | Ja | Key of the category axis (e.g. the month). |
| title | string | – | Ja | Accessible name of the figure and caption of the fallback data table. |
| valueFormatter | ((value: number) => string) | – | Nein | Formats numbers in axes, tooltip and the fallback table; defaults to the provider locale. |
| Prop | Typ | Standard | Pflicht | Beschreibung |
|---|---|---|---|---|
| categories | string[] | – | Ja | Keys of the value series, coloured in `--chart-1` … `--chart-5` order. |
| className | string | – | Nein | – |
| data | ChartDatum[] | – | Ja | Rows of the data set; keys are looked up by `index` and `categories`. |
| height | number | – | Nein | Height of the chart canvas in pixels. |
| index | string | – | Ja | Key of the category axis (e.g. the month). |
| title | string | – | Ja | Accessible name of the figure and caption of the fallback data table. |
| valueFormatter | ((value: number) => string) | – | Nein | Formats numbers in axes, tooltip and the fallback table; defaults to the provider locale. |
| Prop | Typ | Standard | Pflicht | Beschreibung |
|---|---|---|---|---|
| categories | string[] | – | Ja | Keys of the value series, coloured in `--chart-1` … `--chart-5` order. |
| className | string | – | Nein | – |
| data | ChartDatum[] | – | Ja | Rows of the data set; keys are looked up by `index` and `categories`. |
| height | number | – | Nein | Height of the chart canvas in pixels. |
| index | string | – | Ja | Key of the category axis (e.g. the month). |
| title | string | – | Ja | Accessible name of the figure and caption of the fallback data table. |
| valueFormatter | ((value: number) => string) | – | Nein | Formats numbers in axes, tooltip and the fallback table; defaults to the provider locale. |
| Prop | Typ | Standard | Pflicht | Beschreibung |
|---|---|---|---|---|
| categories | string[] | – | Ja | Keys of the value series, coloured in `--chart-1` … `--chart-5` order. |
| className | string | – | Nein | – |
| data | ChartDatum[] | – | Ja | Rows of the data set; keys are looked up by `index` and `categories`. |
| height | number | – | Nein | Height of the chart canvas in pixels. |
| index | string | – | Ja | Key of the category axis (e.g. the month). |
| title | string | – | Ja | Accessible name of the figure and caption of the fallback data table. |
| valueFormatter | ((value: number) => string) | – | Nein | Formats numbers in axes, tooltip and the fallback table; defaults to the provider locale. |
Legende und Tooltip lassen sich auch einzeln einsetzen:
ChartLegend hat keine eigenen Props – alle Attribute des zugrunde liegenden Elements bleiben möglich.
| Prop | Typ | Standard | Pflicht | Beschreibung |
|---|---|---|---|---|
| valueFormatter | ((value: number) => string) | – | Nein | Formats numbers in axes, tooltip and the fallback table; defaults to the provider locale. |