Published
Edited
Oct 11, 2021
7 stars
Also listed in…
Fil’s plots
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = books.flatMap((book) =>
d3
.utcDays(
d3.isoParse(book.start),
// 🌶 add 24hrs to the end date, in case a book is read in a single day (end==start).
24 * 3600 * 1000 + +d3.isoParse(book.stop)
)
.map((date) => ({ ...book, date }))
)
Insert cell
Insert cell
Plot.rectY(
data,
Plot.stackY({
x: "date",
interval: d3.utcDay, // transforms points in time into days (from 00:00 to 24:00)
inset: -0.5,
fill: "author",
title: "title",
order: "appearance",
reverse: true
})
).plot({ width, height: 200 })
Insert cell
Insert cell
import { Calendar } from "@observablehq/calendar-component"
Insert cell
Calendar(data, {
reduce: (books) => ({
value: books.length,
titles: books.map((d) => d.title).join(" | ") // shows the current books as a tooltip
}),
title: (d) => d.titles,
color: { scheme: "reds", range: [0.2, 1] },
width
})
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