addTooltips(
Plot.plot({
marginTop: 30,
marginBottom: 30,
x: { label: "City", tickFormat: (name) => (name ? name : "None") },
y: { grid: true, nice: true, label: "Expense Value in CNY" },
color: { legend: true },
marks: [
Plot.barY(
data,
Plot.groupX(
{
y: "sum",
title: (group) => currencySum(group, true)
},
{
x: "city",
y: (d) => d.amount * currencyExchangeRate(d.currency),
fill: "currency",
sort: { x: "-y" },
filter: (d) => d.subcategory != "Plane"
}
)
),
Plot.textY(
data,
Plot.groupX(
{ y: "sum", text: "sum" },
{
x: "city",
y: (d) => d.amount * currencyExchangeRate(d.currency),
filter: (d) => d.subcategory != "Plane",
text: (d) => d.amount * currencyExchangeRate(d.currency),
lineAnchor: "bottom",
dy: -5
}
)
),
Plot.ruleY([0])
]
})
)