Public
Edited
Apr 5, 2024
2 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
[
...d3.rollup(
data,
(v) => d3.sum(v, (d) => d.people),
(d) => d.year
)
].map((d) => ({ year: new Date(d[0], 1, 1), people: d[1] }))
Insert cell
Plot.plot({
width: width * 0.95,
marginLeft: 80,
// x: {
// tickFormat: "" // don’t show a comma for years
// },
marks: [
Plot.ruleY([0]),
Plot.dot(
[
...d3.rollup(
data,
(v) => d3.sum(v, (d) => d.people),
(d) => d.year
)
].map((d) => ({ year: new Date(d[0], 1, 1), people: d[1] })),
{
x: (d) => d["year"],
y: "people",
interval: "year",
tip: true,
title: (d, i) =>
[
"year = " + m(d.year).format("YYYY"),
"population = " + d.people.toLocaleString()
].join("\n")
}
)
]
})
Insert cell
data_filtrada
X
people
Y
Color
Size
Facet X
Facet Y
Mark
Auto
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
marginLeft: 100,
marks: [
Plot.rectY(
data_filtrada,
Plot.binX({ y: "count" }, { x: "people", tip: true })
),
Plot.ruleY([0])
]
})
Insert cell
m = require("moment@2.30.1/moment.js")
Insert cell
_.uniq( data.map((d) => d.year) )
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