Aliases
chart, graph
components / datachart
Pure-SVG chart surface for line, bar, and area series with optional legend and lightweight point tooltips.
Playground
Start here. Switch systems, interact with the shipped component, and let the rest of the page answer the why and how after the behavior clicks.
Cobalt
The crisp default DK action system: bright primary, roomy spacing, and a direct editorial rhythm.
Compare work entering the pipeline with work actually shipping.
Overview
This section explains the intent of the component before the implementation details.
Aliases
chart, graph
Explore the math
Contrast and Distinctness,Layout and Composition,Proof System
Decision guide
Use these notes to decide quickly whether this is the right DK component for the job.
Decision guide
Do
Do not
Usage
Prefer these situations when choosing this component.
Usage
These patterns are better served by a different component or a simpler surface.
Anti-patterns
Migration notes
Anatomy
The anatomy explains which pieces matter to the recipe and accessibility model.
chart canvas shell
surfaceOwns the chart background, border, and internal spacing.
category labels and grid
axisSupports interpretation of the plotted values.
series explanation
legendMaps color to each series label.
point detail
tooltipShows focused or hovered value details.
API
The docs contract distinguishes props, DOM events, and slots so integration behavior is explicit.
Props
| Name | Type | Default | Description |
|---|---|---|---|
type | 'line' | 'bar' | 'area' | — | Chart rendering mode. |
series | Array<{ id: string; label: string; values: number[]; tone?: "brand" | "success" | "warning" | "danger" | "neutral" }> | — | Series values to plot. |
categories | string[] | — | Category labels aligned with each value index. |
title | string | — | Chart title. |
description | string | — | Optional supporting description. |
height | number | 280 | SVG height in pixels. |
showLegend | boolean | true | Shows the series legend. |
showGrid | boolean | true | Shows horizontal grid lines. |
showTooltip | boolean | true | Shows hover/focus tooltip details. |
valueFormat | (value: number) => string | — | Optional formatter for displayed values. |
emptyTitle | string | — | Title shown when no chart data is available. |
emptyDescription | string | — | Supporting empty-state guidance. |
theme | ThemeContract | — | Overrides the compiled DK theme used to resolve tokens and recipes for this component. |
Slots
| Name | Description |
|---|---|
default | DataChart is prop-driven in v1 and does not expose custom series or tooltip slots. |
Recipes
These notes summarize the intended recipe surface rather than exposing raw implementation detail first.
Variants
Sizes
States
Accessibility
This is the behavior the component promises to assistive tech and keyboard users today.
Semantics
Keyboard
Screen readers
Checklist
Implementation
This section shows the representative compiled slot variables that the runtime consumes for the selected design system.
Implementation notes
Implementation checklist
Examples
Each example is intentionally practical, grouped by starter, common pattern, and edge-case coverage.
Starter
1 example
starter
Starter: line trendA simple trend chart for one or two comparable series.
Copy snippet
<DataChart type="line" title="Revenue" categories={['Jan', 'Feb', 'Mar']} series={[{ id: 'mrr', label: 'MRR', values: [12, 18, 24] }]} />Common patterns
1 example
common
Common: comparative bar chartBar mode works well for side-by-side category comparisons.
Copy snippet
<DataChart type="bar" title="Activation" categories={['Week 1', 'Week 2', 'Week 3']} series={activationSeries} />Edge cases
1 example
edge
Edge: filled trend with hidden legendArea mode can read well for one primary metric and restrained dashboard treatment.
Copy snippet
<DataChart type="area" title="Active users" showLegend={false} categories={['Mon', 'Tue', 'Wed']} series={activeUserSeries} />Verification
Proofs stay visible in the docs so the system shows what it can guarantee, not just what it can render.
type=line
type=bar
type=area