Skip to content
Scientific & mathematicalGenerated from the public API

ContourChart

Read a field, a geometry or a spectrum, with the scale handled for you.

@luc/ui/charts

What it shows

Read a sampled scalar field through explicitly supplied contour rings and levels.

Live preview

Iso-rings supplied by the caller over a nine-point sampled surface — the chart traces nothing itself.

<ContourChart
  levels={[
    {
      level: 0.5,
      rings: [
        [[-0.5, 0], [0, 0.5], [0.5, 0], [0, -0.5], [-0.5, 0]],
        [[-1, 0], [0, 1], [1, 0], [0, -1], [-1, 0]],
      ],
    },
    {
      level: 1,
      rings: [
        [[-0.95, 0], [0, 0.95], [0.95, 0], [0, -0.95], [-0.95, 0]],
        [[-1.9, 0], [0, 1.9], [1.9, 0], [0, -1.9], [-1.9, 0]],
      ],
    },
  ]}
  surface={[
    { x: -1, y: -1, z: 1 },
    { x: 0, y: -1, z: 0 },
    { x: 1, y: -1, z: 1 },
    { x: -1, y: 0, z: 0 },
    { x: 0, y: 0, z: -1 },
    { x: 1, y: 0, z: 0 },
    { x: -1, y: 1, z: 1 },
    { x: 0, y: 1, z: 0 },
    { x: 1, y: 1, z: 1 },
  ]}
  xFormat={{ kind: "number", decimals: 1 }}
  yFormat={{ kind: "number", decimals: 1 }}
  zFormat={{ kind: "number", decimals: 1 }}
  height={340}
  ariaLabel="Saddle field"
/>

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 { ContourChart } from "@luc/ui/charts";

<ContourChart
  levels={[
    {
      level: 0.5,
      rings: [
        [[-0.5, 0], [0, 0.5], [0.5, 0], [0, -0.5], [-0.5, 0]],
        [[-1, 0], [0, 1], [1, 0], [0, -1], [-1, 0]],
      ],
    },
    {
      level: 1,
      rings: [
        [[-0.95, 0], [0, 0.95], [0.95, 0], [0, -0.95], [-0.95, 0]],
        [[-1.9, 0], [0, 1.9], [1.9, 0], [0, -1.9], [-1.9, 0]],
      ],
    },
  ]}
  surface={[
    { x: -1, y: -1, z: 1 },
    { x: 0, y: -1, z: 0 },
    { x: 1, y: -1, z: 1 },
    { x: -1, y: 0, z: 0 },
    { x: 0, y: 0, z: -1 },
    { x: 1, y: 0, z: 0 },
    { x: -1, y: 1, z: 1 },
    { x: 0, y: 1, z: 0 },
    { x: 1, y: 1, z: 1 },
  ]}
  xFormat={{ kind: "number", decimals: 1 }}
  yFormat={{ kind: "number", decimals: 1 }}
  zFormat={{ kind: "number", decimals: 1 }}
  height={340}
  ariaLabel="Saddle field"
  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 `ContourChart` from Luc UI. It is: Read a field, a geometry or a spectrum, with the scale handled for you.

Import it with: import { ContourChart } 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="Saddle field"`.

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
<ContourChart
  levels={[
    {
      level: 0.5,
      rings: [
        [[-0.5, 0], [0, 0.5], [0.5, 0], [0, -0.5], [-0.5, 0]],
        [[-1, 0], [0, 1], [1, 0], [0, -1], [-1, 0]],
      ],
    },
    {
      level: 1,
      rings: [
        [[-0.95, 0], [0, 0.95], [0.95, 0], [0, -0.95], [-0.95, 0]],
        [[-1.9, 0], [0, 1.9], [1.9, 0], [0, -1.9], [-1.9, 0]],
      ],
    },
  ]}
  surface={[
    { x: -1, y: -1, z: 1 },
    { x: 0, y: -1, z: 0 },
    { x: 1, y: -1, z: 1 },
    { x: -1, y: 0, z: 0 },
    { x: 0, y: 0, z: -1 },
    { x: 1, y: 0, z: 0 },
    { x: -1, y: 1, z: 1 },
    { x: 0, y: 1, z: 0 },
    { x: 1, y: 1, z: 1 },
  ]}
  xFormat={{ kind: "number", decimals: 1 }}
  yFormat={{ kind: "number", decimals: 1 }}
  zFormat={{ kind: "number", decimals: 1 }}
  height={340}
  ariaLabel="Saddle field"
  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: Scientific & mathematical

import { ContourChart } from "@luc/ui/charts";
<ContourChart
  levels={[
    {
      level: 0.5,
      rings: [
        [[-0.5, 0], [0, 0.5], [0.5, 0], [0, -0.5], [-0.5, 0]],
        [[-1, 0], [0, 1], [1, 0], [0, -1], [-1, 0]],
      ],
    },
    {
      level: 1,
      rings: [
        [[-0.95, 0], [0, 0.95], [0.95, 0], [0, -0.95], [-0.95, 0]],
        [[-1.9, 0], [0, 1.9], [1.9, 0], [0, -1.9], [-1.9, 0]],
      ],
    },
  ]}
  surface={[
    { x: -1, y: -1, z: 1 },
    { x: 0, y: -1, z: 0 },
    { x: 1, y: -1, z: 1 },
    { x: -1, y: 0, z: 0 },
    { x: 0, y: 0, z: -1 },
    { x: 1, y: 0, z: 0 },
    { x: -1, y: 1, z: 1 },
    { x: 0, y: 1, z: 0 },
    { x: 1, y: 1, z: 1 },
  ]}
  xFormat={{ kind: "number", decimals: 1 }}
  yFormat={{ kind: "number", decimals: 1 }}
  zFormat={{ kind: "number", decimals: 1 }}
  height={340}
  ariaLabel="Saddle field"
/>

Data contract

`surface` supplies the sampled grid and `levels` supplies the iso-values; `xFormat`, `yFormat` and `zFormat` describe the three units. The chart does not extrapolate a surface.

Important configuration

Choose levels that cover the observed range, keep the x/y domain explicit, and format the z value with its real unit rather than a bare number.

Guidelines

When not to use

Do not use contours to hide sparse sampling or present interpolated rings as measured values.

Configuration

Exported symbols
ExportKindSignature
ContourChart16 documented props({ levels, surface, xFormat, yFormat, zFormat, labels, title, description, state, height, className, ariaLabel, ariaDescription, onReady, onEvent, eager, }: ContourChartProps) => import("@types/react…

ContourChart props

Type: ContourChartProps

Values the compiler reads from the declaration.

ContourChart props
PropTypeDefaultNotes
ariaDescription?string | undefined—
ariaLabel?string | undefined—
className?string | undefined—
description?string | undefined—
eager?boolean | undefined—Create the engine on mount rather than when the surface is approached.
height?string | number | undefined—
labels?boolean | undefined—Label the iso lines. Default `true`.
levelsreadonly ContourLevel[]—
onEvent?((event: EChartEvent) => void) | undefined—
onReady?((chart: EChartsInstance) => void) | undefined—
state?ChartState | undefined—
surface?readonly { x: number; y: number; z: number; }[] | undefined—The sampled surface, drawn under the lines as a field.
title?string | undefined—
xFormat?ChartFormat | undefined—
yFormat?ChartFormat | undefined—
zFormat?ChartFormat | undefined—

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.0ContourChartdark theme