Public
Edited
May 24, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
format = d3.format(",d")
Insert cell
name = (d) => (d.id === "/" ? "All names" : d?.id?.replaceAll("/", "") || "")
Insert cell
w = width < 500 ? width : Math.floor(width / 3)
Insert cell
height = width //width < 500 ? (width * 2) / 3 : Math.floor(width / 3)
Insert cell
import { data } from "@mkfreeman/baby-name-treemap"
Insert cell
Insert cell
candian_baby_names.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
color = d3
.scaleLinear()
.domain([0, pack(data).height])
.range(["hsl(152,80%,80%)", "hsl(228,30%,40%)"])
.interpolate(d3.interpolateHcl)
Insert cell
pack = (data) => d3.pack().size([width, height]).padding(3)(data)
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