Dashral Pro is on the wayGet 30% off at launch

Dashral

Line Chart

Values over time as lines, with dashed ones for a target or last year; the axis fits the values so changes show. Plain SVG.

$ pnpm dlx shadcn@latest add https://dashral.com/r/line-chart.json

Installation

$ pnpm dlx shadcn@latest add https://dashral.com/r/line-chart.json

Adds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:

components.json
{
  "registries": {
    "@dashral": "https://dashral.com/r/{name}.json"
  }
}

Then add components by name:

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

Usage

example.tsx
import { LineChart } from "@/components/dashral/line-chart"

<LineChart
  data={[
    { day: "2026-10-20", visitors: 1240 },
    { day: "2026-10-21", visitors: 1380 },
    { day: "2026-10-22", visitors: 1310 },
  ]}
  index="day"
  series={[{ key: "visitors", label: "Visitors" }]}
  timeFormat={{ month: "short", day: "numeric" }}
  aria-label="Visitors by day"
/>

Examples

Revenue by plan

Several lines with a legend; startAtZero when the size of each matters.

  • Pro
  • Team
  • Starter

Against a target

A dashed target, straight segments (curve="linear") and a dot on every week.

Weekly signups

Ahead of target for three weeks running

  • Signups
  • Target

API reference

LineChart

Also takes every prop of <div>(opens in a new tab).

PropTypeDefault
dataRecord<string, string | number>[]

The rows, in order along the x axis. Required.

—
indexstring

The key for the x axis: a label, or a timestamp or ISO date with timeFormat. Required.

—
series{ key, label, color?, dashed? }[]

What to draw, in order; colors default to --chart-1 … --chart-5. Required.

—
curve"smooth" | "linear" | "step"

Smooth never bends past a value it didn't have.

"smooth"
showDotsboolean

A dot on every point, not only the one being read.

false
startAtZeroboolean

Starts the axis at zero; by default it fits the values, so changes show.

false
heightnumber

In pixels, axes included; the width follows the container.

260
formatOptionsIntl.NumberFormatOptions

How values are written in the tooltip, e.g. { style: "currency", currency: "USD" }; the axis writes them compactly.

—
timeFormatIntl.DateTimeFormatOptions

Reads the index as dates and writes them like this.

—
showLegendbooleanmore than one series
showGridboolean

Dashed lines at the axis values.

true
showYAxisboolean

The values along the left.

true
localestringthe LocaleProvider's
aria-labelstring

What the chart shows, e.g. “Revenue by month”.

"Trend from … to …"
classNames{ legend, tooltip }—

Keyboard

KeysAction
TabFocus the chart
←or→Read the previous or next point
HomeorEndThe first or last point
EscStop reading

Accessibility

  • A group named by your label (by default, how the first series went); the point you move to with the arrow keys is read out with every series' value.
  • The x axis runs left to right in every language, as on most charts; the legend and tooltip follow the page's direction.
  • The tooltip lists every series by name, so nothing depends on telling colors apart.

Motion

  • Draws in from the left when it first shows; new data moves the lines to their new shape (in browsers that animate SVG paths). Instant with reduced motion.