# Area chart

Compare nonnegative time series as stacked or overlaid areas with exact period inspection.

Access: pro. Category: Data. Kind: composite.

## When to use

- Use it when a page needs compare nonnegative time series as stacked or overlaid areas with exact period inspection.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose analytics-card instead when explore revenue, compare periods and inspect chart values is the actual interface need, rather than area chart.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Area chart

```sh
npx shadcn@latest add @tidal-pro/area-chart
```

Stylesheets: `components/ui/tidal.css`, `components/ui/area-chart.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/area-chart.css";
import{TidalAreaChart}from"./components/ui/area-chart";
export default()=><div className="tidal-scope"><TidalAreaChart data={[{id:"example",label:"Demo",values:{}}]} onSelectedChange={() => {}} selectedId={"example"} series={[{id:"example",label:"Demo"}]} title={"Demo"}/></div>;
```

## Structured props

- `TidalAreaChart.data: ReadonlyArray<TidalAreaDatum>`: Required data value accepted by this exported component.
- `TidalAreaChart.onSelectedChange: (id: string, event: ChangeEvent<HTMLInputElement> | PointerEvent<HTMLDivElement>) => void`: Callback invoked when the selected change interaction is proposed.
- `TidalAreaChart.selectedId: string`: Required selected id value accepted by this exported component.
- `TidalAreaChart.series: ReadonlyArray<TidalAreaSeries>`: Required series value accepted by this exported component.
- `TidalAreaChart.title: ReactNode`: Required title value accepted by this exported component.
- `TidalAreaChart.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalAreaChart.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalAreaChart.formatAxisValue?: ((value: number) => string) | undefined` (default (value) =>
        new Intl.NumberFormat("en-US", {
          notation: value >= 1e15 ? "scientific" : "compact",
          maximumFractionDigits: 1,
        }).format(value)): Optional format axis value value accepted by this exported component.
- `TidalAreaChart.formatValue?: ((value: number) => string) | undefined` (default (value) =>
        new Intl.NumberFormat("en-US", { maximumSignificantDigits: 21 }).format(
          value,
        )): Optional format value value accepted by this exported component.
- `TidalAreaChart.headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalAreaChart.labels?: Partial<{ inspect: string; series: string; total: string; missing: string; table: string; period: string; invalid: string; empty: string; plot: string; }> | undefined` (default {}): Optional labels value accepted by this exported component.
- `TidalAreaChart.mode?: "stacked" | "overlaid" | undefined` (default "stacked"): Optional mode value accepted by this exported component.
- `TidalAreaChart.plotProps?: Omit<Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "aria-hidden" | "children" | "dangerouslySetInnerHTML"> | undefined`: Optional plot props value accepted by this exported component.
- `TidalAreaChart.rangeProps?: NativeRange | undefined`: Optional range props value accepted by this exported component.
- `TidalAreaChart.rangeRef?: Ref<HTMLInputElement> | undefined`: Optional range ref value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/area-chart.tsx) | [Manifest](https://tidalui.com/examples/area-chart.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useState } from "react";

import { TidalAreaChart, type TidalAreaDatum } from "./components/ui/area-chart";

import "./components/ui/area-chart.css";



const tidalExampleStyles = ".tidal-scope .area-chart-demo {\n  width: 100%;\n  max-width: 760px;\n  min-width: 0;\n}\n.area-chart-demo > p {\n  font-size: 11px;\n  line-height: 1.6;\n  color: var(--t-muted);\n  margin: 14px 0 0;\n  overflow-wrap: anywhere;\n}\n.area-chart-mode {\n  display: flex;\n  justify-content: flex-end;\n  gap: 12px;\n  align-items: center;\n  flex-wrap: wrap;\n  margin-top: 14px;\n  font-size: 11px;\n  color: var(--t-muted);\n}\n.area-chart-mode select {\n  font-family: inherit;\n  color: var(--t-ink);\n  border: 1px solid var(--t-border);\n  background: var(--t-surface);\n  border-radius: 8px;\n  min-height: 44px;\n  max-width: 100%;\n  padding: 8px 32px 8px 10px;\n}\n.area-chart-mode select:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 2px;\n}\n@media (max-width: 480px) {\n  .area-chart-mode select {\n    font-size: 16px;\n  }\n}";

const data: TidalAreaDatum[] = [
  { id: "may", label: "May", values: { self: 1200, sales: 600 } },
  { id: "jun", label: "June", values: { self: 1450, sales: 700 } },
  { id: "jul", label: "July", values: { self: 1380, sales: 820 } },
  { id: "aug", label: "August", values: { self: 1820, sales: 940 } },
  { id: "sep", label: "September", values: { self: 2100, sales: 1000 } },
  { id: "oct", label: "October", values: { self: 2380, sales: 1150 } },
];

export function AreaChartDemo() {
  const [selected, setSelected] = useState("oct"),
    [mode, setMode] = useState<"stacked" | "overlaid">("stacked");
  return (
    <div className="area-chart-demo">
      <TidalAreaChart
        title="Monthly subscriptions"
        description="Self-serve and sales-assisted subscriptions across six sample months."
        data={data}
        series={[
          { id: "self", label: "Self-serve" },
          { id: "sales", label: "Sales-assisted" },
        ]}
        selectedId={selected}
        onSelectedChange={setSelected}
        mode={mode}
      />
      <label className="area-chart-mode">
        Chart layout
        <select
          value={mode}
          onChange={(e) => setMode(e.currentTarget.value as typeof mode)}
        >
          <option value="stacked">Stacked</option>
          <option value="overlaid">Overlaid</option>
        </select>
      </label>
      <p>
        Sample counts. Move over the plot or use the period control to inspect
        exact values.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <AreaChartDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Consumer-owned data and series require unique nonblank IDs and labels. One to six series and up to 1,000 ordered periods are supported. Values are finite nonnegative numbers or explicit null for missing values; missing keys, negative/nonfinite values, duplicate IDs, unknown selection and unrepresentable totals produce a configuration alert. Stacked mode gaps the whole period when any series is missing; overlaid mode gaps only the missing series. Single points and all-zero values remain visible and exact. Controlled selectedId/onSelectedChange supports mouse/pen plot inspection and a native range field for keyboard or touch selection; touch scrolling over the plot is preserved. Optional formatValue/formatAxisValue, title/description/h2-h6 heading, localized labels, disabled state, safe root attrs/ref, native range attrs/ref and plot pointer attrs are supported. The native range serializes a period index if a name is supplied. Native range onChange and plot pointer handlers run first and may prevent a proposal. A native data-table disclosure exposes every supplied value. No interpolation, estimation, analytics request, persistence or data fetching is bundled.
