Pacing chart
Cumulative month-to-date actual against plan with a run-rate projection.
Work remaining (or done) against the ideal pace, with the finish projected from the pace so far.
<BurndownChart />A burndown chart shows the work left in a sprint or project, day by day, against the ideal straight line to zero. The question it answers is simple: will we finish on time?
Pass one row per day of the whole period and leave the future days empty. The chart draws the ideal line, the work so far, and a dashed projection from the average pace to date. A line at the top says it plainly: on pace to finish by a given day, or how much will be left at the end. Hover any day to see how far ahead or behind the ideal you were.
When scope changes mid-sprint, a burndown hides it. Use the burnup form instead: pass completed work and total scope, and the chart draws both, so added work is visible as a step in the scope line. For money against a monthly plan, use a pacing chart.
Burndown chart is free under the MIT license.
pnpm dlx shadcn@latest add https://chartslibraryui.com/r/burndown-chart.jsonInstalls the chart, its dependencies and the shared core into your components folder.
Then import the theme once: import "@/components/charts/core/charts.css" Installation guide
Building with an AI tool? Download the burndown chart for your AI tool and attach it to Claude, ChatGPT, Lovable or Cursor. No terminal needed. How it works
import { BurndownChart } from "@/components/charts/burndown-chart";
import { sprintBurndown } from "./sample-data";
export function Example() {
return (
<BurndownChart
title="Sprint 14 will end with about 28 points left at this pace"
subtitle="Story points remaining by working day, two-week sprint"
data={sprintBurndown}
x="day"
remaining="remaining"
/>
);
}
One row per day of the whole period with an x key and remaining (burndown) or completed (burnup) work; future days left empty. Optional scope key.
[{ day: "Mon 1", remaining: 52 }, ..., { day: "Fri 12", remaining: null }]Missing values are null. Invalid values make the chart say what’s wrong instead of drawing a misleading picture. How charts handle bad data
Every chart also accepts the shared frame props: title, subtitle, source, height, mode, toolbar. Common API
export interface BurndownChartProps extends FrameProps {
/** One row per day (or period) of the whole sprint or project, with future rows left empty. */
data: Row[];
/** Key of the x value (day, date or sprint label). */
x: string;
/** Burndown: key of the work remaining. */
remaining?: string;
/** Burnup: key of the work completed so far (cumulative). Use instead of `remaining`. */
completed?: string;
/** Key of the total scope per period, when scope changes. Drawn as a step line; required for a burnup. */
scope?: string;
/** Number format for the work. Default "integer". */
format?: FormatInput;
/** What the work is counted in, e.g. "points" or "tasks". Used in the callout. Default "points". */
unit?: string;
/** Draw the ideal line from the start to the end. Default true. */
ideal?: boolean;
/** Project the finish from the pace so far. Default true. */
projection?: boolean;
}Installs burndown-chart.tsx and the shared core/ (12 files).
"use client";
import { useMemo, type PointerEvent } from "react";
import { PeriodShade, XLabels, YGrid, axisWidth } from "./core/axis";
import { color as tokens } from "./core/color";
import { checkRows, column, type Issue, type Row } from "./core/data";
import { formatValue, tickFormatter, type FormatInput } from "./core/format";
import { ChartFrame, ChartTooltip, localPoint, useActiveIndex, type FrameProps, type LegendItem, type TooltipRow } from "./core/frame";
import { linePath, type MaybePoint } from "./core/path";
import { linearScale, nearestIndex, pointScale, valueDomain } from "./core/scale";
/** "1 point", "2 points": drops a trailing s for exactly one unit. */
const unitOf = (unit: string) => (n: number | null) => (n !== null && Math.round(n) === 1 && unit.endsWith("s") ? unit.slice(0, -1) : unit);
export interface BurndownChartProps extends FrameProps {
/** One row per day (or period) of the whole sprint or project, with future rows left empty. */
data: Row[];
/** Key of the x value (day, date or sprint label). */
x: string;
/** Burndown: key of the work remaining. */
remaining?: string;
/** Burnup: key of the work completed so far (cumulative). Use instead of `remaining`. */
completed?: string;
/** Key of the total scope per period, when scope changes. Drawn as a step line; required for a burnup. */
scope?: string;
/** Number format for the work. Default "integer". */
format?: FormatInput;
/** What the work is counted in, e.g. "points" or "tasks". Used in the callout. Default "points". */
unit?: string;
/** Draw the ideal line from the start to the end. Default true. */
ideal?: boolean;
/** Project the finish from the pace so far. Default true. */
projection?: boolean;
}
/**
* Work remaining (burndown) or completed (burnup) against the ideal pace, with a projection from the pace so far
* and the day the work will be done. Answers "will we finish on time?" while there is still time to act.
*/
export function BurndownChart({ data, x, remaining, completed, scope, format = "integer", unit = "points", ideal = true, projection = true, height = 300, ...frame }: BurndownChartProps) {
const unitFor = unitOf(unit);
const mode: "down" | "up" = remaining ? "down" : "up";
const workKey = remaining ?? completed ?? "";
const prep = useMemo(() => {
if (!workKey) return { issues: [{ level: "error", message: "Pass `remaining` (burndown) or `completed` (burnup)." }] as Issue[], rows: [] as Row[], work: [], scopeV: [], idealV: [], proj: [], last: -1, finish: null as number | null, endLeft: null as number | null };
const keys = [workKey, ...(scope ? [scope] : [])];
const issues = checkRows(data, { xKey: x, valueKeys: keys, allowMissing: true }).filter((i) => !(i.level === "note" && /missing value/.test(i.message)));
const rows = Array.isArray(data) ? data : [];
const work = column(rows, workKey).values;
const scopeV = scope ? column(rows, scope).values : rows.map(() => null);
const n = rows.length;
const first = work.findIndex((v) => v !== null);
const last = work.reduce<number>((acc, v, i) => (v !== null ? i : acc), -1);
if (mode === "up" && !scope) issues.push({ level: "error", message: "A burnup needs `scope` (the total work) to measure against." });
const negative = work.filter((v) => v !== null && v < 0).length;
if (negative) issues.push({ level: "warning", message: `${negative} negative value(s) in "${workKey}"; work is usually counted from zero.` });
// total work at the start (burndown) or at the latest period (burnup)
const startTotal = mode === "down" ? (scopeV[first] ?? work[first] ?? null) : null;
const lastScope = scopeV.reduce<number | null>((acc, v) => (v !== null ? v : acc), null);
const idealV: (number | null)[] = rows.map((_, i) => {
if (first < 0 || n < 2) return null;
const t = (i - first) / Math.max(1, n - 1 - first);
if (i < first) return null;
if (mode === "down") return startTotal === null ? null : startTotal * (1 - t);
return lastScope === null ? null : lastScope * t;
});
const proj: (number | null)[] = rows.map(() => null);
let finish: number | null = null;
let endLeft: number | null = null;
if (first >= 0 && last > first) {
const target = mode === "down" ? 0 : (scopeV[last] ?? lastScope);
const pace = mode === "down" ? (work[first]! - work[last]!) / (last - first) : (work[last]! - work[first]!) / (last - first);
const gap = mode === "down" ? work[last]! - 0 : target === null ? null : target - work[last]!;
if (gap !== null && gap <= 0) finish = last;
else if (gap !== null && pace > 0) {
finish = last + gap / pace;
for (let i = last; i < n; i++) {
const v = mode === "down" ? work[last]! - pace * (i - last) : work[last]! + pace * (i - last);
proj[i] = mode === "down" ? Math.max(0, v) : target === null ? v : Math.min(target, v);
if ((mode === "down" && v <= 0) || (mode === "up" && target !== null && v >= target)) break;
}
if (finish > n - 1) endLeft = gap - pace * (n - 1 - last);
} else if (gap !== null) endLeft = gap;
}
return { issues, rows, work, scopeV, idealV, proj, last, finish, endLeft };
}, [data, x, workKey, scope, mode]);
const { rows, work, scopeV, idealV, proj, last, finish, endLeft } = prep;
const label = mode === "down" ? "Remaining" : "Completed";
const callout =
last < 0
? ""
: finish !== null && finish <= rows.length - 1
? `On pace to finish by ${String(rows[Math.min(rows.length - 1, Math.ceil(finish))]?.[x] ?? "")}`
: endLeft !== null
? `At this pace: ${formatValue(Math.max(0, endLeft), format)} ${unitFor(Math.max(0, endLeft))} left at the end`
: "";
const good = finish !== null && finish <= rows.length - 1;
const legend: LegendItem[] = [
{ key: "w", label, color: tokens.series(0), shape: "line" },
...(projection ? [{ key: "p", label: "Projection", color: tokens.series(0), shape: "dash" as const }] : []),
...(ideal ? [{ key: "i", label: "Ideal", color: tokens.context, shape: "dash" as const }] : []),
...(scope ? [{ key: "s", label: "Scope", color: tokens.ink2, shape: "line" as const }] : []),
];
const f = (v: unknown) => formatValue(v as number, format, { context: "table" });
const table = {
columns: [
{ key: "__x", label: x },
{ key: "w", label, align: "right" as const, format: f },
...(ideal ? [{ key: "i", label: "Ideal", align: "right" as const, format: f }] : []),
...(projection ? [{ key: "p", label: "Projection", align: "right" as const, format: f }] : []),
...(scope ? [{ key: "s", label: "Scope", align: "right" as const, format: f }] : []),
],
rows: rows.map((r, i) => ({ __x: r?.[x], w: work[i], i: idealV[i], p: proj[i], s: scopeV[i] })),
};
const summary = `${mode === "down" ? "Burndown" : "Burnup"} chart over ${rows.length} periods. ${
last >= 0 ? `${label} ${formatValue(work[last], format)} ${unitFor(work[last])} at ${String(rows[last]?.[x] ?? "")}.` : "No progress recorded yet."
} ${callout}.`;
return (
<ChartFrame {...frame} height={height} issues={prep.issues} table={table} summary={summary} legend={legend}>
{({ width }) => <Plot {...{ width, height, rows, x, work, scopeV, idealV: ideal ? idealV : rows.map(() => null), proj: projection ? proj : rows.map(() => null), last, format, label, callout: projection ? callout : "", good }} />}
</ChartFrame>
);
}
function Plot(p: {
width: number;
height: number;
rows: Row[];
x: string;
work: (number | null)[];
scopeV: (number | null)[];
idealV: (number | null)[];
proj: (number | null)[];
last: number;
format?: FormatInput;
label: string;
callout: string;
good: boolean;
}) {
const { width, height, rows } = p;
const n = rows.length;
const { active, setActive, keyProps } = useActiveIndex(n, { describe: (i) => ({ label: String(rows[i]?.[p.x] ?? ""), row: rows[i] }) });
const all = [...p.work, ...p.scopeV, ...p.idealV, ...p.proj].filter((v): v is number => v !== null);
const { domain, ticks } = valueDomain(all.length ? all : [0], { includeZero: true, ticks: Math.max(3, Math.floor(height / 55)) });
const ft = tickFormatter(p.format, ticks);
const left = axisWidth(ticks.map(ft));
const right = width - 10;
const top = 26;
const bottom = height - 24;
const y = linearScale(domain, [bottom, top]);
const ps = pointScale(n, [left, right], Math.min(12, (right - left) / Math.max(2, n) / 2));
const xs = rows.map((_, i) => ps(i));
const pts = (vals: (number | null)[]): MaybePoint[] => vals.map((v, i) => (v === null ? null : [xs[i], y(v)]));
const lastProj = p.proj.reduce<number>((acc, v, i) => (v !== null ? i : acc), -1);
const shadeFrom = p.last >= 0 && p.last < n - 1 && lastProj > p.last ? (xs[p.last] + xs[p.last + 1]) / 2 : null;
const onMove = (e: PointerEvent<SVGRectElement>) => setActive(nearestIndex(xs, localPoint(e).x + left));
const tip = (i: number): TooltipRow[] => {
const out: TooltipRow[] = [];
if (p.work[i] !== null) out.push({ label: p.label, value: formatValue(p.work[i], p.format, { context: "tooltip" }), color: tokens.series(0), shape: "line", strong: true });
if (p.proj[i] !== null && i > p.last) out.push({ label: "Projection", value: formatValue(p.proj[i], p.format, { context: "tooltip" }), color: tokens.series(0), shape: "dash" });
if (p.idealV[i] !== null) {
const ref = p.work[i];
const diff = ref !== null ? ref - p.idealV[i]! : null;
const behind = diff !== null && (p.label === "Remaining" ? diff > 0.5 : diff < -0.5);
const ahead = diff !== null && (p.label === "Remaining" ? diff < -0.5 : diff > 0.5);
out.push({
label: "Ideal",
value: formatValue(p.idealV[i], p.format, { context: "tooltip" }),
color: tokens.context,
shape: "dash",
note: diff === null ? undefined : behind ? `(${formatValue(Math.abs(diff), p.format)} behind)` : ahead ? `(${formatValue(Math.abs(diff), p.format)} ahead)` : "(on pace)",
});
}
if (p.scopeV[i] !== null) out.push({ label: "Scope", value: formatValue(p.scopeV[i], p.format, { context: "tooltip" }), color: tokens.ink2, shape: "line" });
return out;
};
return (
<>
<svg width={width} height={height} role="group" aria-roledescription="chart" aria-label="Burndown chart. Use arrow keys to read periods." {...keyProps}>
{shadeFrom !== null && <PeriodShade x0={shadeFrom} x1={right + 6} top={top - 4} bottom={bottom} />}
<YGrid ticks={ticks} y={y} x0={left} x1={right} format={ft} />
<XLabels positions={xs} labels={rows.map((r) => String(r?.[p.x] ?? ""))} y={bottom + 17} anchorEnds x0={left - 8} x1={width} />
{p.scopeV.some((v) => v !== null) && <path d={linePath(pts(p.scopeV), "step")} fill="none" style={{ stroke: tokens.ink2 }} strokeWidth={1.5} />}
<path d={linePath(pts(p.idealV))} fill="none" style={{ stroke: tokens.context }} strokeWidth={1.75} strokeDasharray="4 4" />
<path d={linePath(pts(p.work))} fill="none" style={{ stroke: tokens.series(0) }} strokeWidth={2.25} strokeLinejoin="round" strokeLinecap="round" />
<path d={linePath(pts(p.proj))} fill="none" style={{ stroke: tokens.series(0) }} strokeWidth={2} strokeDasharray="5 4" strokeLinecap="round" />
{p.last >= 0 && <circle cx={xs[p.last]} cy={y(p.work[p.last]!)} r={4.5} style={{ fill: tokens.series(0), stroke: "var(--clui-surface)" }} strokeWidth={2} />}
{p.callout && (
<text x={right} y={12} textAnchor="end" className="clui-label-strong clui-halo" style={{ fill: p.good ? "var(--clui-good-text)" : "var(--clui-bad-text)" }}>
{p.callout}
</text>
)}
{active !== null && <line x1={xs[active]} x2={xs[active]} y1={top} y2={bottom} style={{ stroke: "var(--clui-axis)" }} />}
<rect x={left} y={0} width={Math.max(0, right - left)} height={bottom} fill="transparent" onPointerMove={onMove} onPointerLeave={() => setActive(null)} />
</svg>
{active !== null && (
<ChartTooltip
x={xs[active]}
y={y(p.work[active] ?? p.proj[active] ?? p.idealV[active] ?? (domain[0] + domain[1]) / 2)}
width={width}
height={height}
data={{ title: String(rows[active]?.[p.x] ?? ""), rows: tip(active) }}
/>
)}
</>
);
}
Cumulative month-to-date actual against plan with a run-rate projection.
A project plan on a timeline, with progress, milestones and a today line.
Trends over time for one to four series, with gaps for missing data and marked forecasts.