Published
Edited
Feb 24, 2021
Insert cell
md`# The difference between \`d3.rollup\` and \`d3.group\``
Insert cell
d3 = require("d3@6")
Insert cell
Insert cell
data = [
{name: "jim", amount: "34.0", date: "11/12/2015"},
{name: "carl", amount: "120.11", date: "11/12/2015"},
{name: "stacy", amount: "12.01", date: "01/04/2016"},
{name: "stacy", amount: "34.05", date: "01/05/2016"}
]
Insert cell
Insert cell
Insert cell
d3.group(data, d => d.name)
Insert cell
d3.group(data, d => d.date)
Insert cell
Insert cell
d3.group(data, d => d.name, d => d.date)
Insert cell
md`
Sorry, I don't quite understand \`d3.rollup\` yet.
`
Insert cell
d3.rollup(data, ([d]) => d.amount, d => d.name)
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