Skip to content

feat: add category spending bar chart to Statistics tab#20

Merged
7174Andy merged 2 commits into
mainfrom
feat/add-category-bar-chart
Feb 14, 2026
Merged

feat: add category spending bar chart to Statistics tab#20
7174Andy merged 2 commits into
mainfrom
feat/add-category-bar-chart

Conversation

@7174Andy
Copy link
Copy Markdown
Owner

Summary

  • Adds a horizontal bar chart showing spending by category to the Statistics tab, displayed below the existing metric cards
  • Makes the Statistics tab scrollable so all content remains accessible as more visualizations are added
  • Bar chart dynamically sizes to fit its content (number of categories) rather than stretching to fill space

Details

Repository layer

  • New get_spending_by_category(start_date, end_date) method on TransactionRepository — same query as get_top_spending_category but returns all categories instead of LIMIT 1, sorted descending by total spending

Service layer

  • New get_monthly_category_breakdown(year, month) on StatisticsService — delegates to repository after converting year/month to date range via existing _get_month_date_range()

GUI

  • Statistics tab content is now wrapped in a scrollable Canvas with mousewheel support (handles both macOS and Windows delta conventions)
  • Bar chart section below cards: colored horizontal bars proportional to max spending, category labels on the left, dollar amounts on the right
  • 10-color palette cycling for distinct bars
  • Empty state shows "No expenses this month" centered text
  • Chart redraws on month navigation and tab refresh

Tests

  • 4 repository tests: multiple categories sorted descending, empty, income-only, date range filtering
  • 3 service tests: with data, empty, December year boundary edge case

Design decisions

  • Native Canvas drawing (no external chart libs) — consistent with the existing HeatmapTab pattern
  • Content-sized chart — canvas height is computed from num_categories * (bar_height + gap) so the box fits its content exactly
  • Platform-aware scrolling — macOS event.delta is small (1/-1) while Windows uses multiples of 120; handled via platform.system() check

🤖 Generated with Claude Code

@7174Andy 7174Andy merged commit 5c1a5a9 into main Feb 14, 2026
3 checks passed
@7174Andy 7174Andy deleted the feat/add-category-bar-chart branch February 14, 2026 20:57
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