Skip to content
InsightCharts

Search

Search guides and components

Line chart

Shows how one or more values change over time or another ordered dimension.

Use when
Trends over time with roughly 5 or more points; comparing the trajectories of a few series; one highlighted series against many context series.
Avoid when
Unordered categories (use bar chart); only two time points (use slope chart); more than about 6 equally important lines (use small multiples).

Preview

Solar's share rose from 2.7% to 5.5% between 2019 and 2023

Composition

Used in

5 molecules and 9 templates use line chart.

Molecules

5

A chart with a callout beside it that states the main fact. In narrow containers the callout goes underneath.

One chart frame with a segmented control that switches between several views of the same data, morphing between views that share a chart type.

The opening exhibit of a piece: kicker, headline and deck above one large chart, with a source line underneath.

Two to four charts over one shared dataset in a responsive grid: clicking a mark in one filters the others, with the active filters shown as removable chips.

A story section: a numbered step marker or a headline, introductory prose, then one or more exhibits in a responsive one- to three-column grid.

Templates

9

A compared with B on one page. It has a headline that states the result, the headline figures mirrored either side of their labels, one hero exhibit that shows both sides, paired exhibits on a shared scale, a verdict callout and a source note.

A one-page summary. It has a headline that states the main finding with its number, a deck, a row of three or four key figures, one hero chart with a takeaway callout, two smaller supporting exhibits, a short list of actions and a source note.

Directly, and throughChart with callout

A vertical infographic in one narrow column. It opens with a big number or a proportion statement (hook), then the hero exhibit, then numbered sections with one exhibit each, a conclusion with an optional link, and sources.

A section of an analytical report laid out as a document. It has a title block, a summary, numbered findings, then method, limitations and sources. Each finding has one exhibit, an observation and a separately labelled interpretation with a confidence rating and a caveat.

A recurring report. It has a masthead with the report name and period, a headline that states the main change, a KPI grid with changes and sparklines, a ranked list beside one or two trend charts, an optional comparison table, short notes and a source note.

A sequence of full-frame cards (title, stat, chart, quote, closing) that the reader swipes or steps through. Each card states one fact. It has an optional fixed aspect ratio, a keyboard-accessible pager and a stacked layout for print.

A story told in date order. It has a headline, one overview exhibit of the whole period (a timeline chart or an annotated line), dated chapters along a rail, a closing paragraph and a source note. Each chapter has a short text and an optional small exhibit.

A long article read by scrolling. It has a headline, then an ordered list of blocks in a reading column, then a source note. The blocks are prose, figures, charts with a callout, scrolly sequences, pull quotes, stat rows, small multiples and chapter breaks. Exhibits can be wider than the column.

Directly, and throughChart with callout

A set of linked charts over one shared dataset that filter each other. It has a headline, a sentence of instructions with filter chips, a row of figures that recompute from the filtered rows, two to four charts and an optional detail table. It opens on selections the author chooses.

Installation

$ pnpm dlx shadcn@latest add @insightcharts/line-chart

The CLI copies the source into your project and needs the @insightcharts registry in components.json; see installation. With the package, import it by name:

import { LineChart } from "insightcharts";

Examples

Highlight with named context lines

Mobile money use in Addis rose from 6.6% in 2015 to 60.8% in 2024

Share of households with a mobile money account. `contextLabels: true` names the grey lines in muted type.

Illustrative data

Highlight, one legend entry for the rest, annotations near the right edge

Addis reached the 60% national target in 2024

Households with a mobile money account

Illustrative data

Stress: six lines converge

Five of six cities had between 58.8% and 61% of households using mobile money in 2024

Households with a mobile money account

Illustrative data

Long format with highlight

Mobile money use in Addis rose from 6.6% in 2015 to 60.8% in 2024

Households with a mobile money account

Illustrative data

Props

PropTypeDefaultDescription
xrequiredstringTime or ordered category field. ISO dates are placed on a true time axis.
yrequiredstring | string[]Value field, or several (one line each).
seriesstringField that splits rows into lines (long data).
curve"linear" | "smooth" | "step""linear"Line shape.
areabooleanfalseLight fill under the line; forces a zero baseline.
endLabelsbooleanName each line at its end. Default: on for up to 6 lines.
pointsbooleanMarker on every point. Default: on for 12 points or fewer.
zerobooleanfalseStart the value axis at zero.
logbooleanfalseLogarithmic value axis.
namesRecord<string, string>Display names for series keys.
contextLabelsboolean | stringfalseWith highlight: name the grey context lines. true adds a muted end label to each when they all fit; a string such as "Other cities" adds one muted legend entry instead. On narrow charts the legend already lists every line.
Common chart props 29

Every chart built with defineChart accepts these on top of its own props.

PropTypeDescription
dataDataInputRows, CSV text, a URL, { url, path }, an async function, or an Arrow-style table. Omit inside <InsightData>.
transformTransform | Transform[]A pipeline of transforms applied before drawing.
titlestringThe title. One plain statement of what the data shows, with the number and the period ("Monthly churn fell from 4.2% to 2.1% in 2024"), or a plain label ("Monthly churn, 2024"). One clause, no figures of speech.
subtitlestringMeasure, unit, population, period.
sourcestringData source, shown as "Source: ...".
notestringMethod notes or caveats.
heightnumber | stringCSS height of the plot. Default 360.
aspectnumberWidth / height. Overrides height.
highlightstring | string[]The entity (or entities) the title is about. Every other series is drawn in grey.
annotationsAnnotation[]Reference lines, shaded bands and callouts, in data coordinates.
formatFormatSpecHow to print values: "compact", "percent", "currency:USD", "{value} kg", Intl options, or a function.
legendbooleanShow the legend. Default: shown when there are two or more series.
selectboolean | stringMake marks clickable to filter. Inside <InsightData> the selection filters every other chart. Pass a field name, or true to use the chart's category field.
onSelect(values: string[], field: string) => voidCalled with the selected values whenever the selection changes.
optionEChartsOption | ((option: EChartsOption, ctx: BuildContext) => EChartsOption)Deep-merged over the generated ECharts option, or a function that receives and returns it. Use it for ECharts settings no prop covers.
themeThemeInputA theme, or a partial set of tokens merged over the surrounding theme, for this chart only.
modeModeInput"auto" (default) follows the page, "system" follows the OS, or force "light" / "dark".
rendererRendererInput"auto" (default) uses SVG for light charts and canvas for heavy ones.
animatebooleanSet false to disable animation. Reduced-motion preferences are always respected.
lazybooleanMount the chart only when it scrolls near the viewport. Default true.
groupstringLink tooltips with other charts sharing this group id.
exportableboolean | ExportFormat[]Show an export menu: true or a list of formats from png, jpeg, svg, pdf, csv, json.
tablebooleanShow a collapsible "View data" table under the chart.
altstringAccessible description: the chart type and measures, then the main pattern and the notable values.
idstringStable id for this chart's selection in the shared store.
onEventsRecord<string, ChartEventHandler>ECharts event handlers, e.g. { click: (params, chart) => {} }. Prefix a name with zr: to bind to the canvas itself.
onReady(chart: EChartsInstance) => voidCalled with the ECharts instance once it is created.
classNamestringClass name for the outer <figure>.
styleCSSPropertiesInline style for the outer <figure>.