[object Object]

← back to Nationalrealestate

USRE Markets: left-rail filters now cover ALL data points (derived from FIELDS)

4d6622330c0906de5c7786ca57c23d1dcbf80165 · 2026-07-26 16:10:39 -0700 · Steve

Files touched

Diff

commit 4d6622330c0906de5c7786ca57c23d1dcbf80165
Author: Steve <steve@designerwallcoverings.com>
Date:   Sun Jul 26 16:10:39 2026 -0700

    USRE Markets: left-rail filters now cover ALL data points (derived from FIELDS)
---
 public/markets.html | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/public/markets.html b/public/markets.html
index fdb41c3..a55eb3e 100644
--- a/public/markets.html
+++ b/public/markets.html
@@ -90,6 +90,17 @@ const FIELDS = [
 function sub100(v){ return v == null ? null : Math.round(v * 100); }
 function pctv(v){ return v == null ? null : +(v * 100).toFixed(2); }
 
+// Left-rail filters: ONE facet per data point so the rail covers ALL data points.
+// 'state' -> multi-select chips; every other field -> a min/max range. Derived from
+// FIELDS (not hand-written) so it stays in sync, and each range reuses its field's
+// `calc` so the bounds match the SCALED value shown in the grid (YoY %, 0-100
+// sub-scores, rounded ZHVI, Data %, etc.) rather than the raw stored value.
+const FILTERS = FIELDS
+  .filter(f => f.k !== 'name')                       // 'name' is the title/sort target, not a filter
+  .map(f => f.k === 'state'
+    ? { k: 'state', l: 'State', type: 'chip', max: 60 }
+    : { k: f.k, l: f.l, type: 'range', calc: f.calc, money: f.money });
+
 let grid = null;
 let allRows = [];
 // thin markets (<50k pop or <10 monthly sales) carry no rank and hide by default —
@@ -128,13 +139,7 @@ async function load(type){
     sort: { k: 'opportunity_score', dir: -1 },
     onRow: r => ({ cls: (r.data_completeness != null && r.data_completeness < THIN) ? 'dim' : '' }),
     onRowClick: r => { location.href = '/market.html?key=' + encodeURIComponent(r.key); },
-    facets: [
-      { k: 'state', l: 'State', type: 'chip', max: 60 },
-      { k: 'opportunity_score', l: 'Score', type: 'range' },
-      { k: 'zhvi', l: 'ZHVI', type: 'range', money: 1 },
-      { k: 'population', l: 'Population', type: 'range' },
-      { k: 'dom', l: 'DOM', type: 'range' },
-    ],
+    facets: FILTERS,
   });
 }
 fetch('/api/health').then(r => r.json()).then(d => {

← d32c870 wake: optimize bulk-flag UPDATE to pkey join (was 53min JSON  ·  back to Nationalrealestate  ·  auto-save: 2026-07-26T16:14:26 (17 files) — public/admin.htm 3d80035 →