Skip to content
InsightCharts

Search

Search guides and components

Scrolly chart

A scroll-driven story from JSON: one base chart spec and a list of steps, each with narration and a patch of chart props applied while that step is active.

Use when
Walking a reader through one chart in stages: show everything, highlight the subject, change the measure, add the annotation. Make ONE change per step (the highlight, the data or the encoding) so the reader can see what changed.
Avoid when
Steps that change several things at once, or that swap to an unrelated chart (start a new section instead). More than about seven steps. A fact that one view can show (use chart with callout). In documents that will be printed or embedded in a short frame, set scrollMode: "steps".

Preview

EU electricity generation by source, 2015

Share of EU electricity generation, %

Source: Ember, European Electricity Review 2025 · Rounded, approximate figures for illustration
2015

In 2015 nuclear and coal together supplied 51.7% of the EU's electricity.

Coal supplied 24.6% in 2015. Only nuclear supplied more.

2024

In 2024 coal supplied 9.8%.

Solar supplied 11.1% in 2024. It supplied 2.9% in 2015.

Composition

Built from

The pieces scrolly chart renders or expects in its slots.

Atoms

2

Compares a value across categories with bars from a zero baseline.

A readable block of narration at a 45-75 character measure, for the text between charts.

Used in

1 template uses scrolly chart.

Templates

1

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.

Installation

$ pnpm dlx shadcn@latest add @insightcharts/scrolly-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 { ScrollyChart } from "insightcharts";

Examples

Steps mode (buttons), cumulative patches

EU electricity generation by source, 2015

Share of EU electricity generation, %

Source: Ember, European Electricity Review 2025 · Rounded, approximate figures for illustration

The chart shows each source's share in 2015.

Swipe mode

EU electricity generation by source, 2015

Share of EU electricity generation, %

Source: Ember, European Electricity Review 2025 · Rounded, approximate figures for illustration
2015

In 2015 nuclear and coal together supplied 51.7% of the EU's electricity.

Props

PropTypeDefaultDescription
chartrequiredInsightSpecThe base chart spec: { type, data, x, y, ... }. Give it a title; steps may replace it.
stepsrequired{ content, id?, label?, ...chart props }[]The steps in order. content is a short paragraph that says plainly what the chart now shows (**bold** works). Every other key is a chart prop merged over chart for that step: highlight, transform, annotations, x, y, title… Use null to remove a base prop. Change one thing per step.
cumulativebooleanfalseEach step's patch builds on the previous steps instead of on the base spec alone.
scrollMode"auto" | "scroll" | "swipe" | "steps""auto"scroll pins the chart while steps scroll past; swipe makes steps swipeable cards; steps shows previous/next buttons; auto uses scroll, or swipe on narrow touch screens. (Named scrollMode because mode is the colour mode.)
side"left" | "right""left"Side of the text column in scroll mode. Narrow containers overlay the text on the chart.
stickyTopnumber | string0Offset from the top of the viewport at which the chart pins; set it to the height of a fixed header.
stepHeightstring"80vh"Scroll distance per step, as a CSS length.
onStepChange(index) => voidCalled when the active step changes.
titlestringHeading above the whole story.
subtitlestringLine under the heading.
sourcestringShown after the last step as "Source: ...". Prefer the chart's own source, which stays visible.
notestringMethod note or caveat.
themeThemeInputTheme override, passed on to the chart and the step cards.
mode"auto" | "system" | "light" | "dark""auto"Colour mode.