Simulates prefers-reduced-motion for the demo. Off follows your system setting.
Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.
1
| day | p95 |
|---|---|
| Oct 1 | 180 |
| Oct 2 | 244 |
| Oct 3 | 205 |
| Oct 4 | 188 |
| Oct 5 | 400 |
| Oct 6 | 276 |
| Oct 7 | 205 |
| Oct 8 | 199 |
| Oct 9 | 251 |
| Oct 10 | 212 |
| Oct 11 | 132 |
| Oct 12 | 150 |
| Oct 13 | 185 |
| Oct 14 | 263 |
| Oct 15 | 77 |
| Oct 16 | 137 |
| Oct 17 | 166 |
| Oct 18 | 111 |
| Oct 19 | 120 |
| Oct 20 | 206 |
| Oct 21 | 214 |
| Oct 22 | 167 |
| Oct 23 | 350 |
| Oct 24 | 279 |
| Oct 25 | 241 |
| Oct 26 | 194 |
| Oct 27 | 241 |
| Oct 28 | 262 |
| Oct 29 | 182 |
| Oct 30 | 147 |
Bars with a draggable alert line that marks every period crossing it.
npx shadcn@latest add ikislay/pixel-ui/threshold-chartimport { ThresholdChart } from "@/components/ui/threshold-chart"const data = [{ day: "Mon", p95: 180 },{ day: "Tue", p95: 320 },{ day: "Wed", p95: 210 },]export function Demo() {return <ThresholdChart label="p95 latency" data={data} index="day" value="p95" defaultThreshold={250} />}
1// Loading…
Options you can pass to customize this component.
data*Record<string, string | number>[]One object per period along the x axis.
index*stringThe key in each object that labels the x axis.
value*stringThe key that holds each bar's value.
valueLabelstringNames the value in the tooltip. Defaults to the key.
thresholdnumberThe line's value, when you control it.
defaultThresholdnumberWhere the line starts when uncontrolled. Defaults to 70% of the highest bar.
onThresholdChange(threshold: number) => voidCalled each time the line lands on a new step.
direction"above""below"Whether bars over the line or under it count.
stepnumberWhat the line snaps to. Defaults to about a fortieth of the scale, rounded.
captionstringThe words after the count. Defaults to "over the line" or "under the line".
label*stringNames the chart for screen readers and captions its data table.
heightnumberHeight in pixels. The width fills the parent.
format(value: number) => stringFormats values wherever the chart shows them. Defaults to short numbers like 12.4K.
colorstringAny CSS color for the bars below the line.
classNamestringMerged onto the root element.