Plot.plot({
marginLeft: 200,
marginRight: 1,
marginTop: 30,
grid: true,
x: {
axis: "top",
domain: [-maxQuantity, maxAmount],
label: null
},
y: {
domain: processedData.map(d => d.Resource),
label: null
},
marks: [
Plot.barX(processedData, {
y: "Resource",
x1: -1500,
x2: d => -d.Quantity,
fill: "gray"
}),
Plot.barX(processedData, {
y: "Resource",
x1: 1500,
x2: "Amount",
fill: "yellow"
}),
Plot.text(["Quantity (←) | Amount (→)"], {
x: 0,
frameAnchor: "top",
dy: -30,
fontSize: 14,
fontWeight: "bold"
}),
Plot.ruleX([-1500, 1500], {
y: processedData.map(d => d.Resource),
y1: { band: 0 },
y2: { band: 1 },
strokeDasharray: "29,4"
}),
Plot.text(processedData, {
y: "Resource",
x: 0,
text: d => d.UnitMeasure,
})
]
})