Gap-Aware Line

A line chart that shows missing readings as gaps instead of drawing them as zero or smoothing over them.

StopsMissing readings drawn as zero

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/gap-aware-line.json

The files land in your project. They're yours to edit.

Usage

gap-aware-line-usage.tsx
import { GapAwareLine, type GapAwareDatum } from "@/components/ui/gap-aware-line"

<GapAwareLine label="Daily UPI payments, ₹ lakh" data={daily} />

What it catches

  • Missing readings drawn as a drop to zero
  • Gaps smoothed over into a false trend
  • A single reading between two gaps disappearing
  • Estimated or modelled values passed off as measured

Props

GapAwareLine props
PropTypeDefault
data* (required)

Readings in order.

GapAwareDatum[]—
label* (required)

Accessible name and caption.

string—
variant

"chart" has axes and a summary; "sparkline" is a compact inline trend.

"chart" | "sparkline""chart"
height

Plot height in px.

number—
format

Value format for axis, tooltip and table.

(value: number) => string(v) => compact.format(v)
defaultTable

Show the data table instead of the chart at first.

booleanfalse
gapText

Templates: `{from}`, `{to}`, `{count}`, `{gaps}` and `{estimated}` are filled in.

string"No data · {from}"
gapRangeText

Label for a gap spanning several readings.

string"No data · {from} – {to} ({count} readings)"
summaryText

Text summary read with the chart.

string"{gaps} · {estimated}. Breaks are missing data, not zero."
noDataLabel

Shown in the table for a missing reading.

string"No data"
estimatedLabel

Shown in the table for an estimated reading.

string"Estimated"
showTableLabel

Toggle text to show the data table.

string"Table"
showChartLabel

Toggle text to show the chart.

string"Chart"
valueHeader

Table header for the value column.

string"Value"
noteHeader

Table header for the note column.

string"Note"

* required. Also accepts the native props of <figure> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Chart is role=img with an aria-label that includes a text summary
  • Points are reachable by keyboard (Arrow keys, Home, End) and the active point is read out in a polite live region
  • A toggle (aria-pressed) swaps the chart for a captioned data table; the table stays available to screen readers when hidden
  • Estimated points differ by shape (hollow, dashed), not only colour

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Only null means missing; a real 0 is drawn as 0, so your data must distinguish them
  • Does not detect gaps in timestamps; pass a null for each missing slot
  • Not a general charting library: one series, no zoom

What it stops

Missing readings drawn as zero

Also known as

line chart · missing data · null values · time series · gaps · svg chart · monitoring · iot

Dependencies

Pairs well with