# Line chart

A controlled responsive line chart with exact pointer and native-button inspection plus an HTML data table fallback.

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

## When to use

- Use it when a page needs a controlled responsive line chart with exact pointer and native-button inspection plus an html data table fallback.
- 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 line 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 Line chart

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

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

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/line-chart.css";
import{TidalLineChart}from"./components/ui/line-chart";
export default()=><div className="tidal-scope"><TidalLineChart points={[{id:"example",label:"Demo",value:1,displayValue:"value"}]} title={"Demo"}/></div>;
```

## Structured props

- `TidalLineChart.points: ReadonlyArray<TidalLineChartPoint>`: Required points value accepted by this exported component.
- `TidalLineChart.title: ReactNode`: Required title value accepted by this exported component.
- `TidalLineChart.chartLabel?: string | undefined` (default "Line chart"): Optional chart label value accepted by this exported component.
- `TidalLineChart.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalLineChart.emptyMessage?: ReactNode` (default "No finite data points are available."): Optional empty message value accepted by this exported component.
- `TidalLineChart.eyebrow?: ReactNode` (default "Line chart"): Optional eyebrow value accepted by this exported component.
- `TidalLineChart.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalLineChart.formatAxisValue?: ((value: number) => string) | undefined` (default (value) => String(Math.round(value))): Optional format axis value value accepted by this exported component.
- `TidalLineChart.headingLevel?: "h2" | "h3" | "h4" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalLineChart.motionKey?: string | number | undefined`: Optional motion key value accepted by this exported component.
- `TidalLineChart.nextButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> | undefined`: Optional next button props value accepted by this exported component.
- `TidalLineChart.nextButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional next button ref value accepted by this exported component.
- `TidalLineChart.nextLabel?: string | undefined` (default "Inspect next point"): Optional next label value accepted by this exported component.
- `TidalLineChart.onSelectedChange?: ((point: TidalLineChartPoint, source: "pointer" | "previous" | "next") => void) | undefined`: Callback invoked when the selected change interaction is proposed.
- `TidalLineChart.previousButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> | undefined`: Optional previous button props value accepted by this exported component.
- `TidalLineChart.previousButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional previous button ref value accepted by this exported component.
- `TidalLineChart.previousLabel?: string | undefined` (default "Inspect previous point"): Optional previous label value accepted by this exported component.
- `TidalLineChart.selectedId?: string | undefined`: Optional selected id value accepted by this exported component.
- `TidalLineChart.tableLabel?: ReactNode` (default "View data table"): Optional table label value accepted by this exported component.
- `TidalLineChart.xAxisLabel?: string | undefined` (default "Period"): Optional x axis label value accepted by this exported component.
- `TidalLineChart.yAxisLabel?: string | undefined` (default "Value"): Optional y axis label value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/line-chart.tsx) | [Manifest](https://tidalui.com/examples/line-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 { useMemo, useState } from "react";

import { TidalLineChart, type TidalLineChartPoint } from "./components/ui/line-chart";

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



const tidalExampleStyles = ".tidal-scope .line-chart-demo {\n  display: grid;\n  width: min(100%, 880px);\n  min-width: 0;\n  gap: 11px;\n  margin-inline: auto;\n}\n\n.tidal-scope .line-chart-demo-controls {\n  display: grid;\n  width: min(100%, 260px);\n  grid-template-columns: repeat(2, minmax(0, 1fr));\n  gap: 5px;\n  padding: 5px;\n  background: var(--t-subtle);\n  border: 1px solid var(--t-border);\n  border-radius: 14px;\n}\n\n.tidal-scope .line-chart-demo-controls button {\n  min-width: 44px;\n  min-height: 44px;\n  padding: 8px 12px;\n  color: var(--t-muted);\n  background: transparent;\n  border: 1px solid transparent;\n  border-radius: var(--t-radius-control);\n  font: inherit;\n  font-size: 11px;\n  font-weight: 700;\n  cursor: pointer;\n  transition:\n    color 140ms,\n    background 180ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .line-chart-demo-controls button[aria-pressed=\"true\"] {\n  color: var(--t-surface);\n  background: var(--t-ink);\n}\n\n.tidal-scope .line-chart-demo-controls button:active {\n  transform: scale(0.97);\n}\n\n.tidal-scope .line-chart-demo-controls button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n.tidal-scope .line-chart-demo-footer {\n  display: flex;\n  justify-content: space-between;\n  gap: 12px;\n}\n\n.tidal-scope .line-chart-demo-status {\n  min-height: 1.4em;\n  margin: 0 5px;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.4;\n  text-align: center;\n}\n\n@container tidal-line-chart (max-width: 480px) {\n  .tidal-scope .line-chart-demo-footer {\n    flex-direction: column;\n    gap: 3px;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .line-chart-demo-controls button {\n    transition: none;\n  }\n\n  .tidal-scope .line-chart-demo-controls button:active {\n    transform: none;\n  }\n}";

type PeriodId = "week" | "month";

const DATA: Record<PeriodId, readonly TidalLineChartPoint[]> = {
  week: [
    {
      id: "oct-08",
      label: "Oct 8",
      value: 12,
      displayValue: "12 tasks",
      description: "Fictional completed-task count",
    },
    {
      id: "oct-09",
      label: "Oct 9",
      value: 18,
      displayValue: "18 tasks",
      description: "Fictional completed-task count",
    },
    {
      id: "oct-10",
      label: "Oct 10",
      value: 14,
      displayValue: "14 tasks",
      description: "Fictional completed-task count",
    },
    {
      id: "oct-11",
      label: "Oct 11",
      value: 26,
      displayValue: "26 tasks",
      description: "Fictional completed-task count",
    },
    {
      id: "oct-12",
      label: "Oct 12",
      value: 21,
      displayValue: "21 tasks",
      description: "Fictional completed-task count",
    },
    {
      id: "oct-13",
      label: "Oct 13",
      value: 31,
      displayValue: "31 tasks",
      description: "Fictional completed-task count",
    },
    {
      id: "oct-14",
      label: "Oct 14",
      value: 28,
      displayValue: "28 tasks",
      description: "Fictional completed-task count",
    },
  ],
  month: [
    { id: "sep-15", label: "Sep 15", value: 9, displayValue: "9 tasks" },
    { id: "sep-18", label: "Sep 18", value: 15, displayValue: "15 tasks" },
    { id: "sep-21", label: "Sep 21", value: 13, displayValue: "13 tasks" },
    { id: "sep-24", label: "Sep 24", value: 22, displayValue: "22 tasks" },
    { id: "sep-27", label: "Sep 27", value: 19, displayValue: "19 tasks" },
    { id: "sep-30", label: "Sep 30", value: 25, displayValue: "25 tasks" },
    { id: "oct-03", label: "Oct 3", value: 23, displayValue: "23 tasks" },
    { id: "oct-06", label: "Oct 6", value: 30, displayValue: "30 tasks" },
    { id: "oct-10", label: "Oct 10", value: 27, displayValue: "27 tasks" },
    { id: "oct-14", label: "Oct 14", value: 34, displayValue: "34 tasks" },
  ],
};

export function LineChartDemo() {
  const [period, setPeriod] = useState<PeriodId>("week");
  const [selectedId, setSelectedId] = useState("oct-14");
  const [message, setMessage] = useState(
    "Oct 14 selected. The chart uses fictional local task counts.",
  );
  const points = DATA[period];
  const total = useMemo(
    () => points.reduce((sum, point) => sum + point.value, 0),
    [points],
  );

  function changePeriod(nextPeriod: PeriodId) {
    const next = DATA[nextPeriod];
    const nextSelected = next.at(-1)!;
    setPeriod(nextPeriod);
    setSelectedId(nextSelected.id);
    setMessage(
      `${nextPeriod === "week" ? "Seven-day" : "Thirty-day"} sample selected.`,
    );
  }

  return (
    <section className="line-chart-demo" aria-label="Line chart preview">
      <div
        className="line-chart-demo-controls"
        role="group"
        aria-label="Choose sample period"
      >
        <button
          type="button"
          aria-pressed={period === "week"}
          onClick={() => changePeriod("week")}
        >
          7 days
        </button>
        <button
          type="button"
          aria-pressed={period === "month"}
          onClick={() => changePeriod("month")}
        >
          30 days
        </button>
      </div>

      <TidalLineChart
        title="Completed tasks"
        eyebrow={null}
        description="Inspect exact fictional task counts by pointer, touch, or the native previous and next controls."
        points={points}
        selectedId={selectedId}
        onSelectedChange={(point) => {
          setSelectedId(point.id);
          setMessage(`${point.label}: ${point.displayValue}.`);
        }}
        chartLabel={`${period === "week" ? "Seven-day" : "Thirty-day"} fictional completed tasks`}
        xAxisLabel="Sample date"
        yAxisLabel="Tasks"
        footer={
          <div className="line-chart-demo-footer">
            <span>{total} fictional tasks across the selected sample.</span>
            <span>No live workspace, request, or analytics source.</span>
          </div>
        }
      />
      <p className="line-chart-demo-status" role="status" aria-live="polite">
        {message}
      </p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <LineChartDemo />
    </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."}

title and consumer-owned points are required. Each point has a stable id, full string label, finite numeric value, exact displayValue and optional ReactNode description. Nonfinite runtime values are excluded from geometry and exposed as Unavailable in the HTML table. Optional controlled selectedId and onSelectedChange provide exact pointer/touch/previous/next inspection without owning application state. Optional headingLevel, eyebrow, description, chart/axis labels, formatAxisValue, previous/next labels, native button props/refs, tableLabel, emptyMessage, footer, motionKey and native figure attributes/ref are consumer-owned. Native button handlers run before higher inspection and preventDefault suppresses it. The chart performs no request, analytics, storage, aggregation, live-data or formatting side effect.
