Line chart
Trace change across an ordered sequence and compare several trends without hiding gaps.
- Studio
- Field
- Studio
- 42
- Field
- 31
View data table 6 rows
| Data point | Studio | Field |
|---|---|---|
| Jan | 42 | 31 |
| Feb | 48 | 35 |
| Mar | No data | 39 |
| Apr | 57 | 44 |
| May | 64 | 49 |
| Jun | 69 | 55 |
Installation
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/line-chart.jsonThe registry includes the shared styles and dependencies. Import @/components/apple-ui/styles.css in your root layout once. For the package route, use the installation guide.
Usage
"use client";
import { LineChart } from "@eduardoul/apple-ui";
const data = [
{ label: "Jan", studio: 42, field: 31 },
{ label: "Feb", studio: 48, field: 35 },
{ label: "Mar", studio: null, field: 39 },
{ label: "Apr", studio: 57, field: 44 },
{ label: "May", studio: 64, field: 49 },
];
export function Example() {
return (
<LineChart
title="Monthly active projects"
description="Monthly project counts. Studio has no March observation. Synthetic example data."
data={data}
series={[
{ key: "studio", label: "Studio" },
{ key: "field", label: "Field" },
]}
valueFormatter={(value) => value.toLocaleString()}
/>
);
}Package imports use @eduardoul/apple-ui. Registry imports use @/components/apple-ui. Add "use client" to files that use state or event handlers.
API reference
| Property | Type | Default |
|---|---|---|
| data | ChartDatum[] | required |
| series | ChartSeries[] | required |
| labelKey | string | label |
| title | string | required |
| description | string | undefined |
| height | number | component default |
| loading | boolean | false |
| error | string | undefined |
| emptyMessage | string | No data to display. |
| showTable | boolean | true |
| compact | boolean | false |
| valueFormatter | (value: number) => string | localized number |
| className | string | undefined |
| style | React.CSSProperties | undefined |
Use className and style to customize the component. The package includes full TypeScript definitions for its supported element properties and refs.
Design guidance
- Use a line when the order of values matters, usually across time.
- Keep missing observations as gaps. A connected line can imply that a value was measured when it was not.
- Limit the number of series when their paths overlap. Direct labels or a short legend should make each line easy to identify.
Accessibility
Give the chart a descriptive title and explain its units. Select a data point to read its values, or open the data table for the full dataset. Labels and values accompany color, and the chart adapts to reduced motion and appearance preferences. Test long labels, touch input and keyboard navigation with your own data.
Library styles support reduced motion, reduced transparency, increased contrast and forced colors. Read the accessibility foundation for the checks your application still needs.