Mapping Dynamic Table Data into a Table
This page explains how a BPS dynamic table response is transformed into a renderable table in the UI, including the case where turtahun is present.
Visual 1 — Table Structure Mapping
This visual shows how response dimensions are mapped into rows, columns, and cell values — without relying on a separate SVG asset.
Each table value is built from a combination of these dimensions.
Example: Pinrang × Population × 1999
| Region | 1999 | 2000 | 2001 |
|---|---|---|---|
| Pinrang | 308,669 | 311,595 | 312,473 |
308669read from
datacontent[7315310990]Core Mapping
- Rows come from
vervar - Main columns come from
tahun - Sub-columns can come from
turvar - A deeper sub-column level can come from
turtahun - Cell values are read from
datacontent - Every value is looked up using a composite key:
{vervar}{var}{turvar}{tahun}{turtahun}Example:
7315 + 31 + 0 + 99 + 0 = 7315310990Then lookup:
datacontent[7315310990] = 308669Visual 2 — Full Mapping including turtahun
The visual below shows four important header structure cases:
- Case A: single turvar + single turtahun
- Case B: multiple turvar + single turtahun
- Case C: single turvar + multiple turtahun
- Case D: multiple turvar + multiple turtahun
datacontent key and render a multi-level header tableval fields→ build key → lookup datacontent → cell value
| Wilayah | 1999 | 2000 |
|---|---|---|
| Pinrang | 308,669 | 311,595 |
| Wilayah | 1999 | 2000 | ||
|---|---|---|---|---|
| Kec A | Kec B | Kec A | Kec B | |
| Pinrang | 308,669 | 295,421 | 311,595 | 300,112 |
count(turvar)=2| Wilayah | 1999 | 2000 | ||
|---|---|---|---|---|
| Februari | Maret | Februari | Maret | |
| Pinrang | 101,234 | 102,887 | 103,991 | 105,112 |
count(turtahun)=2| Wilayah | 1999 | 2000 | ||||||
|---|---|---|---|---|---|---|---|---|
| Februari | Maret | Februari | Maret | |||||
| Kec A | Kec B | Kec A | Kec B | Kec A | Kec B | Kec A | Kec B | |
| Pinrang | 101,234 | 98,441 | 102,887 | 99,103 | 103,991 | 100,234 | 105,112 | 101,876 |
count(turtahun)×count(turvar)=2 × 2 = 4count(turvar)=2Mental Model Rules
1. Rows
Always start with vervar.
each item in vervar = one main row2. Columns
- if
turvaronly has one meaningful value or is effectively absent → columns can just betahun - if
turvarhas multiple meaningful values → columns becometurvar × tahun
3. Extra turtahun hierarchy
If there is more than one turtahun, the column header needs one more level.
Practical rule:
tahunis always the top levelturtahunbecomes the middle level when count > 1turvarbecomes the lower level when count > 1
So the header structure can become:
tahunor:
tahun -> turvaror:
tahun -> turtahunor in the full case:
tahun -> turtahun -> turvarIn stadata-js
Option 1 — toStructuredData()
Use this when you want full control over rendering the table.
const structured = table.toStructuredData()Option 2 — DynamicTableHtmlGenerator
Use this when you want a quick HTML table.
import { DynamicTableHtmlGenerator } from 'stadata-js'
const html = DynamicTableHtmlGenerator.generate(table)When do you need manual parsing?
Manual parsing is usually only needed when:
- you want a highly custom visualization
- you want to export to your own custom format
- you want pivot logic different from the built-in helpers
Otherwise, prefer the built-in helpers.