Xzero UI
Pro library

Brush chart

A dense time series with an overview strip: drag a window to zoom, resize it by its handles, and read events in place.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/brush-chart
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/brush-chart

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { useState } from "react";
import { BrushChart } from "@/components/xzero/brush-chart/brush-chart";

export function ActiveUsers({ days }: { days: { date: number; value: number }[] }) {
  const [range, setRange] = useState<[number, number]>([days[days.length - 90].date, days[days.length - 1].date]);
  return <BrushChart data={days} label="Daily active users" unit="users" range={range} onRangeChange={setRange}
    annotations={[{ date: Date.UTC(2026, 2, 24), label: "v2", description: "Offline mode and shared spaces" }]} />;
}

API reference

BrushChart

A detailed time series with an overview strip. Drag the window to pan, its handles to resize, or across empty track to draw a new one; double click resets. Zoomed out, a seven point average and band replace the raw line.

PropTypeDefaultDescription
data (required){ date: Date | number; value: number }[]–Points in ascending time order.
label (required)string–Names the chart for assistive technology.
unitstring""Unit after values in the tooltip and table.
formatValue(value: number) => string–Formats values in the tooltip and table.
formatTick(value: number) => string–Formats the value axis. Defaults to a compact number.
formatDate(date: Date) => string–Formats dates in the tooltip and announcements.
annotations{ date: Date | number; label: string; description?: string }[][]Events drawn as markers on both charts; labels show where they fit.
range[number, number]–Controlled window as epoch milliseconds. A new value glides the window there.
defaultRange[number, number]–Initial window when uncontrolled. Defaults to the whole series.
onRangeChange(range: [number, number]) => void–Called while the window is dragged, resized, stepped, or reset.
minSpannumber7 daysSmallest window in milliseconds.
heightnumber240Main plot height in pixels.
overviewHeightnumber52Overview strip height in pixels.
emptyLabelstring"No data yet"Shown with fewer than two points.
classNamestring–Extra class on the figure.

Keyboard interactions

KeysAction
ArrowLeft / ArrowRight (plot)Moves the crosshair between points in view.
ArrowLeft / ArrowRight (window)Pans by a tenth of the window; Shift or PageUp and PageDown pan by half.
+ / - (window)Zooms in or out around the window's centre.
ArrowLeft / ArrowRight (handles)Moves that edge by one point; Shift moves by ten.
Home / EndMoves the window or edge to the start or end.
Escape / 0Resets the window to the whole series.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in charts

Guidance for AI tools

Brush chart: A dense time series with an overview strip: drag a window to zoom, resize it by its handles, and read events in place. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components