Search docs

Jump to any table example

Discord—

Shadcn Anomaly Investigation Table

Values against the ranges they were expected to stay in, with spikes and drops flagged. Expand any row for its last two weeks, and mark anomalies reviewed as you work through them. Pick an example.

Revenue, latency, conversion and other product metrics. A spike or drop reads as better or worse depending on the metric: more revenue is good news, more latency is not.

$ npx shadcn add https://www.shad-table.dev/r/anomaly-investigation-table.json
HistoryMetricTodayReview
Payment failuresCard paymentsSpike, high
110
API p95 latencyEU regionSpike, high
680 ms
Checkout conversionWebDrop, high
2.41%
Support ticketsBillingSpike, high
186
RevenueUnited StatesSpike, high
$60,960
Email open rateNewsletterDrop, medium
32.7%
SignupsOrganic searchDrop, medium
705
Refund rateAll ordersSpike, low
1.90%

8 of 8 anomalies left to review today.

How it works

1.Flagged by the expected range

Each metric comes with the range its model expected for today. Above it is a spike, below it a drop. How far outside, measured in half-widths of the range, sets the severity and the default sort, so the most unusual change is at the top whatever its units.

src/components/anomaly-investigation/anomalies.ts
export const kindOf = (p: Point): Kind =>
p.actual > p.high ? 'spike' : p.actual < p.low ? 'drop' : 'normal'

2.The range and the value side by side

The Expected range column draws the range as a bar with a dot where today landed, stretched to fit both, so a value far outside is still on screen. Spikes are orange and drops violet, here and in the chart, and every flag also says Spike or Drop in words. Whether the move is good depends on the metric: a revenue spike is better than usual, a latency spike worse.

src/components/anomaly-investigation/anomalies.ts
export const isGood = (m: Metric) =>
(kindOf(m.today) === 'spike') === (m.better === 'up')

3.Expand for the last two weeks

A row expands to fourteen days and today: the expected range as a band, what happened as a line, and every day outside the band as a dot. Hovering shows a day’s value. Beside it are the 7-day average, the same day last week and earlier days outside the range, which tell a one-off from a pattern. A hidden table carries the same numbers for screen readers.

src/components/anomaly-investigation/history-chart.tsx
<polygon points={band} className="fill-muted-foreground/12" />
<polyline points={line} className="stroke-foreground" strokeWidth={2} />

4.Filter, review, move on

Filter to spikes or drops, mark each anomaly reviewed as you go, and hide reviewed ones to work through a queue. When a reviewed row leaves the list, focus moves to the next row instead of getting lost.

src/components/anomaly-investigation/data-table.tsx
const i = ids.indexOf(id)
focusNext.current = ids.at(i + 1) ?? ids.at(i - 1) ?? null