+- [x] **Group trend analysis via chat** — Business analysts can ask "which regions are growing?", "fastest growing products?", "which segments are trending up?", "compare growth by product category", or "how are my regions trending over time?" and receive an inline `GroupTrendCard` ranking all groups by growth rate. `compute_group_trends(df, date_col, group_col, value_col)` in `core/analyzer.py` converts dates to a numeric day-index, fits OLS slope per group (b = cov(x,y)/var(x)), computes % change (first→last), classifies direction (up/down/flat), ranks by slope descending, and builds a plain-English summary naming the fastest grower and worst decliner. Guards: rejects if group_col has >50 unique values (high cardinality). `GET /api/data/{id}/group-trends?date_col=&group_col=&value_col=` REST endpoint (400 on missing columns or high-cardinality group_col). `_GROUP_TREND_PATTERNS` (7 NL variants: "which X are growing/trending/increasing/declining/rising", "fastest growing/declining X", "growth/trend rate by/per X", "which X have the most growth/decline", "how are X trending over time", "compare growth by X") + `_detect_group_trend_request()` in `chat.py` — auto-detects date column via `detect_time_columns()`, scans message for mentioned categorical col (longest-match, fallback first cat col) and numeric col (longest-match, fallback first numeric). Handler computes `_compute_gt()`, injects rising/falling counts + summary into system prompt. `{type:"group_trends"}` SSE event; `attachGroupTrendsToLastMessage()` Zustand store action. `GroupTrendCard` renders: orange border, 📈 icon, rising/falling/flat count badges, table with rank/#/group/first/last/change badge (color-coded +green/-rose/→muted) / direction arrow (▲▼→), summary footer. `GroupTrendRow` + `GroupTrendResult` TypeScript types; `api.data.getGroupTrends()` client method. Directly implements the vision's "Which products are trending up?" question — distinct from scatter (static relationship), correlation (strength/direction), time-window comparison (two specific periods), and line chart (single series raw trend line).
0 commit comments