Published
Edited
May 21, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
color: {
type: "linear",
range: ["steelblue", "orange"]
},
x: {
grid: true,
label: "Floor →"
},
y: {
label: "↑ Stops"
},
marks: [
Plot.line(data, {
x: "floor",
y: "buttons",
marker: "circle",
stroke: 0
}),
Plot.text(data, {
filter: (d) => d.floor % 5 == 0,
x: "floor",
y: "buttons",
text: (d) =>
`${d.buttons.toLocaleString(undefined, { minimumFractionDigits: 3 })}`,
dy: -15
})
]
})
Insert cell
Insert cell
function elevator(n) {
if (n == 2) return 1;
if (n == 1) return 0;

let sum = 0;
for (let i = 1; i < n; i++) {
sum += elevator(i);
}
return 1 + sum / (n - 1);
}
Insert cell
Array.from({ length: 20 }, (x, i) => i)
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