Published
Edited
Mar 31, 2022
6 stars
Food clockDisambiguating selection in a 2D treePerceptually more-uniform diverging color scatterplotDays since a U.S. President was last shotSingle-serving sitesDo you feel old?Dynamic scales deprive dashboards of institutional memoryNesting chevron pillsColumnar group byDe Moivre by generatorsShowing ESPN Receiver Tracking Metrics using weighted radar chartsCombine consecutive stringsDollar spectrumThe Feedback BathtubIs Visnu’s hex random?Dual axes are a great way to show correlation 🔥Promise.raceHealthcare plan payoff curvePlot image beeswarmGenerations on Google TrendsFor i of myriadChatterjee correlationChecking invariance of round trip-0 and 0Norms and central tendencyDisordering ULsData-driven table sort iconPlot: weather with sunrise and sunsetRecreating Östling’s regression visualizationsMixing knowledge and random guessesHow many five digit numbers are prime?Warping gridspaceSampling moodLow IDsTesting for OmicronAll Too WellDistance from square root to nearest factorSuper BogosortParrots of Telegraph HillNudibranch sightingsDecimal watershedsFirst Ladies of the United StatesEval-in-PlaceClassic Research in Data VisualizationResponsive PrettierObsv, obvsGenerating All Natural NumbersDaily Café PickerConcentration of MeasureDivide SeriesMultiply Series
Multiplication and Division by Similar Triangles
Recursive typed table (sketch!)Lorenz CurveThe “Select cells” buttonRecursive viewof testBubble Map RaceSensitivity and Specificity (sketch)Reactive transition sketchHow to crash ObservableSpilhaus World TourSimpson’s paradox: CalendarsThe Cauchy DistributionEmoji frequenciesThe Man Comes AroundNot what I meant to doSVG numeral sketchesRSAMandelbrot’s binomial time bending??Re: “Can Moons Have Moons?”Continuous cursorParenthesis matching with vertical offsetsA filter icon that shows filtering instead of funnelingFlag of the Popular VoteFlag of the Popular VoteFlag of the Popular VoteTrailing zeroes in factorialsBitcoin fractal bubbles (animated)Bitcoin fractal bubbles
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
o = [0, 0]
Insert cell
basisA = [1, 0]
Insert cell
basisB = rotate([1, 0], angle)
Insert cell
lines = [
{ d: [basisA, multiply(basisB, d.b)], color: "#aaa" },
{ d: [multiply(basisA, d.a), multiply(basisB, d.c)], color: "#aaa" },
{ d: [o, basisA], color: "black" },
{ d: [o, multiply(basisB, d.c)], color: cColor },
{ d: [o, multiply(basisA, d.a)], color: aColor },
{ d: [o, multiply(basisB, d.b)], color: bColor }
]
Insert cell
scale = d3.scaleLinear([0, 1], [0, 100])
Insert cell
margin = 150
Insert cell
extent = {
const [a, b] = d3.extent(lines.flatMap(d => d.d.flatMap(d => d.map(scale))));
return [a - margin, b + margin];
}
Insert cell
viewBox = `${extent[0]} ${extent[0]}
${extent[1] - extent[0]} ${extent[1] - extent[0]}`
Insert cell
diagonal = Math.sqrt((extent[1] - extent[0]) ** 2 * 2)
Insert cell
aColor = "rgb(223, 0, 48)"
Insert cell
bColor = "rgb(100, 149, 237)"
Insert cell
cColor = "rgb(40, 174, 123)"
Insert cell
axis = basis =>
svg`<g>
<path
d="${line([multiply(basis, -diagonal), multiply(basis, diagonal)])}"
stroke="#ccc"
fill="none" />
${d3.range(...extent.map(d => Math.round(scale.invert(d)))).map(
d => svg`<text
text-anchor="middle"
fill="black"
font-weight="bold"
stroke="white"
stroke-width="0.7"
dy="0.31em"
transform="translate(${multiply(basis, d)
.map(scale)
.join(", ")})"
>
${d}
</text>`
)}
</g>`
Insert cell
labels = [
{ label: "1", color: "black", position: multiply(basisA, 1) },
{
label: "a",
color: aColor,
position: multiply(basisA, d.a)
},
{
label: d.type === "mult" ? "b" : "c ÷ a",
color: bColor,
position: multiply(basisB, d.b)
},
{
label: d.type === "mult" ? "a × b" : "c",
color: cColor,
position: multiply(basisB, d.c)
}
]
Insert cell
line = d3
.line()
.x(d => scale(d[0]))
.y(d => scale(d[1]))
Insert cell
// https://stackoverflow.com/a/2259502/120290
rotate = ([px, py], angle, [cx, cy] = [0, 0]) => {
const s = Math.sin(angle);
const c = Math.cos(angle);

// translate point back to origin
px -= cx;
py -= cy;

// rotate point
const xnew = px * c - py * s;
const ynew = px * s + py * c;

// translate point back
px = xnew + cx;
py = ynew + cy;
return [px, py];
}
Insert cell
multiply = ([px, py], coef) => [coef * px, coef * py]
Insert cell
Insert cell
import { radio } from "@jashkenas/inputs"
Insert cell
import { note } from "@tophtucker/scrapbook"
Insert cell
import { tweet } from "@mbostock/tweet"
Insert cell
d3 = require("d3@6")
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