UI.MD

Chart

One series over time with a frame: a labelled scale with gridlines, labelled periods, a dashed target line, gaps for unknown values, and each value on hover.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/chart.json

Usage

import { Chart } from "@/components/ui/chart"

Examples

Default

A line for a level over time. The newest point carries a dot; hover any column for its value.

Followers
540
+28 this week

Bars with a goal

Bars for a count per period, measured from zero. The dashed line is the goal, named in the key above the plot.

Sign-ups per week
39
Goal: 35 a week

Unknown values

A day with no data is bridged with a dotted line instead of dropped to zero, so a missed export never reads as a crash.

Conversion
24.0%
Target: 25%

API Reference

PropTypeDefaultDescription
data*{ label: string; value: number | null }[]-The series, oldest first. A null value is a gap.
label*string-Accessible name: what the series is.
type"line" | "bar""line"bar for a count per period, measured from zero. line for a level over time.
reference{ value: number; label: string } | null-A dashed target or milestone line, named in a key above the plot.
format(value: number) => stringgrouped integerFormats values on the axis and in the hover readout.
data*{ label: string; value: number | null }[]The series, oldest first. A null value is a gap.
label*stringAccessible name: what the series is.
type"line" | "bar" = "line"bar for a count per period, measured from zero. line for a level over time.
reference{ value: number; label: string } | nullA dashed target or milestone line, named in a key above the plot.
format(value: number) => string = grouped integerFormats values on the axis and in the hover readout.