Distribution
interlace-ui/distributionFreeComponent
One quantity spread across a fixed set of bins — hours of the day, days of the week, cohorts, buckets — with an optional REFERENCE distribution drawn over it.
Install it
npx shadcn@latest add https://ds.interlace.tools/r/distribution.jsonSource
1'use client';23import * as React from 'react';45// @interlace/distribution v1.1.0 — Interlace design system.6// Docs, props and live preview: https://ds.interlace.tools/c/distribution7// What changed since: https://ds.interlace.tools/c/distribution#history8// Generated banner — keep it, the upgrade diff reads this version.910/**11 * @interlace/ui — Distribution12 *13 * One quantity spread across a fixed set of bins — hours of the day, days of14 * the week, cohorts, buckets — with an optional REFERENCE distribution drawn15 * over it.16 *17 * ## Why this is not `TimeSeries` with three more props18 *19 * It was attempted that way first. Every part of `TimeSeries` is chronological20 * in a way that cannot be parameterised out:21 *22 * - its axis keys are `day(t)`, sorted — a calendar. Bins are NAMES, and23 * sorting `['Thu','Fri','Sat']` gives `['Fri','Sat','Thu']`, which is a24 * week that does not exist;25 * - a LINE asserts that the metric passed through every value between two26 * samples. Between "readers awake at 14:00" and "readers awake at 15:00"27 * there is nothing to pass through — the quantity is an aggregate OF the28 * bin, not a sample at an instant;29 * - `delta()` — first → last — is the sentence `TimeSeries` speaks, and on a30 * cyclical axis the first and last bins are neighbours. "Down 40% from31 * 00:00 to 23:00" is arithmetic performed on a circle.32 *33 * So the marks are BARS from a zero baseline (see `bandScales` for why the34 * axis cannot be truncated), the axis order is the caller's, and the summary35 * sentence answers where the peak is rather than which way it went.36 *37 * ## The reference is the whole point, and it shares one domain38 *39 * A distribution on its own answers "when did this happen". The question worth40 * asking is almost always "when did this happen *against what was available*"41 * — reading against readers awake, incidents against traffic, deploys against42 * working hours. The gap between the bars and the reference IS the finding.43 *44 * Both series therefore share ONE y domain, exactly as in `TimeSeries`, and for45 * the same reason: two axes let an author slide one against the other until46 * they cross where the argument needs them to. That means the reference must47 * be in the SAME unit as the bars — usually both as shares of their own48 * denominator ("% of the week's reading" vs "% of readers awake"). A reference49// … truncated
More from interlace-ui
All 140 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| A11y Startera11y-starter | interlace-ui | Components | Free | no deps | |
| Accordionaccordion | interlace-ui | Components | Free | no deps | |
| Alertalert | interlace-ui | Components | Free | no deps | |
| Alert Dialogalert-dialog | interlace-ui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | interlace-ui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | interlace-ui | Components | Free | no deps | |
| Animated Listanimated-list | interlace-ui | Components | Free | no deps | |
| Article Cardarticle-card | interlace-ui | Components | Free | no deps |
