Skip to content
GeneralGenerated from the public API

LineChart

Compare series and read the change behind them, with the axes, legend and tooltip already wired.

@luc/ui/charts

What it shows

Track ordered observations and compare one or more numeric series through time or another continuous x value.

Live preview

Eight weekly closes and a supplied trend line; both series are the caller's numbers.

<LineChart
  data={[
    { date: "2026-08-17", close: 94.2, trend: 94.6 },
    { date: "2026-08-24", close: 95.1, trend: 94.8 },
    { date: "2026-08-31", close: 96.4, trend: 95.1 },
    { date: "2026-09-07", close: 95.8, trend: 95.4 },
    { date: "2026-09-14", close: 97.1, trend: 95.8 },
    { date: "2026-09-21", close: 98.6, trend: 96.3 },
    { date: "2026-09-28", close: 97.9, trend: 96.7 },
    { date: "2026-10-05", close: 99.4, trend: 97.2 },
  ]}
  xKey="date"
  axes={[{ id: "primary", position: "left", format: { kind: "number", decimals: 1 } }]}
  series={[
    {
      key: "close",
      label: "Close",
      type: "line",
      tone: "accent",
      lineWidth: 2,
      axis: "primary",
    },
    {
      key: "trend",
      label: "Trend",
      type: "line",
      tone: "neutral",
      lineType: "dashed",
      symbol: false,
    },
  ]}
  interaction={{ zoom: "none" }}
  height={320}
  ariaLabel="Weekly closes"
/>

Controls

Presets

Title

Also the chart's accessible name when no `ariaLabel` is given.

Height

260px

Legend

The legend is also the series switch; it needs two or more comparable series.

Visible series

Start with a series hidden rather than removing it from the data.

State

Loading, empty and error are drawn by the chart chrome, not by your page.

Accessible name

Leave it empty and the chart names itself from the title and the family.

Advanced

Animation

Tooltip

`axis` reads the whole column; `item` reads one mark.

A fixed twelve-session fixture: eight weekly closes and a fitted trend line.

Code
import { LineChart } from "@luc/ui/charts";

const rows = [
  { date: "2026-09-21", close: 96.4, trend: 96 },
  { date: "2026-09-22", close: 96.9, trend: 96.2 },
  { date: "2026-09-23", close: 96.2, trend: 96.1 },
  { date: "2026-09-24", close: 95.5, trend: 95.9 },
  { date: "2026-09-25", close: 96.1, trend: 96 },
  { date: "2026-09-28", close: 97.3, trend: 96.3 },
  { date: "2026-09-29", close: 98, trend: 96.7 },
  { date: "2026-09-30", close: 97.4, trend: 96.9 },
  { date: "2026-10-01", close: 96.8, trend: 96.9 },
  { date: "2026-10-02", close: 97.9, trend: 97.1 },
  { date: "2026-10-05", close: 99.1, trend: 97.5 },
  { date: "2026-10-06", close: 98.6, trend: 97.8 },
];

const series = [
  { key: "close", label: "Close", type: "line", tone: "accent", lineWidth: 2 },
  { key: "trend", label: "Trend", type: "line", tone: "neutral", lineType: "dashed", symbol: false },
];

<LineChart xKey="date" data={rows} series={series} />

Not controllable here

  • data — A whole dataset is the caller's, never a control. The preview draws a fixed fixture and the copied code writes it out in full.
  • xKey — The fixture is keyed by `date`; a real chart's key follows the shape your API serves.
  • series — Series mark types, axes and stacking are the analytical contract, described above this panel.
  • className — Layout and width belong to the page that places the chart.
Copy for an AI agentA specification an agent can act on: the import, the setup, the chosen props, the data contract and the accessibility expectation.
Implement `LineChart` from Luc UI. It is: Compare series and read the change behind them, with the axes, legend and tooltip already wired.

Import it with: import { LineChart } from "@luc/ui/charts";
Requires: react ^19.0.0; react-dom ^19.0.0; react-hook-form ^7.0.0 (optional, for @luc/ui/forms/react-hook-form); tailwindcss ^4.0.0; node >= 22 (repository tools). Import the stylesheet once at the app root and wrap the tree in `LucProvider`. Both come from the package that publishes @luc.

Chosen configuration: `title=""`, `height={260}`, `legend={false}`, `visibleSeries={["close","trend"]}`, `animation="standard"`, `state="ready"`, `tooltip="axis"`, `ariaLabel=""`.

Accessibility: keep the component's own semantics. Do not re-implement its ARIA wiring, do not add roles it does not declare, and make sure every interactive element is reachable and operable from the keyboard with a visible focus state.
Styling: use Luc UI design tokens and the component's own props. Do not restyle with raw colour literals and do not override the component's internal structure with page CSS.
Motion: respect `prefers-reduced-motion`. The component already does, so do not disable it.

Reproduce this state:
```tsx
const rows = [
  { date: "2026-09-21", close: 96.4, trend: 96 },
  { date: "2026-09-22", close: 96.9, trend: 96.2 },
  { date: "2026-09-23", close: 96.2, trend: 96.1 },
  { date: "2026-09-24", close: 95.5, trend: 95.9 },
  { date: "2026-09-25", close: 96.1, trend: 96 },
  { date: "2026-09-28", close: 97.3, trend: 96.3 },
  { date: "2026-09-29", close: 98, trend: 96.7 },
  { date: "2026-09-30", close: 97.4, trend: 96.9 },
  { date: "2026-10-01", close: 96.8, trend: 96.9 },
  { date: "2026-10-02", close: 97.9, trend: 97.1 },
  { date: "2026-10-05", close: 99.1, trend: 97.5 },
  { date: "2026-10-06", close: 98.6, trend: 97.8 },
];

const series = [
  { key: "close", label: "Close", type: "line", tone: "accent", lineWidth: 2 },
  { key: "trend", label: "Trend", type: "line", tone: "neutral", lineType: "dashed", symbol: false },
];

<LineChart xKey="date" data={rows} series={series} />
```

Usage

The values are prepared by the caller: this component draws the points it is given and computes no statistic of its own, so units, scaling and any summary have to be settled before the data reaches it.

It is drawn by the ECharts engine.

Worked examples with real data are on the family overview: General

import { LineChart } from "@luc/ui/charts";
<LineChart
  data={[
    { date: "2026-08-17", close: 94.2, trend: 94.6 },
    { date: "2026-08-24", close: 95.1, trend: 94.8 },
    { date: "2026-08-31", close: 96.4, trend: 95.1 },
    { date: "2026-09-07", close: 95.8, trend: 95.4 },
    { date: "2026-09-14", close: 97.1, trend: 95.8 },
    { date: "2026-09-21", close: 98.6, trend: 96.3 },
    { date: "2026-09-28", close: 97.9, trend: 96.7 },
    { date: "2026-10-05", close: 99.4, trend: 97.2 },
  ]}
  xKey="date"
  axes={[{ id: "primary", position: "left", format: { kind: "number", decimals: 1 } }]}
  series={[
    {
      key: "close",
      label: "Close",
      type: "line",
      tone: "accent",
      lineWidth: 2,
      axis: "primary",
    },
    {
      key: "trend",
      label: "Trend",
      type: "line",
      tone: "neutral",
      lineType: "dashed",
      symbol: false,
    },
  ]}
  interaction={{ zoom: "none" }}
  height={320}
  ariaLabel="Weekly closes"
/>

Data contract

`data` is an array of rows; `xKey` names the ordered x field and every `series.key` names a numeric row field. A null value is drawn as a gap.

Important configuration

Set `series[].type: "line"`, format the axis with `axes[].format`, and use `interaction.zoom` only when the reader is expected to inspect a dense range.

Guidelines

When not to use

Do not join unordered categories with a line; use `BarChart` when the x field is a set of labels rather than a sequence.

Configuration

Exported symbols
ExportKindSignature
LineChart33 documented props<TRow extends object = Record<string, unknown>>({ family, state, height, className, visibleSeries, ariaLabel, ariaDescription, onReady, onEvent, ...spec }: CartesianChartProps<TRow>) => import("@type…

LineChart props

Type: CartesianChartProps<TRow>

Values the compiler reads from the declaration.

LineChart props
PropTypeDefaultNotes
animation?ChartAnimationPreset | undefined—Animation budget. Defaults to `standard`.
annotations?AnnotationSpec | undefined—
ariaDescription?string | undefined—
ariaLabel?string | undefined—
axes?readonly AxisSpec[] | undefined—Extra axes beyond the primary one.
className?string | undefined—
data?readonly TRow[] | undefined—
description?string | undefined—
engine?ChartEngine | undefined—
extendOption?((option: unknown) => void) | undefined—Advanced: mutate the assembled engine option. Clearly not the normal path.
family?ChartFamily | undefined—Override the family the wrapper defaults to. Advanced.
height?string | number | undefined—
id?string | undefined—
interaction?ChartInteractionSpec | undefined—
legend?boolean | undefined—
onEvent?((event: EChartEvent) => void) | undefined—
onReady?((chart: EChartsInstance) => void) | undefined—
orientation?"horizontal" | "vertical" | undefined—Bar family only: which way the bars grow. Defaults to `vertical`.
pointCount?number | undefined—The number of plotted points, when the caller already knows it. Used only to *reduce* animation for a large series; it never changes what is drawn.
points?Readonly<Record<string, ChartPointMeta>> | undefined—Per-point display metadata, keyed by the x value's canonical string form. A generic hook for a caller whose x values carry a better label or extra hover context than the axis can …
ranges?ChartRangeSpec | undefined—
renderer?ChartRenderer | undefined—Drawing layer. Defaults to `canvas`. Set `svg` when the chart is going to be captured rather than read: vector output survives PDF export and scales without a density choice. Igno…
scale?{ allowed?: readonly YScaleMode[]; default?: YScaleMode; mode?: YScaleMode; } | undefined—Scale capability and current mode. `allowed` is what the *product* declares it may offer (a signed drawdown is linear-only); `default` is what it opens on; `mode` is what the read…
seriesreadonly SeriesSpec[]—
state?ChartState | undefined—
syncGroup?string | undefined—
title?string | undefined—
tooltip?ChartTooltipSpec | undefined—
unit?string | undefined—
universalTransition?boolean | undefined—Morph the *same data* between two representations (a histogram ↔ a ranked bar, a stacked ↔ a grouped bar). Opt-in, because a morph between charts that do not share a data identity…
visibleSeries?readonly string[] | undefined—
x?AxisSpec | undefined—
xKey?string | undefined—Field that supplies the x value for tabular data.

Accessibility

A chart is a picture of data, so it needs a name that states what it shows, and the numbers must exist as text somewhere on the page — in a table or a written summary — because a drawing is not readable by a screen reader and cannot be copied.

What happens on the server, and when hydration changes it.

Luc UI v1.0LineChartdark theme