Public
Edited
Apr 1, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ordersByDayOfWeek = pizzadb.query(`
select
"type",
"day_of_week",
sum("orders") as orderSum
from
orders
group by
"type",
"day_of_week"
order by
"type",
"day_of_week"
`)
Insert cell
ordersByDate = pizzadb.query(`
select
"orderDate",
"type",
sum("orders") as orderSum
from
orders
group by
"orderDate",
"type"
order by
"orderDate"
`)
Insert cell
Insert cell
augmented_pizzaorders = pizzaorders.map((d) => augment(d))
Insert cell
mappings = ({
type: (d) => d.name.split(" Pizza ")[0],
size: (d) => d.name.split(" Pizza ")[1]
})
Insert cell
augment = d => {
const ret = {...d};
for (const [key, mapping] of Object.entries(mappings))
{
ret[key] = mapping(d);
}
return ret;
}
Insert cell
Insert cell
dayLetter = (day_of_week) => ["S", "M", "T", "W", "T", "F", "S"][day_of_week]
Insert cell
lineTooltip = (d) => `${d.type}
${d.orderSum} Orders
(${formatDate(d.orderDate)})`
Insert cell
formatDate = d3.timeFormat("%a %d. %b %Y")
Insert cell
types = [...new Set(pizzaorders.map(mappings.type))].sort()
Insert cell
sizes = [...new Set(pizzaorders.map(mappings.size))].sort()
Insert cell
names = [...new Set(pizzaorders.map((po) => po.name))].sort()
Insert cell
fields = Object.keys(pizzaorders[0])
Insert cell
dateCount = [...new Set(dates.map((d) => "" + d))].length
Insert cell
dateRange = d3.extent(dates)
Insert cell
dates = pizzaorders.map((o) => o.orderDate)
Insert cell
Insert cell
pizzadb = DuckDBClient.of({ orders: augmented_pizzaorders })
Insert cell
import { pizzaorders } from "@observablehq/data-vis-course-assignment"
Insert cell
import { Plot } from "@mkfreeman/plot-tooltip"
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