VectorFieldChart
Read a field, a geometry or a spectrum, with the scale handled for you.
@luc/ui/chartsWhat it shows
Read direction and magnitude across a sampled plane through one arrow per observation.
Live preview
Nine sampled arrows at their true magnitude, including the one that is exactly zero.
<VectorFieldChart
vectors={[
{ x: -1, y: -1, u: 0.3, v: -0.4 },
{ x: 0, y: -1, u: 0.5, v: -0.2 },
{ x: 1, y: -1, u: 0.4, v: 0.3 },
{ x: -1, y: 0, u: -0.6, v: 0.1 },
{ x: 0, y: 0, u: 0, v: 0 },
{ x: 1, y: 0, u: 0.6, v: -0.1 },
{ x: -1, y: 1, u: -0.4, v: 0.3 },
{ x: 0, y: 1, u: -0.5, v: 0.2 },
{ x: 1, y: 1, u: -0.3, v: 0.4 },
]}
scale={1}
xFormat={{ kind: "number", decimals: 1 }}
yFormat={{ kind: "number", decimals: 1 }}
height={340}
ariaLabel="Vector field"
/>Controls
Height
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 { VectorFieldChart } from "@luc/ui/charts";
<VectorFieldChart
vectors={[
{ x: -1, y: -1, u: 0.3, v: -0.4 },
{ x: 0, y: -1, u: 0.5, v: -0.2 },
{ x: 1, y: -1, u: 0.4, v: 0.3 },
{ x: -1, y: 0, u: -0.6, v: 0.1 },
{ x: 0, y: 0, u: 0, v: 0 },
{ x: 1, y: 0, u: 0.6, v: -0.1 },
{ x: -1, y: 1, u: -0.4, v: 0.3 },
{ x: 0, y: 1, u: -0.5, v: 0.2 },
{ x: 1, y: 1, u: -0.3, v: 0.4 },
]}
scale={1}
xFormat={{ kind: "number", decimals: 1 }}
yFormat={{ kind: "number", decimals: 1 }}
height={340}
ariaLabel="Vector 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 `VectorFieldChart` from Luc UI. It is: Read a field, a geometry or a spectrum, with the scale handled for you.
Import it with: import { VectorFieldChart } 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="Vector 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
<VectorFieldChart
vectors={[
{ x: -1, y: -1, u: 0.3, v: -0.4 },
{ x: 0, y: -1, u: 0.5, v: -0.2 },
{ x: 1, y: -1, u: 0.4, v: 0.3 },
{ x: -1, y: 0, u: -0.6, v: 0.1 },
{ x: 0, y: 0, u: 0, v: 0 },
{ x: 1, y: 0, u: 0.6, v: -0.1 },
{ x: -1, y: 1, u: -0.4, v: 0.3 },
{ x: 0, y: 1, u: -0.5, v: 0.2 },
{ x: 1, y: 1, u: -0.3, v: 0.4 },
]}
scale={1}
xFormat={{ kind: "number", decimals: 1 }}
yFormat={{ kind: "number", decimals: 1 }}
height={340}
ariaLabel="Vector 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 { VectorFieldChart } from "@luc/ui/charts";<VectorFieldChart
vectors={[
{ x: -1, y: -1, u: 0.3, v: -0.4 },
{ x: 0, y: -1, u: 0.5, v: -0.2 },
{ x: 1, y: -1, u: 0.4, v: 0.3 },
{ x: -1, y: 0, u: -0.6, v: 0.1 },
{ x: 0, y: 0, u: 0, v: 0 },
{ x: 1, y: 0, u: 0.6, v: -0.1 },
{ x: -1, y: 1, u: -0.4, v: 0.3 },
{ x: 0, y: 1, u: -0.5, v: 0.2 },
{ x: 1, y: 1, u: -0.3, v: 0.4 },
]}
scale={1}
xFormat={{ kind: "number", decimals: 1 }}
yFormat={{ kind: "number", decimals: 1 }}
height={340}
ariaLabel="Vector field"
/>Data contract
`vectors` contain a tail (`x`, `y`) and vector components (`u`, `v`); `scale` is a caller-controlled length multiplier. The chart does not normalise arrows by default.
Important configuration
Set `scale` explicitly, keep a zero vector visible when it is meaningful, and format both spatial axes with `xFormat`/`yFormat`.
Guidelines
When not to use
Do not apply an undocumented scale or compare fields with different arrow multipliers as if magnitudes were on one scale.
Configuration
| Export | Kind | Signature |
|---|---|---|
VectorFieldChart | 14 documented props | ({ vectors, scale, xFormat, yFormat, title, description, state, height, className, ariaLabel, ariaDescription, onReady, onEvent, eager, }: VectorFieldChartProps) => import("@types/react").JSX.Element |
VectorFieldChart props
Type: VectorFieldChartProps
Values the compiler reads from the declaration.
| Prop | Type | Default | Notes |
|---|---|---|---|
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 | — | |
onEvent? | ((event: EChartEvent) => void) | undefined | — | |
onReady? | ((chart: EChartsInstance) => void) | undefined | — | |
scale? | number | undefined | — | Arrow length multiplier. 1 keeps the raw magnitude. |
state? | ChartState | undefined | — | |
title? | string | undefined | — | |
vectors | readonly { x: number; y: number; u: number; v: number; }[] | — | One arrow per sample: a tail at `(x, y)` and a direction `(u, v)`. |
xFormat? | ChartFormat | undefined | — | |
yFormat? | 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.
Family
Scientific & mathematical
Fields, geometry and spectra for scientific readers.
Related