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.
npx shadcn@latest add @silicon-ui/brush-chartInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/brush-chartManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/brush-chart/brush-chart.tsx
- components/silicon-ui/brush-chart/brush-chart.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
data* | BrushChartDatum[] | — |
label*What is measured, such as "Daily active users". Names the chart for assistive technology. | string | — |
unitUnit after each value, such as "users". | string | "" |
formatValue | (value: number) => string | value => grouped.format(value) |
formatTickFormats the value axis. Defaults to a compact number, such as 12K. | (value: number) => string | value => compact.format(value) |
formatDateFormats a date in the tooltip and announcements. | (date: Date) => string | date => fullDate.format(date) |
annotationsEvents drawn as markers on both charts. | BrushChartAnnotation[] | [] |
rangeControlled window as [start, end] epoch milliseconds. A new value glides the window there. | [number, number] | — |
defaultRangeInitial window when uncontrolled. Defaults to the whole series. | [number, number] | — |
onRangeChangeCalled while the window is dragged, resized, stepped, or reset. | (range: [number, number]) => void | — |
minSpanSmallest window in milliseconds. Defaults to seven days. | number | 7 * DAY |
heightMain plot height in pixels. | number | 240 |
overviewHeightOverview strip height in pixels. | number | 52 |
emptyLabel | string | "No data yet" |
ref | Ref<HTMLElement> | — |
className | string | — |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokens