uimaxxer

Line chart

An area chart you scrub with a pointer or a finger. The crosshair snaps from day to day, the figure above rolls to each value, and the rest of the line dims behind you.

npx shadcn@latest add @uimaxxer/line-chart
Pro
PasskeysSpend

Spend

Revenue, 1 to 29 Nov

$39,741

+14.9% vs 4 Oct to 1 Nov

1 Nov29 Nov
1 to 29 Nov4 Oct to 1 Nov

Usage

import { LineChart } from "@/components/ui/line-chart"

<LineChart
  title="Revenue, 1 to 29 Nov"
  compareLabel="4 Oct to 1 Nov"
  data={days}
  format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
/>

Props

PropTypeDefaultWhat it does
dataLinePoint[]{ label, tick?, value, compare?, compareName? }. compare draws the second, quieter line; compareName labels that point.
titlestringWhat the chart measures. Shown above the figure when nothing is scrubbed.
totalnumberThe resting figure. Defaults to the sum of the values.
compareTotalnumberThe comparison total. Defaults to the sum of the compare values.
compareLabelstringNames the comparison, as in vs October. Also the legend.
seriesLabelstring"This period"Legend name for the main line.
formatIntl.NumberFormatOptionsHow every figure is written. Pass a stable object.
heightnumber200Plot height in px. The width follows the container.
size"md" | "lg""md"lg sets a 56px figure and heavier marks, for a feature moment.

Keyboard

← →
Previous or next point
Home / End
First or last point
Esc
Back to the total

Accessibility

  • The plot is a role=slider over the points; aria-valuetext reads the date and the value.
  • Hover scrubs with a mouse; on touch, press and slide. Vertical swipes still scroll the page.
  • One accent and ink, no gridlines; the comparison is told apart by weight and a legend, not by colour alone.
  • Reduced motion skips the draw-in and snaps the crosshair.