StackedBars
<k.StackedBars> stacks one band per column for each x value. Use it for
the parts of a total over time (sales per channel per month), or with
percent for their shares. Rates such as a conversion rate can ride on top
as lines with lines.
Example
byChannel.sql:
-- Orders per channel and month, and the share paid by card
select '2026-01' as month, 60 as web, 40 as store, 100 as total, 71.5 as card_rate
union all select '2026-02', 72, 38, 110, 74.0
union all select '2026-03', 80, 45, 125, 73.2
In report.tsx:
import byChannel from "./byChannel.sql?raw"
type Row = { month: string; web: number; store: number; total: number; card_rate: number }
// in defineReport({ … })
queries: { byChannel: query<Row>(byChannel) },
blocks: (k) => [
<k.StackedBars
key="channels"
series="byChannel"
x="month"
xFormat="month"
y={{ web: "Web", store: "Store" }}
total="total"
lines={{ card_rate: "Paid by card" }}
title="Orders per channel"
info={{ what: "Orders per channel, with the share paid by card.", sql: ["byChannel"] }}
/>,
],
Props
Also key, description, span (default 1) and info: see
Props every block takes.
A stack with negative values is stacked by sign: positive bands up from zero, negative ones down.
Checks
A series that is not one of the report's queries, or a column it names
that the query's rows do not have, fails the typecheck, as does a missing
required prop or a value of the wrong type.