Public
Edited
Dec 21, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
width: width,
height: 420,
marginRight: 120,
marks: [
Plot.lineY(pizza.filter(d => d.name !== "Veggie Pizza Small"), Plot.binX({y: 'sum'}, {
x: "order_date",
y: "orders",
z: "name",
interval: d3.utcWeek,
tip: true,
stroke: "lightgrey",
strokeWidth: 0.85,
})),
//Additional mark to highlight the top perfoming pizza
Plot.lineY(pizza.filter(d => d.name === "Veggie Pizza Small"), Plot.binX({y: 'sum'}, {
x: "order_date",
y: "orders",
z: "name",
interval: d3.utcWeek,
tip: true,
stroke: "#00ad85",
strokeWidth: 2,
})),
//Additional text annotation to highlight the top perfoming pizza
Plot.text(pizza.filter(d => d.name === "Veggie Pizza Small"), Plot.selectLast({x: "order_date", y: 1750, text: "name", textAnchor: "start", dx: 3}))
]
})
Insert cell
Insert cell
Plot.plot({
width: 720,
height: 300,
marginLeft: 90,
facet: {
data: pizza,
y: "pizza_name",
x: "size",
},
color: { legend: true, scheme: "OrRd" },
marks: [
Plot.tickX(
pizza,
Plot.binX(
{
fill: "sum",
},
{
x: "order_date",
interval: d3.utcWeek,
stroke: "orders"
}
)
),
Plot.frame({ stroke: "#aaa", strokeWidth: 0.5 })
]
})
Insert cell
Insert cell
Plot.plot({
width: 720,
height: 420,
//Using plot default color scheme "Observable10" for categorical data.
color: { legend: true, type: "categorical" },
facet: {
data: pizza,
y: "pizza_name",
x: "size",
marginRight: 90,
label: "",
//sort: (d) => d3.ascending(d.category)
},
marks: [
Plot.areaY(pizza, Plot.binX({y: 'sum'}, {
x: "order_date",
y: "orders",
fill: "category",
interval: d3.utcWeek,
tip: true
})),
Plot.ruleY([0])
],
y: {
tickFormat: d => ""
},
})
Insert cell
Insert cell
pizza
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
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