Skip to content
GeneralGenerated from the public API

ComposedChart

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

@luc/ui/charts

What it shows

Read two differently scaled quantities on one shared x axis, such as a price line with a drawdown bar layer.

Live preview

Two marks, two axes, two units: a price on the right and a negative percentage on the left.

<ComposedChart
  data={[
    { date: "2026-09-21", close: 96.4, drawdown: -1.2 },
    { date: "2026-09-22", close: 96.9, drawdown: -0.8 },
    { date: "2026-09-23", close: 96.2, drawdown: -1.5 },
    { date: "2026-09-24", close: 95.5, drawdown: -2.3 },
    { date: "2026-09-25", close: 96.1, drawdown: -1.7 },
    { date: "2026-09-28", close: 97.3, drawdown: -0.6 },
    { date: "2026-09-29", close: 98, drawdown: -0.1 },
    { date: "2026-09-30", close: 97.4, drawdown: -0.7 },
  ]}
  xKey="date"
  axes={[
    { id: "price", position: "right", format: { kind: "number", decimals: 1 } },
    { id: "drawdown", position: "left", format: { kind: "percent", decimals: 1 } },
  ]}
  series={[
    {
      key: "close",
      label: "Close",
      type: "line",
      axis: "price",
      tone: "accent",
      lineWidth: 2,
    },
    {
      key: "drawdown",
      label: "Drawdown",
      type: "bar",
      axis: "drawdown",
      tone: "negative",
      opacity: 0.5,
    },
  ]}
  height={340}
  ariaLabel="Close with drawdown"
/>

Controls

Height

340px

A chart measures its container, so it always needs a definite height.

State

The surface the chart is in — loading, empty and error are drawn by the component.

Accessible name

A drawing is not readable by a screen reader, so it needs a name that states what it shows.

The same fixture as the live preview above; the controls change how it is drawn, not what it measures.

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

<ComposedChart
  data={[
    { date: "2026-09-21", close: 96.4, drawdown: -1.2 },
    { date: "2026-09-22", close: 96.9, drawdown: -0.8 },
    { date: "2026-09-23", close: 96.2, drawdown: -1.5 },
    { date: "2026-09-24", close: 95.5, drawdown: -2.3 },
    { date: "2026-09-25", close: 96.1, drawdown: -1.7 },
    { date: "2026-09-28", close: 97.3, drawdown: -0.6 },
    { date: "2026-09-29", close: 98, drawdown: -0.1 },
    { date: "2026-09-30", close: 97.4, drawdown: -0.7 },
  ]}
  xKey="date"
  axes={[
    { id: "price", position: "right", format: { kind: "number", decimals: 1 } },
    { id: "drawdown", position: "left", format: { kind: "percent", decimals: 1 } },
  ]}
  series={[
    {
      key: "close",
      label: "Close",
      type: "line",
      axis: "price",
      tone: "accent",
      lineWidth: 2,
    },
    {
      key: "drawdown",
      label: "Drawdown",
      type: "bar",
      axis: "drawdown",
      tone: "negative",
      opacity: 0.5,
    },
  ]}
  height={340}
  ariaLabel="Close with drawdown"
  state="ready"
/>

Not controllable here

  • series / rows — The numbers are the caller's; the fixture above is the example.
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 `ComposedChart` 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 { ComposedChart } 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: `height={340}`, `state="ready"`, `ariaLabel="Close with drawdown"`.

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
<ComposedChart
  data={[
    { date: "2026-09-21", close: 96.4, drawdown: -1.2 },
    { date: "2026-09-22", close: 96.9, drawdown: -0.8 },
    { date: "2026-09-23", close: 96.2, drawdown: -1.5 },
    { date: "2026-09-24", close: 95.5, drawdown: -2.3 },
    { date: "2026-09-25", close: 96.1, drawdown: -1.7 },
    { date: "2026-09-28", close: 97.3, drawdown: -0.6 },
    { date: "2026-09-29", close: 98, drawdown: -0.1 },
    { date: "2026-09-30", close: 97.4, drawdown: -0.7 },
  ]}
  xKey="date"
  axes={[
    { id: "price", position: "right", format: { kind: "number", decimals: 1 } },
    { id: "drawdown", position: "left", format: { kind: "percent", decimals: 1 } },
  ]}
  series={[
    {
      key: "close",
      label: "Close",
      type: "line",
      axis: "price",
      tone: "accent",
      lineWidth: 2,
    },
    {
      key: "drawdown",
      label: "Drawdown",
      type: "bar",
      axis: "drawdown",
      tone: "negative",
      opacity: 0.5,
    },
  ]}
  height={340}
  ariaLabel="Close with drawdown"
  state="ready"
/>
```

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 { ComposedChart } from "@luc/ui/charts";
<ComposedChart
  data={[
    { date: "2026-09-21", close: 96.4, drawdown: -1.2 },
    { date: "2026-09-22", close: 96.9, drawdown: -0.8 },
    { date: "2026-09-23", close: 96.2, drawdown: -1.5 },
    { date: "2026-09-24", close: 95.5, drawdown: -2.3 },
    { date: "2026-09-25", close: 96.1, drawdown: -1.7 },
    { date: "2026-09-28", close: 97.3, drawdown: -0.6 },
    { date: "2026-09-29", close: 98, drawdown: -0.1 },
    { date: "2026-09-30", close: 97.4, drawdown: -0.7 },
  ]}
  xKey="date"
  axes={[
    { id: "price", position: "right", format: { kind: "number", decimals: 1 } },
    { id: "drawdown", position: "left", format: { kind: "percent", decimals: 1 } },
  ]}
  series={[
    {
      key: "close",
      label: "Close",
      type: "line",
      axis: "price",
      tone: "accent",
      lineWidth: 2,
    },
    {
      key: "drawdown",
      label: "Drawdown",
      type: "bar",
      axis: "drawdown",
      tone: "negative",
      opacity: 0.5,
    },
  ]}
  height={340}
  ariaLabel="Close with drawdown"
/>

Data contract

`data` rows share `xKey`; every `series.key` names a numeric field and every `series.axis` must match an entry in `axes`. Different units need different axis ids.

Important configuration

Declare each `axes[].id`, `position` and `format`, and choose the mark with `series[].type`; stacking is a property of the bar series, not the composed chart as a whole.

Guidelines

When not to use

Do not place two units on one y axis merely to make the lines fit; the visual comparison becomes arithmetically false.

Configuration

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

ComposedChart props

Type: CartesianChartProps<TRow>

Values the compiler reads from the declaration.

ComposedChart 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.0ComposedChartdark theme