Published
Edited
May 7, 2021
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 Measure
Divide Series
Multiply SeriesMultiplication and Division by Similar TrianglesRecursive 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
Insert cell
Insert cell
seriesA = (regen,
getRandomWalk(
n,
randWalkStart,
d3.randomNormal(randWalkMean, randWalkStDev)
))
Insert cell
seriesB = (regen,
getRandomWalk(
n,
randWalkStart + 0.1,
d3.randomNormal(randWalkMean, randWalkStDev)
))

Insert cell
xAccessor = d => d[0]
Insert cell
yAccessor = d => d[1]
Insert cell
Insert cell
series = [seriesA, seriesB].map(serie => serie.map(normalize))
Insert cell
productSeries = d3.zip(...series).map(([a, b]) => [a[0], a[1] / b[1]])
Insert cell
partialProduct = i =>
productSeries.slice(0, i + 1).concat(series[0].slice(i + 1))
Insert cell
data = d3.zip(...series).map(([a, b]) => ({
x: a[0],
a: a[1],
b: b[1],
A: [0, y(a[1]) - y(0)],
B: [0, y(b[1]) - y(0)]
}))
Insert cell
normalize = (d, i) => [xAccessor(d, i), yAccessor(d, i)]
Insert cell
Insert cell
xExtent = d3.extent(series.flatMap(s => s.map(d => d[0])))
Insert cell
yExtent = d3.extent([
0,
1,
...series.flatMap(s => s.map(d => d[1])),
...productSeries.map(d => d[1])
])
Insert cell
x = d3.scaleLinear(xExtent, [margin.left, width - margin.right])
Insert cell
y = d3.scaleLinear(yExtent, [height - margin.bottom, margin.top])
Insert cell
margin = ({ top: 10, right: 90, bottom: 20, left: 25 })
Insert cell
height = width / 2
Insert cell
Insert cell
xAxis = g => g.attr("transform", `translate(0, ${y(0)})`).call(d3.axisBottom(x))
Insert cell
yAxis = g =>
g.attr("transform", `translate(${x.range()[0]})`).call(d3.axisLeft(y))
Insert cell
dataLine = d3
.line()
.x((d, i) => x(d[0]))
.y((d, i) => y(d[1]))
Insert cell
line = d3
.line()
.x(d => d[0])
.y(d => d[1])
Insert cell
l = p => path => path.attr("d", line([o, p]))
Insert cell
pt = ([px, py]) => circle => circle.attr("cx", px).attr("cy", py)
Insert cell
o = [0, 0]
Insert cell
unity = [0, y(1) - y(0)]
Insert cell
Insert cell
renderPoint = function(d, i) {
const sel = d3.select(this);

d.l1 = sel
.append("path")
.attr("stroke", girderColor)
.call(l(unity));
d.pt1 = sel
.append("circle")
.attr("fill", girderColor)
.attr("r", ptR)
.call(pt(unity));

d.l1AB = sel
.append("path")
.attr("stroke", girderColor)
.attr("d", line([d.A, d.B]));
d.lAB = sel
.append("path")
.attr("stroke", girderColor)
.call(l(d.A));
d.ptAB = sel
.append("circle")
.attr("fill", girderColor)
.attr("r", ptR)
.call(pt(d.A));

d.lA = sel
.append("path")
.attr("stroke", color(null, 0))
.call(l(d.A));
d.lB = sel
.append("path")
.attr("stroke", color(null, 1))
.call(l(d.B));
d.ptA = sel
.append("circle")
.attr("fill", color(null, 0))
.attr("r", ptR)
.call(pt(d.A));
d.ptB = sel
.append("circle")
.attr("fill", color(null, 1))
.attr("r", ptR)
.call(pt(d.B));
}
Insert cell
color = (d, i) => (i ? "steelblue" : "orange")
Insert cell
girderColor = "#ccc"
Insert cell
duration = speed
Insert cell
delay = speed
Insert cell
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
d3 = require("d3")
Insert cell
import { getRandomWalk } from "@tophtucker/scrapbook"
Insert cell
import { slider } from "@jashkenas/inputs"
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more