Progress
<k.Progress> reads the first row of a result and draws a bar: the figure
so far, a paler projection behind it, and the full width as the target,
with "0" and the target printed under its ends. Up to three figures can
follow under the bar. Use it for a budget or a goal for the year.
Example
year.sql:
-- Sales so far this year, the projection and the target
select 640 as sales, 910 as projected, 1000 as target,
'Jan to Aug' as period, 64.0 as reached
In report.tsx:
import year from "./year.sql?raw"
type Row = { sales: number; projected: number; target: number; period: string; reached: number }
// in defineReport({ … })
queries: { year: query<Row>(year) },
blocks: (k) => [
<k.Progress
key="goal"
series="year"
value="sales"
projection="projected"
target="target"
targetLabel="Goal"
suffix=" k"
cells={[
{ label: "So far", value: "sales", line: "period", swatch: "value" },
{ label: "Projected", value: "projected", swatch: "projection" },
{ label: "Reached", value: "reached", format: "percent" },
]}
title="Sales against the yearly goal"
info={{ what: "Sales so far and projected, against the goal.", sql: ["year"] }}
/>,
],
Props
Also key, description, span (default 2) 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.