Controls

Threshold Chart

Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Threshold Chart
2of 30 days would have alerted

p95 latency in ms, last 30 days
dayp95
Oct 1180
Oct 2244
Oct 3205
Oct 4188
Oct 5400
Oct 6276
Oct 7205
Oct 8199
Oct 9251
Oct 10212
Oct 11132
Oct 12150
Oct 13185
Oct 14263
Oct 1577
Oct 16137
Oct 17166
Oct 18111
Oct 19120
Oct 20206
Oct 21214
Oct 22167
Oct 23350
Oct 24279
Oct 25241
Oct 26194
Oct 27241
Oct 28262
Oct 29182
Oct 30147

Threshold Chart

Bars with a draggable alert line that marks every period crossing it.

Installation

npx shadcn@latest add ikislay/pixel-ui/threshold-chart

How to use

import { 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} />
}

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
data*
Record<string, string | number>[]

One object per period along the x axis.

index*
string

The key in each object that labels the x axis.

value*
string

The key that holds each bar's value.

valueLabel
string

Names the value in the tooltip. Defaults to the key.

threshold
number

The line's value, when you control it.

defaultThreshold
number

Where the line starts when uncontrolled. Defaults to 70% of the highest bar.

onThresholdChange
(threshold: number) => void

Called each time the line lands on a new step.

direction
"above""below"

Whether bars over the line or under it count.

step
number

What the line snaps to. Defaults to about a fortieth of the scale, rounded.

caption
string

The words after the count. Defaults to "over the line" or "under the line".

label*
string

Names the chart for screen readers and captions its data table.

height
number

Height in pixels. The width fills the parent.

format
(value: number) => string

Formats values wherever the chart shows them. Defaults to short numbers like 12.4K.

color
string

Any CSS color for the bars below the line.

className
string

Merged onto the root element.