SVG-Diagramm ohne Abhängigkeiten (Fläche, Balken, Linie, Sparkline): pixelgenaue Darstellung, gerundete Skala, animiertes Einzeichnen beim Erscheinen, Fadenkreuz und Tooltip bei Hover und per Tastatur sowie eine Datentabelle für Screenreader.
Kategorie
Datenanzeige
Typ
Web Component (<mv-chart>)
Status
stabil
Keywords
chart, graph, area, bar, line, sparkline, dataviz, dashboard
When to use
A dashboard needs a simple area, bar or line chart with tooltips and no charting dependency
KPI tiles need tiny sparklines with no axes to show a trend next to a figure
Values must be formatted as currency, percent or compact numbers and stay accessible via a data table
Avoid when
Only a single headline number with a trend is needed → use Number Ticker instead
The data needs scatter, pie, stacked series, dual axes or zoom; only area, bar, line and sparkline are drawn
Exact values must be read and compared across many rows → use Table instead
Installation
node scripts/add.mjs chart --out ./src/marvelous
KI-Agent mit dem MCP-Server von Marvelous UI: install_components({ slugs: ["chart"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).
{ labels: string[], series: [{ name, values: number[], color? }] }. Also via the data property or a <script type="application/json"> child.
height
number (px)
240 (44 as sparkline)
Height of the plot area.
label
string
Accessible name of the chart and caption of the data table.
format
decimal | currency | percent
decimal
Intl format of the values (axis, tooltip, table).
currency
ISO 4217
USD
Currency for format=currency.
compact
boolean
Compact notation everywhere (12.4K). The axis switches to compact above 10,000.
locale
BCP 47
en-US
Formatting locale. The value auto follows the page language (nearest lang); without the attribute, en-US unless the app registered the page language with setStrings() (core/i18n.js).
curve
smooth | linear
smooth
Monotone interpolation (no overshoot) or straight segments.
sparkline
boolean
Mini chart with no axes or interaction (KPI tiles).
legend
true | false
auto (≥ 2 series)
Forces or hides the legend.
animate
view | none
view
Animated draw-in the first time it appears on screen.
Properties
Name
Typ
Beschreibung
data
object
Read/write; writing redraws instantly. Can be set before the element is defined.
strings
object
Override any default text: roledescription, caption (table caption without a label), series ({n}, unnamed series), missing (table and tooltip placeholder), noValue, point ({label}, {values}) and value ({series}, {value}) for the announcement. Numbers and lists follow the locale attribute (Intl). Can be set before the element is defined.
Methods
Name
Beschreibung
render()
Redraws (called automatically on resize).
Events
Name
Beschreibung
mv-hover
Active point changed. detail: { index, label }.
CSS classes
Name
Beschreibung
mv-chart-legend / -plot / -tooltip
Generated, stylable parts.
CSS variables
Name
Beschreibung
--mv-chart-1 … --mv-chart-5
Categorical palette, in a fixed order (1 = accent).
--mv-chart-grid
Grid line color.
--mv-chart-surface
Color of the ring around points (= card background).
Accessibility
role=group + aria-roledescription “chart” and aria-label; focusable: ← → Home End step through the points and the value is announced (aria-live). A visually hidden data table lists every value. The SVG is aria-hidden. Color is never the only cue: a legend appears for ≥ 2 series. Reduced motion: no draw-in animation. Forced colors: series are told apart by dash pattern (lines) or fill (bars), in the legend and the tooltip too, and focus gets a system outline.