I am creating a bar chart with the sum of values in the last 7 days. This is easy combining Plot.rectY and Plot.windowY but I have not been able to display the text with the sum on top of each bar:
This is the code I have tried:
Plot.plot({
marks: [
Plot.rectY(
weather.slice(-28),
Plot.windowY({
k: 7,
anchor: "end",
reduce: "sum",
x: "date",
y: "precipitation",
interval: d3.utcDay,
fill: "lightgrey"
})
),
Plot.text(
weather.slice(-28),
Plot.windowY({
text: "sum",
k: 7,
anchor: "end",
reduce: "sum",
x: "date",
y: "precipitation",
interval: d3.utcDay
})
),
Plot.ruleY([0])
]
})
I would appreciate hints on how to combine Plot.text with Plot.windowY
Thanks