Blog · Frontend · · 6 min read
Live filtered summaries without a server round trip
Press Nocturnal on Aves under Mass, drag the mass slider on Mammalia under Conservation, or sweep your pointer across the sidebar world map, and every other property's readout and legend box-whisker plot glide in real time to summarize only the filtered subset, computed entirely in the browser from the tiles already on screen.
Pooling the visible frontier in client memory
A naive server implementation would need to cross-tabulate arbitrary combinations of 39 biological properties and arbitrary map polygons across millions of taxa on every slider drag or mouse move. That query cannot stay at 60 frames per second over HTTP, and precomputing the cross-product would multiply storage by hundreds.
The tiles already loaded on screen hold almost everything needed to approximate the answer immediately. Every numeric property carries a seven-knot summary (min, p5, q1, median, q3, p95, max), a geometric or arithmetic mean (gmean), and a measured species count (count). Every categorical property carries per-bin species weights normalized within each question facet.
When any filter or location is active, the client walks the deepest already-loaded, property-ready child frontier beneath the selected clade. For each child tile, every active filter contributes a match share between 0 and 1:
- A categorical filter computes the fraction of that child's answering descendants that hold any pressed bin, normalized within each facet so multi-question properties never dilute one question with another.
- A numeric window integrates the child's own cumulative distribution function between the two thumbs, staying strictly positive whenever the tile's extent reaches the window.
- A location filter, whether a committed place or a live hover coordinate from the
Path2Dmap scrubber, tests the child's cached range union for0or1.
Those shares multiply across every active filter other than the property being summarized, so clicking categories or dragging thumbs on Mass keeps Mass's own legend steady while every other property in the menu glides to match.
// Weight each child by its measured count times its match share across other active filters.
const entries = frontier.map((child, i) => ({
d: seg(child, key),
w: d?.count ? d.count * shares[i] : 0,
total: d ? d.total * shares[i] : 0,
}));
From those weighted child distributions, pooling a categorical property is a weighted sum of bucket weights. Pooling a numeric property gives the exact weighted geometric or linear mean directly in one pass, then inverts the weighted mixture of child CDFs by 24 steps of bisection (about 16 millionths of the domain width) to recover p5, q1, median, q3, and p95. Menu readouts solve only the median; the active legend solves all five quantiles and feeds the pooled summary into the exact same @property box-whisker updater that handles taxon hover. The entire update uses no extra DOM elements, no animation loop, and no server endpoint.
Bending the outer five percent with a cubic tail
Linear interpolation between consecutive knots works well across the interior 90% of a distribution (p5 to p95), where species density varies gently. It breaks down badly in the outer 5% tails ([min, p5] and [p95, max]), where a single giant or miniature outlier stretches the interval over orders of magnitude.
On Amphibia mass, for example, Chinese giant salamanders stretch Caudata's upper tail far past p95. Treating [p95, max] as a flat rectangle spreads 5% of all salamander species evenly across that void, inflating the reconstructed Amphibia p95 by +107.8% even with no filter active.
Replacing linear interpolation on only those two outer segments with a cubic power curve (u ** 3 below p5 and 1 - (1 - u) ** 3 above p95) packs tail probability near p5 and p95 and lets density taper smoothly to zero at min and max:
const u = (px - pxs[i]) / (pxs[i + 1] - pxs[i]);
const f = i === 0 ? u ** 3 : i === 5 ? 1 - (1 - u) ** 3 : u;
return KNOTS[i] + f * (KNOTS[i + 1] - KNOTS[i]);
Because u ** 3 is strictly increasing from 0 to 1 and matches the endpoints exactly, monotonicity and knot identity stay guaranteed with zero extra bytes on the wire. Reconstructing unfiltered classes from their direct child orders with the cubic tail produces exact geometric means and tight interior quantiles:
| Clade and property | p5 error |
q1 error |
median error |
gmean error |
q3 error |
p95 error |
|---|---|---|---|---|---|---|
| Aves mass | -1.1% | +1.3% | +0.3% | 0.0% | +1.3% | +5.0% |
| Mammalia longevity | -4.9% | -3.4% | -1.5% | 0.0% | -1.0% | +2.0% |
| Mammalia offspring | +2.8% | +0.7% | -2.0% | 0.0% | -0.2% | +0.1% |
| Squamata mass | -3.9% | -0.2% | +1.6% | 0.0% | +4.6% | +14.3% |
| Amphibia mass | -4.5% | -3.3% | +1.3% | 0.0% | +5.6% | +20.4% |
Amphibia mass p95 error drops from +107.8% to +20.4%, Aves mass p5 drops from -8.7% to -1.1%, and Mammalia longevity p95 drops from +7.6% to +2.0%.
Honest limits of client-side accuracy
Client-side frontier pooling is fast because it never sees individual species records. That shortcut comes with three real statistical limits that are worth measuring against exact species-level joins rather than hiding.
First is the within-clade independence assumption. Weighting a child tile by count * share assumes that inside each individual child clade, the filtered trait and the target trait are independent. Whenever an ecological relationship separates between orders or families, order-level pooling lands within a few percent of species truth on the very first click. Whenever the relationship lives inside one huge, diverse order (like Anura for frogs or Passeriformes for perching birds), order-level pooling blends the two halves together until you open deeper branches:
| Filter and target | Orders | Families | Genera | Exact species |
|---|---|---|---|---|
| Aves nocturnal vs diurnal mass | 126 g vs 33.8 g (3.7×) | 125 g vs 33.9 g (3.7×) | 122 g vs 33.0 g (3.7×) | 120 g vs 33.8 g (3.6×) |
| Elasmobranchii threatened vs LC mass | 9.3 kg vs 4.1 kg (2.3×) | 17.1 kg vs 1.2 kg (13.8×) | 17.0 kg vs 1.4 kg (12.6×) | 21.1 kg vs 1.2 kg (17.6×) |
| Amphibia threatened vs LC mass | 3.49 g vs 3.34 g (1.04×) | 2.76 g vs 3.91 g (0.70×) | 2.40 g vs 4.33 g (0.55×) | 2.10 g vs 4.56 g (0.46×) |
| Amphibia threatened vs LC offspring | 75.6 vs 88.1 (0.86×) | 45.1 vs 130.5 (0.35×) | 40.0 vs 155.7 (0.26×) | 35.0 vs 180.0 (0.19×) |
| Aves cold/temperate vs tropical offspring | 2.60 vs 2.51 (1.03×) | 2.78 vs 2.45 (1.14×) | 3.00 vs 2.29 (1.31×) | 3.50 vs 2.50 (1.40×) |
Because the frontier walker automatically descends into any branch you have already opened on screen, every click deeper into the tree sharpens the parent clade's filtered summary live with zero extra fetches.
Second is differential coverage extrapolation, which produces a striking paradox on Mammalia when filtering Organization: group against Mass. Across the 1,160 mammal species that have both social organization and body mass recorded in literature, group-living species have a median mass of 1.74 kg versus 90 g for solitary species (19.3×). Order-level pooling reports 85.1 g versus 83.8 g (1.02×). Why the massive divergence? Chiroptera (bats, median 12.9 g) has 1,162 species with measured body mass, but only 316 species with social organization logged, of which 81% are group-living. A raw species join counts only 249 doubly-measured bats and is dominated by well-studied primates (2.5 kg), ungulates (53 kg), and cetaceans (424 kg). Clade pooling extrapolates 81% × 1,162 = 940 social bats. Neither number is a bug: the raw join reflects which mammals scientists happened to study for both traits, while clade pooling reflects what happens if unmeasured bats resemble measured bats.
Third is binary range granularity on map hover. Testing a cursor point against a clade's range union returns 1 if any descendant occurs there and 0 otherwise. At class rank, cosmopolitan orders like Rodentia or Passeriformes light up almost everywhere on land; opening down to families and genera turns that broad presence check into sharp regional ecology.
To see the ecological patterns that fall out when every property answers live filters in place, see Why big sharks and tiny frogs share the Red List and Discoveries you can see in three clicks.