defaultExpandPx
defaultExpandPx(
tree,width,height):number
Defined in: network/lod.ts:1061
The adaptive default expand threshold, in px, for a tree with no explicit CutOptions.expandPx (#191).
expandPx is an absolute on-screen size, but the natural scale of the footprint it is compared
against is set by how many leaves the finest aggregate holds: a coarsening tree’s leaf-parent
holds 2 leaves and is 7–23 px across at a fit view, a provided-module tree’s holds 30–60 and is
96–123 px. One fixed 48 px therefore did real work on the first (22–34 % of the fit frontier stayed
raw leaves, the rest aggregates) and nothing on the second — lod({ modules }) opened on 100 %
raw leaves, which is why both website examples used to hard-code 240.
So scale the default by the tree’s own LODTree.leafBranching c: a parent of c
equal-sized children is √c times their diameter (equal discs, area-conserving), so
48·√(c/{@link CALIBRATED_BRANCHING}) gives every child the same ~34 px of screen room the 48 px
default gives the two children of a binary parent. That is exactly 48 px for a coarsening tree (and
for a quadtree bottom cell, via the floor), so those keep their calibration byte-for-byte,
while a 30–60-member module partition asks for 190–260 px — a genuinely aggregated opening view.
Clamped both ways: never below the historical 48 px, and never above half the shorter viewport side, so a tree with enormous leaf-parents (one 2 000-member module) can’t push the threshold past the whole framed layout and collapse the map to a single blob.
O(1) — a √, a multiply and two clamps, off one number computed at tree build. Safe on a tree that
predates the field (leafBranching absent ⇒ the flat 48 px default).
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”number