Published
Edited
Jul 1, 2022
2 stars
Insert cell
Insert cell
Plot.plot({
y: { label: "↑ Job vacancies, seasonally adj. (thousands)", grid: true },
marks: [
Plot.areaY(vacancies, {
x: "month",
y: "vacancies",
fill: "pink",
curve: "step-before"
}),
Plot.lineY(vacancies, { x: "month", y: "vacancies", curve: "step-before" }),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
x: { domain: [new Date("2012-05"), new Date("2022-05")] },
y: {
label: "↑ Job vacancies, seasonally adj. (thousands)",
nice: true,
grid: true
},
marks: [
Plot.areaY(
vacancies,
Plot.map(
{ title: (T) => (T.push(T[T.length - 1]), T.slice(1)) },
{
x: "month",
y: "vacancies",
title: ({ month, vacancies }) =>
`${d3.utcFormat("%b %Y")(month)}: ${vacancies} thousands`,
fill: "pink",
stroke: "pink",
curve: "step-before",
clip: true
}
)
),
Plot.lineY(vacancies, {
x: "month",
y: "vacancies",
curve: "step-before",
clip: true
}),
Plot.ruleY([0])
]
})
Insert cell
vacancies = FileAttachment("vacancies.csv").csv({ typed: true })
Insert cell
Insert cell
Plot.plot({
x: { domain: [new Date("2012-05"), new Date("2022-05")] },
y: {
label: "↑ Job vacancies, seasonally adj. (thousands)",
nice: true,
grid: true
},
marks: [
Plot.areaY(vacancies, {
x: "month",
y: "vacancies",
fill: "pink",
curve: "step-before",
clip: true
}),
Plot.lineY(vacancies, {
x: "month",
y: "vacancies",
curve: "step-before",
clip: true
}),
Plot.ruleY([0]),

// invisible mark to show the title
Plot.barX(vacancies, {
title: ({ month, vacancies }) =>
`${d3.utcFormat("%b %Y")(month)}: ${vacancies} thousands`,
x1: ({ month }) => d3.utcMonth.offset(month, -3),
x2: "month",
fill: "lightblue",
fillOpacity: 0, // comment out to debug
pointerEvents: "all",
clip: true
})
]
})
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