Repository navigation
Description
Summary
Pure refactor — extract inline utility functions and the PropertyComparisonChart component from the monolithic DBDeltaChart.tsx (601 lines) into separate files. Zero behavior change. This establishes the file structure needed for the Event Deltas improvement series.
Problem
DBDeltaChart.tsx currently contains everything inline:
- Data utility functions (
flattenData,getPropertyStatistics,mergeValueStatisticsMaps) - The
PropertyComparisonChartcomponent andHDXBarChartTooltip - Layout constants (
CHART_WIDTH,CHART_HEIGHT,CHART_GAP,PAGINATION_HEIGHT) - The main
DBDeltaChartcomponent with query logic
This violates the 300-line guideline in CLAUDE.md and makes it impossible to add features (filtering, scoring, sampling, highlights) without creating a massive single-file PR. Extracting into separate files enables parallel development of independent features.
Changes
New file: deltaChartUtils.ts
Move from DBDeltaChart.tsx:
flattenData()— recursive object/array flattenergetPropertyStatistics()— computes property/value percentage mapsmergeValueStatisticsMaps()— merges outlier/inlier value maps
No logic changes — exact same functions, just exported.
New file: PropertyComparisonChart.tsx
Move from DBDeltaChart.tsx:
PropertyComparisonChartcomponentHDXBarChartTooltipcomponent- Layout constants:
CHART_WIDTH,CHART_HEIGHT,CHART_GAP,PAGINATION_HEIGHT
No logic changes — exact same component and constants, just in their own file.
Modified: DBDeltaChart.tsx
- Remove moved code (utilities, component, constants)
- Add imports from
deltaChartUtilsandPropertyComparisonChart - All query logic, pagination, and rendering stay in place
Files
packages/app/src/components/deltaChartUtils.ts(NEW — ~160 lines moved)packages/app/src/components/PropertyComparisonChart.tsx(NEW — ~120 lines moved)packages/app/src/components/DBDeltaChart.tsx(MODIFIED — shrinks from ~601 to ~330 lines)
Dependencies
None — this is the foundational refactor that unblocks all Event Deltas feature PRs:
- Event Deltas: Chart UX polish and heatmap fixes #1823 (Chart UX polish)
- Event Deltas: Always-on attribute distribution mode (no selection required) #1824 (Always-on distribution)
- Event Deltas: Field filtering and priority classification #1825 (Field filtering)
- Event Deltas: Improved attribute sorting with entropy scoring and proportional comparison #1826 (Attribute sorting)
- Event Deltas: Deterministic sampling with adaptive sample size #1827 (Sampling)
- Event Deltas: Heatmap correlation highlights on attribute value hover #1828 (Hover highlights)
- Event Deltas: Filter/Exclude/Copy actions on attribute values #1829 (Filter actions)
Test plan
- Existing E2E tests pass (no behavior change)
- Event Deltas comparison view works identically to before
- No visual changes
-
tsc --noEmitpasses (no type errors from moved code)
Review guidance
This is a move-only refactor. The reviewer should verify:
- Every function/component moved exists identically in the source file on main
- No logic was added, removed, or modified
- Imports in
DBDeltaChart.tsxcorrectly reference the new files
Activity
refactor: extract deltaChartUtils and PropertyComparisonChart from DB…
refactor: extract deltaChartUtils and PropertyComparisonChart from DB…