Table
<k.Table> draws one row per row of a result and the columns you list. Use it
when the reader needs the exact figures. A total row is marked with a yes/no
column (strong) and stays at the foot. For the same measures repeated per
group of columns, use GroupedTable.
Example
regions.sql:
-- Sales, orders and share per region, with a total row
select 'North' as region, 120 as sales, 14 as orders, 22.4 as share, 0 as is_total
union all select 'South', 95, 9, 17.8, 0
union all select 'East', 180, 16, 33.6, 0
union all select 'West', 140, 11, 26.2, 0
union all select 'Total', 535, 50, 100.0, 1
In report.tsx:
import regions from "./regions.sql?raw"
type Row = { region: string; sales: number; orders: number; share: number; is_total: number }
// in defineReport({ … })
queries: { regions: query<Row>(regions) },
blocks: (k) => [
<k.Table
key="regions"
series="regions"
title="Regions"
strong="is_total"
copy
download="regions"
columns={[
{ key: "region", label: "Region", format: "text" },
{ key: "sales", label: "Sales" },
{ key: "orders", label: "Orders" },
{ key: "share", label: "Share", format: "percent" },
]}
info={{ what: "Sales and orders per region.", sql: ["regions"] }}
/>,
],
Props
Also key, description, span (default 2) and info: see
Props every block takes.
A column
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.