Public
Edited
Sep 23, 2024
11 stars
Insert cell
Insert cell
d3.pairs([1, 2, 3, 4])
Insert cell
Insert cell
d3.pairs([])
Insert cell
d3.pairs([1])
Insert cell
Insert cell
prices = [100, 110, 112, 115, 123, 122, 127]
Insert cell
changes = d3.pairs(prices, (a, b) => (b - a) / a)
Insert cell
Insert cell
Insert cell
html`<svg width=640 height=120 stroke=black>
<marker id=arrow markerHeight=10 markerWidth=10 refX=9 refY=3 orient=auto>
<path d="M0,0L9,3L0,6Z" />
</marker>
${d3.pairs(
Array.from(
{length: 20},
(_, i) => [i / 10 * 640, Math.random() * 120]
),
([x1, y1], [x2, y2]) => svg`<line
marker-end=url(${location}#arrow)
x1=${x1} y1=${y1}
x2=${x2} y2=${y2}>`
)}
</svg>`
Insert cell
Insert cell
rsp = ["rock", "scissors", "paper"]
Insert cell
d3.pairs(rsp.concat(rsp[0]), (a, b) => `${a} beats ${b}`)
Insert cell
Insert cell
d3.pairs(
"🌝🌝🌝🌝🌝🌝🌝🌝🌚🌚🌚🌚🌚🌚🌝🌚🌚🌚🌚🌚🌚🌝🌝🌝🌝🌝🌚🌚🌚🌚🌝🌝",
d3.descending
)
Insert cell
Insert cell
differences = {
const numbers = Float64Array.from({length: 100000}, Math.random);
return d3.pairs(numbers, (a, b) => a - b);
}
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more