MatrixTable
A statement crossed with a period tree - rows drill down, period columns expand in place, with an optional variance column.
Two hierarchies at right angles: a statement row tree (with + / − / =
flow markers) down the side, and a period tree - year, quarter, month - across
the top. Every leaf period prints its scenario sub-columns (PL and AC by
default) and, with showVariance, the ΔBudget between them. Both axes expand
and collapse in place.
When to use
Budget-versus-actual reporting and any other planning grid where the reader starts at the year and drills into the quarter or month that moved. For a single-period statement use StatementTable; for entities rather than periods use DataTable.
Example
Click a period header to drill into (or fold up) its children, and a row label to break the line down. The label column stays frozen while the period bands scroll.
| 2023 | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Q1 | Q2 | Q3 | Q4 | ||||||||||||
| PL | AC | ΔBdg | PL | AC | ΔBdg | PL | AC | ΔBdg | PL | AC | ΔBdg | PL | AC | ΔBdg | |
| = | 774 | 774 | 0 | 191 | 189 | -2 | 202 | 200 | -2 | 210 | 207 | -3 | 222 | 220 | -2 |
| + | 543 | 565 | +22 | 143 | 138 | -5 | 152 | 147 | -5 | 158 | 152 | -6 | 167 | 161 | -6 |
| + | 231 | 209 | -22 | 48 | 51 | +3 | 50 | 53 | +3 | 52 | 55 | +3 | 55 | 59 | +4 |
| − | 199 | 222 | +23 | 55 | 59 | +4 | 57 | 61 | +4 | 58 | 62 | +4 | 60 | 62 | +2 |
| = | 575 | 552 | -23 | 136 | 130 | -6 | 145 | 139 | -6 | 152 | 145 | -7 | 162 | 158 | -4 |
import { MatrixTable } from "ibcs-react";
<MatrixTable
rows={rows} // [{ id, label, flow: "add" | "subtract" | "result", children? }]
columns={periods} // [{ id, label, children? }] - year > quarter > month
values={values} // values[rowId][periodId][scenario]
scenarios={["PL", "AC"]}
showVariance
defaultExpandedCols={["2024"]}
/>;A row with children and no values of its own aggregates them, so only the
leaf lines have to be supplied.
Expansion: controlled or uncontrolled
Note the polarity. Unlike StatementTable and DataTable, which track what is collapsed, the matrix names what is expanded - its periods deliberately start closed, because a matrix is opened year by year.
- Uncontrolled -
defaultExpandedRowsanddefaultExpandedColsseed the two open sets on mount (rows default to everything except lines flaggeddefaultCollapsed; periods default to those flaggeddefaultExpanded). - Controlled -
expandedRows/expandedCols(aReadonlySet<string>or a string array) withonExpandedRowsChange/onExpandedColsChange. The matrix then renders exactly those sets and never mutates them; every toggle, and the Expand all / Collapse all buttons, report the next sorted ids for you to apply. The change callbacks also fire uncontrolled, as observers.
const [cols, setCols] = useState<string[]>(["2024"]);
<MatrixTable
rows={rows}
columns={periods}
values={values}
columnExpandControls
expandedCols={cols}
onExpandedColsChange={setCols}
/>;Each value sub-cell is an addressable target: onCellClick reports the row and
period ids and labels, the scenario ("DELTA" for the variance cell) and the
value, while cellDecorations draws a corner ribbon - enough to build a
comment layer on top of the grid. See the
budget matrix guide for that walkthrough.
Props
Prop
Type