Skip to content

feat(ui): dashboard cross-filter for DB-source charts (DASH-7)#153

Merged
eliotlim merged 1 commit into
mainfrom
feat/dash-7-cross-filter
Jul 13, 2026
Merged

feat(ui): dashboard cross-filter for DB-source charts (DASH-7)#153
eliotlim merged 1 commit into
mainfrom
feat/dash-7-cross-filter

Conversation

@eliotlim

Copy link
Copy Markdown
Owner

What

Dashboard-level cross-filter for database-source kit charts. A chart binding gains optional filterInput (a named kit input) + filterProp (a DB property), stored as block props dbFilterInput/dbFilterProp. When set, the chart's rows are pre-filtered by the live value of that named input before aggregation, in both the editor (live) and export. Both absent → unchanged whole-database path (fully additive, backward-compatible).

Demoed by a Quarter dropdown on the Dashboard template: selecting Q2 scopes the KPI tiles (244,000/12/1,195 → 60,000/3/290), the region bar (collapses to North+East), and the channel pie (rebalances) — while the quarterly-trend line stays unbound as full-year context.

Also fixes the y-axis 5-digit left-gutter clip via compact tick labels (25000 → "25k", 1.5e6 → "1.5M") — a shared axisTickLabel (chartMath) + mirrored kitTick in the export runtime, with zero plot-geometry change.

How

  • chartData.ts: scopeRowsByFilter pre-filters rows via the SDK's rowMatchesCondition (aggregation itself doesn't apply view filters). filterTargetFor resolves an input's published value (label/slug) to the stored select/status option id; non-select types compare verbatim; multi-select arrays match ANY (OR); null/empty/"all"/[] = no filter. namedInputValue reads input values from the serialized block tree for the export path (cycle-free, avoids importing scope.ts).
  • charts.tsx: ChartBlock threads the bound input's live value into useDbChartSeries via a stable filterKey memo dep (re-aggregates only on actual value change). ChartDbConfig gains a "Filter by input" + "On property" pair.
  • export/kitChart.ts: resolveDbChartSeries resolves each chart's filter → same series the editor shows. No snapshot-on-view write.
  • templates.ts: Quarter control on the Dashboard template.

Verification

  • Worker: pnpm verify green foreground (build:libs → typecheck → lint → 1049 UI + 188 SDK unit + server/MCP e2e).
  • Independent code review (Opus): VERDICT SOUND. Confirmed (a) no snapshot-on-view CRDT write (the DASH-3 invariant holds; existing "persists NO derived snapshot" test passes), (b) select option-id resolution correct, (c) export parity (kitTick byte-mirrors axisTickLabel), (d) SDK 188 + touched UI 61 tests pass, tsc clean. Non-blocking nits (namedInputValue parity for grouped/richtext/toggle inputs — unreachable via the picker) noted for follow-up.
  • Screenshots (light + dark, all-quarters vs Q2) reviewed — cross-filter visibly correct.

Board: DASH-7 (Dashboards epic).

🤖 Generated with Claude Code

Add an optional cross-filter binding to database-source kit charts: a
named kit input (e.g. a Quarter dropdown) whose value scopes every DB
chart bound to it at once. Picking a value re-aggregates + re-renders
every bound chart live (editor) and is reflected in exports.

- chartData: `ChartDbBinding.filterInput`/`filterProp`; `scopeRowsByFilter`
  pre-filters rows via the SDK `rowMatchesCondition` (equals) before
  aggregating, resolving select/status inputs (id/label/slug) to the
  stored option id; "all"/empty = no filter (additive no-op).
- charts.tsx: `useDbChartSeries` + `ChartBlock` read the bound input's
  live value from `inputScope`; `ChartDbConfig` gains an optional
  "Filter by input" + "On property" pair with a sensible auto-suggest.
- export: `resolveDbChartSeries` resolves each chart's filter from the
  serialized input value (`namedInputValue`) — no snapshot-on-view write.
- templates: the Dashboard ships a Quarter control scoping the KPI tiles
  + region/channel breakdowns (the quarterly trend stays full-year).
- y-gutter: compact y-axis tick labels (25000 -> 25k) so wide values no
  longer clip the left gutter — editor + export runtime in lockstep.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app.book.pub Ready Ready Preview, Comment Jul 13, 2026 3:25pm

Request Review

@eliotlim eliotlim merged commit e0f83a4 into main Jul 13, 2026
10 checks passed
@eliotlim eliotlim deleted the feat/dash-7-cross-filter branch July 13, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant