Treemap
<k.Treemap> draws one rectangle per row, its area the row's value. Use it
for how a total splits across many categories, where a bar chart would be
too long. With group, several groups share one map, each in its own tone.
Example
products.sql:
-- Sales per product
select 'Lamps' as product, 'Home' as category, 340 as sales
union all select 'Rugs', 'Home', 210
union all select 'Chairs', 'Furniture', 480
union all select 'Tables', 'Furniture', 390
union all select 'Shelves', 'Furniture', 150
In report.tsx:
import products from "./products.sql?raw"
type Row = { product: string; category: string; sales: number }
// in defineReport({ … })
queries: { products: query<Row>(products) },
blocks: (k) => [
<k.Treemap
key="products"
series="products"
name="product"
value="sales"
group="category"
share
title="Sales by product"
info={{ what: "Each product's share of sales.", sql: ["products"] }}
/>,
],
Props
Also key, description, span (default 1) and info: see
Props every block takes.
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.