Area chart
Emphasize the size of a trend while preserving its movement across an ordered sequence.
- Focused work
- Routine work
- Focused work
- 3.8 h
- Routine work
- 2.1 h
View data table 6 rows
| Data point | Focused work | Routine work |
|---|---|---|
| Mon | 3.8 h | 2.1 h |
| Tue | 4.6 h | 2.4 h |
| Wed | 5.1 h | 2.7 h |
| Thu | 4.4 h | 2.6 h |
| Fri | 5.7 h | 3.2 h |
| Sat | 3.1 h | 1.8 h |
Installation
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/area-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 { AreaChart } from "@eduardoul/apple-ui";
const data = [
{ label: "Mon", focused: 3.8, routine: 2.1 },
{ label: "Tue", focused: 4.6, routine: 2.4 },
{ label: "Wed", focused: 5.1, routine: 2.7 },
{ label: "Thu", focused: 4.4, routine: 2.6 },
{ label: "Fri", focused: 5.7, routine: 3.2 },
];
export function Example() {
return (
<AreaChart
title="Hours by work mode"
description="Synthetic daily hours"
data={data}
series={[
{ key: "focused", label: "Focused work" },
{ key: "routine", label: "Routine work" },
]}
valueFormatter={(value) => value.toFixed(1) + " h"}
/>
);
}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 one or two series when magnitude matters as much as direction.
- Start the vertical scale at zero when readers need to compare the filled area itself.
- Prefer a line chart when overlapping fills obscure the data or when precise comparison matters more than volume.
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.