Viz Kit
A collection of custom, minimalist D3 and Observable Plot components designed for clarity, clean typography, and easy reuse across my Observable notebooks and projects.
Funnel
A D3 funnel chart that visualizes sequential drop-off across ordered stages-commonly used for product onboarding, checkout flows, and marketing or sales pipelines.
Usage
Pass an array of objects ordered top to bottom, with one row per stage. stage sets the metric label, and value (required) specifies the metric that sizes each bar.
import {funnelChart} from "./components/funnel.js";
const funnel = [
{stage: "Visits", users: 10000},
{stage: "Signups", users: 3400},
{stage: "Activations", users: 1450},
{stage: "Purchases", users: 520}
];
funnelChart([...funnel], {value: "users", align: "left"})
funnelChart([...funnel], {
value: "users",
valueLabel: "users",
colors: ["#6366f1", "#8b5cf6", "#ec4899"]
})
Options
| Option | Default | Description |
|---|---|---|
value |
required | Name of the metric column that sizes the bars |
stage |
"stage" |
Name of the dimension column that labels each step. Throws an error listing available columns if not found |
align |
"center" |
"center" or "left". When "left", step-to-step percentages line up in a single column |
colors |
5 built-in | Bar colors, repeats if there are more stages |
valueLabel |
"" |
Text after the number in the tooltip |
bandColor |
"#eeeeee" |
Connector fill |
bandOpacity |
1 |
Connector opacity |
pctFormat |
d3.format(".0%") |
Step-to-step % format |
valueFormat |
d3.format(",") |
Volume format |
width |
900 |
Chart width in px (scales to container) |
barHeight |
56 |
Height of each bar in px |
gap |
44 |
Vertical space between bars, holds the connector and % label |
margin |
{top: 16, right: 200, bottom: 16, left: 16} |
Chart margins; right leaves room for the labels |
animate |
true |
Animate on load |
duration |
700 |
Bar animation duration in ms |