Components · Data Display
Line Chart
BetaAdded v3.2.0
Show a trend over ordered categories such as time. Server-rendered SVG on the chart palette.
import { LineChart } from '@nexub/react';Playground
Props
size
legend
| week | Active | Trial |
|---|---|---|
| W1 | 820 | 310 |
| W2 | 870 | 290 |
| W3 | 905 | 340 |
| W4 | 960 | 330 |
| W5 | 1,010 | 360 |
| W6 | 1,080 | 355 |
<LineChart className="w-full" data={data} index="week" series={…} title="Weekly users" />Examples
Two series
Area
Gaps and one currency per series
States
Weekly users week Active Trial W1 820 310 W2 870 290 W3 905 340 W4 960 330 W5 1,010 360 W6 1,080 355 defaultloadingWeekly users week Active Trial W1 820 310 W2 870 290 W3 905 340 W4 960 330 W5 1,010 360 W6 1,080 355 size="sm"Weekly users week Active Trial W1 820 310 W2 870 290 W3 905 340 W4 960 330 W5 1,010 360 W6 1,080 355 size="md"Weekly users week Active Trial W1 820 310 W2 870 290 W3 905 340 W4 960 330 W5 1,010 360 W6 1,080 355 size="lg"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| titlerequired | string | — | Accessible name of the chart and caption of its data table. |
| datarequired | T[] | — | One row per category, in order. |
| indexrequired | keyof T & string | — | Key of the category label in each row (the x axis). |
| seriesrequired | ChartSeries[] | — | { key, label?, color? } per series. color is 1–8 from the categorical chart palette; defaults to the series position. |
| valueFormat | ((value: number) => string) | defaultFormat | Formats axis labels, hover text and the data table. |
| size | 'sm' | 'md' | 'lg' | 'md' | Plot height: 8, 12 or 16rem. |
| legend | false | true | 'toggle' | true | Show the legend. Defaults to on for more than one series. |
| area | boolean | false | Fill the area under each line. |
| series[].color | 1–8 | 'good' | 'warning' | 'danger' | 'neutral' | — | 11.3: a palette colour or a semantic tone. |
| series[].valueFormat | (value: number) => string | — | 11.3: formats this series in the tooltip and table (one currency per series). |
| integerTicks | boolean | — | 11.3: gridlines on whole numbers only (counts). Also 11.3: a null or missing value is drawn as a gap (no bar, a break in the line) and listed as "—", not counted as 0. |
| tableView | string | boolean | — | 11.3: a visible "Show as table" disclosure with the same data. Works without JS. |
| defaultHiddenSeries | string[] | — | Keys of the series hidden at first. |
| emptyState | React.ReactNode | — | Shown when there is no data. Defaults to the "no data" message. |
| errorState | React.ReactNode | — | Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty. |
| hiddenSeries | string[] | — | Keys of the hidden series, controlled (10.7). |
| interactive | boolean | — | A crosshair and tooltip that follow the pointer, and arrow-key navigation between points. |
| loading | boolean | — | Shows a skeleton in place of the data and sets aria-busy. |
| onHiddenSeriesChange | ((hidden: string[]) => void) | — | |
| onPointClick | ((point: ChartPoint<T>) => void) | — | Click, tap, or Enter/Space on a point. Turns interactive on unless it is set to false. |
Accessibility
Screen reader
The chart is a `figure` named by `title`. The drawing is hidden from assistive tech; a visually hidden table carries every value.
Colour is never the only cue: the legend and table name each series. Past six series, label directly or group the rest as "Other".
On iOS & Android
Web only
Line Chart has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.