JS-modulesnetflow-hierarchy
1.12.0 · API 1

netflow-hierarchy

The nested views of Netflow Map as a netflow-engine add-on: Treemap, Sunburst, Icicle, Circle pack and Tree, nested by links or by groups and drawn as netflow-scene drawing lists; ahead of d3-hierarchy on 35 of 36 measured cases; one call, toSvg(data), draws a picture.

What it is and how it works

Load order: netflow-scene.js, then netflow-hierarchy.js (this module draws through netflow-scene).

The nested views of Netflow Map as an add-on for netflow-engine: Treemap, Sunburst, Icicle, Circle pack and Tree.

Why it exists

Netflow Map draws these views from any map: a tree of links, or items grouped by a column. Kept here, the app and any other page use one tested copy. Netflow Map keeps the views built in.

Where it helps

Not for: editing a tree by hand; it draws the tree it is given or finds.

How it compares

Real trees (2026.11.22; SEC filings and retail orders, 1,000 to 100,000 rows; ungoogled Chromium 156, Firefox 158, WebKitGTK 2.52.6, against d3-hierarchy 3.1.3): ahead in 106 of 108 cells at 21% to 125% of d3's time, 21% to 80% at 100,000 rows; the two cells that are not ahead are 1,000-row cells within the clock step. Earlier, on generated trees, against d3-hierarchy 3.1.2, measured by Netflow Map on its own copy of this code (the same layouts to the last digit) in the cloud test browsers, one at a time, early-stop A/B: ahead on 35 of 36 cases (treemap, icicle, pack and tree at 1,000, 10,000 and 100,000 items), at 0.29 to 0.98 of d3's time; one tie (WebKitGTK icicle at 1,000 items, 1.03, range 0.86 to 1.20). At 100,000 items: 0.29 to 0.78 of d3's time.

How to use it

Use

// netflow-scene.js, then netflow-hierarchy.js
var L = NetflowHierarchy.layout('treemap', { nodes: nodes, edges: edges }, { nest: 'auto', sized: true });
var S = NetflowHierarchy.scene(L, { theme: 'light' }, NetflowScene);
svgElement.outerHTML = NetflowScene.toSvg(S, 'Treemap');

Use with netflow-engine: load the files as page scripts (or keep the folders side by side in Node) and the views join NetflowEngine.VIEWS; or hand them over with NetflowEngine.use('hierarchy', NetflowHierarchy). Then NetflowEngine.build(graph, { view: 'treemap' }) lays the map out and NetflowHierarchy.scene(L, options, NetflowScene) draws it.

Use

// netflow-scene.js, then netflow-hierarchy.js
var L = NetflowHierarchy.layout('treemap', { nodes: nodes, edges: edges }, { nest: 'auto', sized: true });
var S = NetflowHierarchy.scene(L, { theme: 'light' }, NetflowScene);
svgElement.outerHTML = NetflowScene.toSvg(S, 'Treemap');

Use with netflow-engine: load the files as page scripts (or keep the folders side by side in Node) and the views join NetflowEngine.VIEWS; or hand them over with NetflowEngine.use('hierarchy', NetflowHierarchy). Then NetflowEngine.build(graph, { view: 'treemap' }) lays the map out and NetflowHierarchy.scene(L, options, NetflowScene) draws it.

Speed and efficiency numbers

Measured on real trees: cloud Chromium 156.0.8078.79, Firefox 158.0 and WebKitGTK 2.52.6 against d3-hierarchy 3.1.3, one browser at a time, 2026.11.22

The trees are real: the SEC 2026 Q1 numbers file (filing, then statement tag, then each value row) and the retail e-commerce file (country, then item, then each order line), cut to the first 1,000, 10,000 and 100,000 rows, sizes from the real value and quantity columns. Same job both ways: build the tree from rows, sum, sort, lay out (the method of testers/hierarchy-icicle-vs-d3-tester.html, 7 alternating rounds, 3 at 100,000 items). Whole milliseconds are all Firefox and WebKitGTK report, so small cells carry a rounding of up to 1 ms. This replaces the earlier generated trees.

Compared: netflow-hierarchy against d3-hierarchy on real trees (layout of 100,000 rows, percent of d3-hierarchy's time, lower is faster; Chromium / Firefox / WebKitGTK).

netflow-hierarchy lays out 100,000 real rows in 21% to 80% of d3-hierarchy's time in all five views and all three browsers
SEC filing > tag > row
Chromium
Icicle52
Treemap36
Sunburst37
Pack43
Tree80
Firefox
Icicle35
Treemap26
Sunburst31
Pack36
Tree24
WebKitGTK
Icicle58
Treemap52
Sunburst28
Pack33
Tree62
Retail country > item > line
Chromium
Icicle25
Treemap40
Sunburst26
Pack40
Tree51
Firefox
Icicle27
Treemap32
Sunburst21
Pack35
Tree22
WebKitGTK
Icicle21
Treemap27
Sunburst23
Pack37
Tree38

Across all 108 cells (2 real trees x 3 sizes x 6 layouts x 3 browsers) netflow-hierarchy is faster in 106, at 21% to 125% of d3's time; the two cells that are not faster are small (WebKitGTK tree at 1,000 SEC rows 1.25, Firefox unsorted icicle at 1,000 retail rows 1.13, within the clock steps). Harness and raw results: tools/real-corpus.

Source: Measured on real trees: cloud Chromium 156.0.8078.79, Firefox 158.0 and WebKitGTK 2.52.6 against d3-hierarchy 3.1.3, one browser at a time, 2026.11.22.

Against d3-hierarchy 3.1.3 on generated trees (earlier measurement, not re-run on real trees here)

The same job from the same rows: build the tree, sum, sort the children and lay out 100,000 items into positioned boxes, all five views. A fresh page for every library, one browser at a time, shared 4-core cloud machine. Time is shown as a percent of d3-hierarchy's time, so d3-hierarchy is always 100 and lower is faster.

Compared: netflow-hierarchy against d3-hierarchy 3.1.3 (layout of 100,000 items, percent of d3-hierarchy's time, lower is faster).

netflow-hierarchy lays out 100,000 items in 31 to 72% of d3-hierarchy's time in all five views and all three browsers
Icicle
Chromium 156
d3-hierarchy100
netflow-hierarchy57
Firefox 158
d3-hierarchy100
netflow-hierarchy31
WebKitGTK 2.52.6
d3-hierarchy100
netflow-hierarchy38
Treemap
Chromium 156
d3-hierarchy100
netflow-hierarchy41
Firefox 158
d3-hierarchy100
netflow-hierarchy34
WebKitGTK 2.52.6
d3-hierarchy100
netflow-hierarchy42
Sunburst
Chromium 156
d3-hierarchy100
netflow-hierarchy72
Firefox 158
d3-hierarchy100
netflow-hierarchy37
WebKitGTK 2.52.6
d3-hierarchy100
netflow-hierarchy49
Circle pack
Chromium 156
d3-hierarchy100
netflow-hierarchy50
Firefox 158
d3-hierarchy100
netflow-hierarchy33
WebKitGTK 2.52.6
d3-hierarchy100
netflow-hierarchy32
Tree
Chromium 156
d3-hierarchy100
netflow-hierarchy44
Firefox 158
d3-hierarchy100
netflow-hierarchy35
WebKitGTK 2.52.6
d3-hierarchy100
netflow-hierarchy48

The lead is smaller on smaller charts. At 10,000 items netflow-hierarchy takes 43 to 94% of d3-hierarchy's time, and at 1,000 items 53 to 86%; in no view and no browser is it behind. Circle pack was measured again at version 1.8.2 on a mixed tree. On a tree with two children per item, a shape where earlier versions were slower than d3-hierarchy, circle pack now takes 0.60 to 0.70, 0.55 and 0.55 of d3-hierarchy's time at 1,000, 10,000 and 100,000 items in Chromium, 0.95, 0.67 and 0.66 in Firefox, and 0.71, 0.56 and 0.53 in WebKitGTK. Cloud test browsers only; laptop numbers are still to come.

Compared: netflow-hierarchy against d3-hierarchy 3.1.3 on an Android phone (Chrome 157), run by the owner on 2026-11-21 (layout of 100,000 items, percent of d3-hierarchy's time, middle tree shape, lower is faster).

On an Android phone netflow-hierarchy was faster than d3-hierarchy in all 90 races, at 33 to 47% of its time at 100,000 items
Icicle
Android Chrome 157
d3-hierarchy100
netflow-hierarchy33
Treemap
Android Chrome 157
d3-hierarchy100
netflow-hierarchy40
Sunburst
Android Chrome 157
d3-hierarchy100
netflow-hierarchy41
Circle pack
Android Chrome 157
d3-hierarchy100
netflow-hierarchy36
Tree
Android Chrome 157
d3-hierarchy100
netflow-hierarchy47

The phone run covers five views, icicle without sorting, five tree shapes and 1,000, 10,000 and 100,000 items: 90 races, all won by netflow-hierarchy. The best result was 0.32 of d3-hierarchy's time and the closest 0.93. At 10,000 items the middle tree shape takes 43 to 71% and at 1,000 items 47 to 78%. In this test netflow-hierarchy's items are made with their seven output fields already present, as the netflow-hierarchy README advises. This is one phone, so it shows direction rather than a guarantee.

A second phone run, on version 1.10.0 (the owner's Quick run of 31 races on the same phone, 2026-11-21, 4:59 PM Detroit, rows fed untouched to both libraries), was faster than d3-hierarchy 3.1.3 in all 31 races: the best result was 0.34 of d3-hierarchy's time and the closest 0.87. The chart above is the earlier run on 1.8.2.

Size is the one place d3-hierarchy is smaller, and the two are not the same job. d3-hierarchy 3.1.3 minified is 14.8 KB (5.8 KB gzipped) and does layout only. netflow-hierarchy ships a minified copy of 32.5 KB (14.6 KB gzipped) that does layout and drawing in one file (the readable file is 22.6 KB gzipped), and its layout part alone is about 16.3 KB (7.4 KB gzipped). So d3-hierarchy is smaller and no size win is claimed.

Source: Against d3-hierarchy 3.1.3 on generated trees (earlier measurement, not re-run on real trees here).

Credits

The code is Netflow Map's own (LFC Foundry), cut out for this module; no code from other projects.

Original sources (links checked 2026-11-14; ideas only):