Detail rows
InputBusiness detail rows, not yet aggregated. Each row is one raw record.
rows[]rows[]
pivot table · model + canvas
Aggregation produces one row per dimension combination; a matrix transform maps member indices to
[x, y]; Canvas draws only the cells inside the viewport. Model, layout, and rendering stay independent.
02 · pipeline
Aggregation, layout, geometry, and rendering are independent. Built-in and example features attach between stages or after rendering, and new capabilities reuse the same mount points.
Business detail rows, not yet aggregated. Each row is one raw record.
rows[]rows[]
Group by dimension keys, keep one row per combination, and compute count / sum / avg / min / max.
rows[]cube.rows[]
Encode member values as indices, derive integer grid coordinates through an affine matrix, and build recursively renderable headers.
cube.rows[]layout
Compute screen rectangles, visible range, and clip regions from the viewport and scroll offset; never touches Canvas.
layoutgeometry
Draw background, grid lines, text, and frozen headers; iterate only over cells inside the viewport.
layout + geometryCanvas
scrollX / scrollY changes → recompute geometry → redraw
Hit testing / collapse / drill-down → re-enter collapseCube, aggregate, or layoutPivot
03 · matrix transform
A dimension hierarchy is a mixed-radix number: parents position coarsely, and children position finely inside the parent block. The whole tree collapses into one fixed matrix.
A record becomes an augmented vector. Each dimension contributes a member index
id, followed by a constant 1:
v = [i₁, i₂, ..., i_D, 1]ᵀ
Column d of matrix M is the unit vector of that dimension axis scaled by
spand; the last column is the translation:
[x, y]ᵀ = M · v
Parent and child spans multiply. Each step of a parent dimension crosses exactly the child member count times the child span:
span_parent = n_child × span_child span_d = Π n_c (c is a descendant of d)
Every parent member is padded with the full global set of child members, forming a regular grid. The span is independent of the parent, so the entire layout is one fixed matrix—at the cost of empty cells.
Only combinations that actually occur are placed, so parent blocks vary in size. There is no global fixed matrix, but each record still yields a piecewise affine transform.
offset / size maps directly to rowspan / colspan.04 · live demo
5 regions, 20 cities, 6 years, and 3 product categories: 867 detail rows aggregate into 288 rows. Headers stay frozen, and only the visible part of the data area is drawn.
Pan with the wheel or drag; drag the right / bottom scrollbar for precise jumps. Scrollbars auto-hide after you stop interacting and stay visible while hovered or dragged; Shift + wheel scrolls horizontally; when the canvas is focused, use the arrow keys, PageUp / PageDown, Home / End. With dual measures, the heatmap and row/column totals split by measure. Corner labels demonstrate a custom overlay; high-value markers demonstrate a custom feature: cellStyle changes the background and renderWithOverlay draws a corner badge. Collapse mode lets you click parent row/column headers; it works with row/column totals and dual measures, but not cartesian. Row/column subtotals and grand totals are inserted at the end of the region and year dimensions.
05 · performance
Scrolling iterates only over visible cells; headers are binary-pruned by offset; the canvas buffer is reused while dimensions stay unchanged; heatmap ranges are cached per layout.
visible range; total cell count never enters the per-frame loop.cellMap.beginPath() + stroke().06 · benchmark
Runs the real aggregate + layoutPivot pipeline in a separate Node process for each scale, repeated 3 times, and takes the median total time. At 10M rows the available memory is insufficient, so chunked aggregation is used; the table labels both modes explicitly.
| Rows | Generate | Aggregate | Merge | Layout | Transform | Peak memory | Mode |
|---|---|---|---|---|---|---|---|
| Loading benchmark results… | |||||||
Result file:
bench/results.json
· Reproduce: node bench/run.mjs · Script:
bench/transform.mjs
07 · depth sweep
With 1M detail rows fixed, add row dimensions first and then column dimensions, with 2 members per level. The stop condition is the matrix transform (layoutPivot) exceeding 3 seconds; aggregation time and peak memory are recorded too.
Loading depth experiment results…
| Row depth | Column depth | Aggregate | Matrix transform | Total | Peak memory | Output |
|---|---|---|---|---|---|---|
| Loading… | ||||||
| Row depth | Column depth | Aggregate | Matrix transform | Total | Peak memory | Output |
|---|---|---|---|---|---|---|
| Loading… | ||||||
Result file:
bench/depth-results.json
· Reproduce: node bench/depth-run.mjs · Script:
bench/depth-run.mjs
08 · quickstart
No build step and no runtime dependencies. Minimal snippets for each demo feature, ready to copy.
node examples/demo.mjs node --test test/model/*.test.mjs test/render/*.test.mjs \ test/features/*.test.mjs test/site/*.test.mjs
Browser examples must be served over HTTP; ES modules do not work over file://.
python3 -m http.server 8000 # http://localhost:8000/
The core does not depend on features; pick a mount point and write a function that only reads core output.