How It Works
The key technique is pre-segmenting data by filter value and using ternary expressions to select the active dataset. All five variants of the data (one per region, plus “all”) live in state from the start. When the user picks a region, the renderer re-evaluates every expression that referencesregion and swaps in the matching data — no network call, no script rerun.
The let binding pattern
Rather than repeating the ternary expression in every metric and chart prop, a let binding on the outer Column computes four intermediate values once:
{{ m.revenue }} or data="{{ chart }}" directly. The pick() helper builds the ternary chain: {{ region == 'north' ? metrics_north : region == 'south' ? metrics_south : ... : metrics_all }}.
How the Select drives state
The Select component usesname="region" to auto-bind its value to state.region. When the user picks “North”, the renderer sets region = "north", which triggers the let binding to re-evaluate, which swaps every metric value, chart dataset, and radar shape simultaneously.
Expression pipes for formatting
The Metric values use pipes to format raw numbers from state:{{ m.revenue | currency }}renders as “$284,750”{{ m.units | number }}renders as “12,450” with locale separators{{ m.avg_price | currency }}renders as “$22.87”