LineChart

Time-series or numeric line chart with multi-series support, hover tooltip, and legend.

Category: chart · WCAG 2.1-AA · chart, line, time-series, data-viz

Props

PropTypeDefaultDescription
seriesLineChartSeries<Datum>[]Array of data series
x(d: Datum) => number | DateX-value accessor. Return a `number` for a numeric axis or a `Date` for a time axis (ticks format as dates). This is a continuous scale — unlike BarChart, whose `x` returns a category `string` (band scale). For discrete categories, use BarChart.
y(d: Datum) => numberY-value accessor, applied to every series unless a series sets its own `y`. One x-domain per chart, so `x` is chart-level only; give each series a `y` to plot different fields from one shared data row.
titlestringChart title (also used as aria-label)
descriptionstringSubtitle shown below title
curve'linear' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter' | 'natural' | 'basis' | 'cardinal' | 'catmullRom'monotoneLine interpolation curve
widthnumberFixed SVG width (defaults to container width)
heightnumber300SVG height in px
xTicksnumber5Approximate number of X-axis ticks
yTicksnumber5Approximate number of Y-axis ticks
legendbooleanShow series legend
tooltipbooleanEnable hover tooltip
formatTooltip(datum: Datum, series: LineChartSeries<Datum>) => stringCustom tooltip formatter
classNamestringAdditional CSS class names merged onto the root element.
plainbooleanfalseMarks only — no axes, grid lines, or legend. For micro/inline charts.
annotationsAnnotation[]Reference lines, shaded bands, and markers drawn over the plot (e.g. a target/threshold line).
labelsboolean | { format?: (v: number) => string; position?: string }Print each value as a label on the mark (collision-aware, decorative/aria-hidden).
connectNullsbooleanfalseBridge non-finite y gaps instead of breaking the line at them.
onSelect(point: ChartPoint) => voidFired when a point is clicked or activated (Enter/Space) — for drill-down.
brushbooleanfalseShow a keyboard-operable Brush below the plot to subset (zoom) the series to a window.
dataZoombooleanfalseShow a DataZoom slider below the plot — a Brush whose body also pans the window.
zoombooleanfalseEnable in-plot wheel/drag/keyboard zoom-pan (+/-/0) over the series index window, with a reset control and re-ticked axes.
syncIdstringConnect this chart to others sharing the same id — they mirror the zoom window and hovered x.
tooltipMode'item' | 'axis'itemTooltip trigger — item (nearest point) or axis (a crosshair + a shared tooltip listing every series at the hovered x).
decimateboolean | { method?: 'lttb' | 'minmax'; threshold?: number }Downsample dense series before drawing (LTTB or min-max). Visual only — the fallback table keeps the full data.
toolboxboolean | ToolboxOptionsRender a keyboard-reachable toolbox — PNG/SVG export, a data-view table toggle, and restore (reset zoom).
transitionboolean | { duration?: number; easing?: string; properties?: string[] }Tune the reduced-motion-gated enter/update transitions (false disables). Always suppressed under prefers-reduced-motion.
onBeforeDraw(ctx: { width: number; height: number }) => ReactNodeRender custom SVG behind the marks (watermark/region) — a lightweight extension seam.
onAfterDraw(ctx: { width: number; height: number }) => ReactNodeRender custom SVG over the marks (overlay/extra series) — a lightweight extension seam.

Design tokens

When to use

When not to use

Examples

Basic line chart

import { LineChart } from '@cascivo/charts'

const series = [{ id: 'a', label: 'Revenue', data: [{x:1,y:10},{x:2,y:20},{x:3,y:15}] }]
<LineChart series={series} x={d => d.x} y={d => d.y} title="Revenue" />

With an SLO target line

<LineChart
  series={series}
  x={d => d.x}
  y={d => d.y}
  title="Latency"
  annotations={[{ kind: 'line', axis: 'y', value: 200, label: 'SLO' }]}
/>

Related components

← Back to docs