chart() can now draw stacked bars: pass stacked: true on a type: "bar" chart and the series stack within each category instead of sitting side by side. It is the usual way to show a total broken down by part — revenue by product per month, usage by category per day.
chart({
type: "bar",
data: "{{revenue}}",
x: "month",
y: [
{ key: "widgets", label: "Widgets" },
{ key: "gadgets", label: "Gadgets" },
],
stacked: true,
width: 480,
height: 220,
});
The first y series sits at the bottom of each stack. Positive values stack upward from zero and negative values downward, so a category that loses money on one product still reads correctly, and the value axis fits the stacked totals rather than the biggest single value. Generated alt text lists the series values and the per-category total, e.g. "Jan: Widgets 3,000, Gadgets 2,000 (total 5,000)".
stacked applies to bar charts only — line and pie reject it, and the render returns an invalid-chart-data warning if a raw document sets it there. Full option list: pdf-template-author.md §Charts.