vega({
data: { values: flattened.filter((d) => d.date.endsWith("11")) },
title: {
text: ["Inflation across household expenses and geographies - Canada"],
subtitle: [
"Values for November 2002 to 2021. CPI starts at a value of 100 in 2002",
""
],
fontSize: 22
},
mark: { type: "rect", tooltip: true },
encoding: {
facet: {
field: "geo",
type: "ordinal",
columns: 2,
axis: {
fontSize: 18,
title: false
},
header: {
labelFontSize: 18
}
},
tooltip: [
{ field: "date" },
{ field: "geo" },
{ field: "item" },
{ field: "value" }
],
y: {
field: "item",
axis: {
labelFontSize: 14,
titleFontSize: 18,
labelLimit: 200,
title: false
},
sort: "value"
},
x: {
field: "date",
axis: { labelFontSize: 14, titleFontSize: 18, title: false }
},
color: {
field: "value",
type: "quantitative",
scale: { scheme: "viridis" },
legend: {
title: "CPI",
labelFontSize: 14,
titleFontSize: 18
}
}
},
resolve: { axis: { x: "independent" } }
})