# LineChart Several series compared over a continuous axis. - Group: Charts - Import: `import { LineChart } from '@misoto22/design/charts'` - Page: https://ui.misoto22.com/components/line-chart/ - Related: area-chart, composed-chart ## When to reach for it The reader is comparing series against each other. When the area under one line is the point, fill it — that is an AreaChart. ## Accessibility - title is required; the rows are also rendered as a visually hidden table. - A clickable line gets a 15px transparent line underneath it, because a 1.6px stroke is not a pointer target. - buffer draws the last segment dashed by measuring the real path length, so a projection is visibly a different kind of fact at any curve type. ## LineChart Several series compared over a continuous axis — the shape for "which of these is going where". The difference from `` is what the reader is asked to do: an area says "read the magnitude under this", a line says "compare these against each other". Filling four overlapping series makes the second question unanswerable, which is why a line chart has no fill variant to offer. ### Props - `config` (required) — `TConfig & ValidateKeys`. - `data` (required) — `TData[]`. The rows the chart draws. One entry per point, bar or category. - `title` (required) — `string`. What the chart shows, in a sentence a reader could act on. Required, and announced to a screen reader even when it is not printed. - `showTitle` — `boolean`. Prints the title above the plot instead of hiding it from sight. - `description` — `ReactNode`. A line under the title — the unit, the window, the caveat. - `children` (required) — `ReactNode`. The composed parts — axes, grid, tooltip, legend, and the marks themselves. - `className` — `string`. Merged onto the figure, last, so a call site can size or space it. - `chartProps` — `ComponentProps`. Escape hatch onto the raw Recharts chart element. - `curveType` — `ChartCurveType` default `'linear'`. How the line between two points is interpolated. Every mark inherits it unless it says otherwise. - `animationType` — `ChartRevealType` default `'forward'`. - `defaultSelectedDataKey` — `string | null` default `null`. The series lit on first render. Selection dims every other series. - `onSelectionChange` — `(selectedDataKey: string | null) => void`. Fires when the selection changes, and with null when it is cleared. - `isLoading` — `boolean` default `false`. Swaps the marks for an animated skeleton, keeping the measured height so the page does not jump when the data lands. - `loadingPoints` — `number`. How many points the skeleton draws. - `xDataKey` — `keyof TData & string`. The row field on the category axis. Needed by the brush and by the table view. - `hideDataTable` — `boolean` default `false`. Drops the hidden table view. Only correct when the page prints the data itself. - `empty` — `ChartEmptyProps | false`. What the chart shows when it has nothing to draw. Rendered instead of the plot whenever `data` is empty and the chart is not loading — the state a real dashboard reaches within a week, and the one an empty pair of axes is indistinguishable from a failed load. `false` keeps the axes, for a chart whose emptiness is itself the reading. ## Example — default ```tsx import { LineChart, type ChartConfig } from '@misoto22/design/charts' ``` ## Example — stroke dot curve ```tsx import { ToggleGroup, ToggleGroupItem } from '@misoto22/design'
next && setStroke(next as LineStrokeVariant)} aria-label="Stroke" > {STROKES.map((option) => ( {option} ))} next && setDot(next as ChartDotVariant)} aria-label="Dot" > {DOTS.map((option) => ( {option} ))} next && setCurve(next as ChartCurveType)} aria-label="Curve" > {CURVES.map((option) => ( {option} ))}
``` ## Example — legend variants ```tsx import { ToggleGroup, ToggleGroupItem } from '@misoto22/design' import { LineChart, type ChartConfig, type ChartLegendVariant } from '@misoto22/design/charts'
next && setVariant(next as ChartLegendVariant)} aria-label="Legend swatch" > {VARIANTS.map((option) => ( {option} ))}
``` ## Example — backgrounds ```tsx import { ToggleGroup, ToggleGroupItem } from '@misoto22/design' import { LineChart, type ChartBackgroundVariant, type ChartConfig } from '@misoto22/design/charts'
next && setVariant(next as ChartBackgroundVariant)} aria-label="Background plate" className="flex-wrap" > {VARIANTS.map((option) => ( {option} ))}
``` ## Example — emphasis ```tsx import { LineChart, type ChartConfig } from '@misoto22/design/charts'
{/* The last segment is dashed by measuring the real path length, so the split lands exactly on the second-to-last point at any curve type — which an arithmetic dasharray cannot do. */}
``` ## Example — brush ```tsx import { LineChart, type ChartConfig } from '@misoto22/design/charts' ``` ## Example — loading ```tsx import { LineChart, type ChartConfig } from '@misoto22/design/charts' ``` ## Example — axis labels and format ```tsx import { LineChart, formatNumber, type ChartConfig } from '@misoto22/design/charts'
``` ## Example — sonify ```tsx import { LineChart, type ChartConfig } from '@misoto22/design/charts' ``` ## Example — toolbar ```tsx import { LineChart, type ChartConfig } from '@misoto22/design/charts' ```