Skip to content

Enhanced Monthly chart to display cumulative and monthly data via UI toggle. Addresses issue #5.#7

Merged
MarkT1065 merged 6 commits into
MarkT1065:mainfrom
antamy:feature/add-chart-monthly-toggle
Oct 26, 2025
Merged

Enhanced Monthly chart to display cumulative and monthly data via UI toggle. Addresses issue #5.#7
MarkT1065 merged 6 commits into
MarkT1065:mainfrom
antamy:feature/add-chart-monthly-toggle

Conversation

@antamy
Copy link
Copy Markdown
Contributor

@antamy antamy commented Oct 11, 2025

The original implementation displayed a cumulative gains chart by month. This enhancement adds a cumulative / monthly button group to the UI so that the chart either displays cumulative gains or gains by month. Graph and axis titles have been updated accordingly.

In addition, code that deals with the Totals pane at the top of the page has been refactored. It was originally embedded within the code to create the cumulatvive chart and has now been extracted as a separate updateTotalsPanelValues() function that's called from the chart creation function.

Variables have been renamed for clarity:

cumulativeGainsChartgainsOverTimeChartInstance
cumulativeGainsCtxgainsOverTimeCtx

Function renamed to createGainsOverTimeChart()

cumulativePutsMonthDataputsMonthlyData (now represents the raw monthly amounts)
putsCumulativeData stays as is (represents the running totals)

Similar changes for calls, cap gains, and dividends

Cleaner logic flow:

Load monthly data first
Calculate cumulative from monthly
Choose which dataset to display based on view mode
Update totals panel with final running totals

@MarkT1065
Copy link
Copy Markdown
Owner

● Pull Request #7 Evaluation

Title: Enhanced Monthly chart to display cumulative and monthly data via UI toggle

Status: OPEN | Author: antamy (aroby)

Summary: Adds a cumulative/monthly toggle to the Monthly page chart, allowing users to switch between viewing cumulative gains over time and monthly gains.

Changes Overview

Files Modified:

  • internal/web/templates/monthly.html (+265, -151)
  • Binary database file (test data)
  • New screenshots added

Code Quality Assessment

Strengths:

  1. Clean Refactoring: Extracted totals panel logic into updateTotalsPanelValues() function
  2. Smart Naming: Renamed variables for clarity (e.g., cumulativeGainsChart → gainsOverTimeChartInstance)
  3. Proper Chart Management: Destroys existing chart before creating new one to prevent memory leaks
  4. Consistent Data Flow: Loads monthly data first, calculates cumulative from it
  5. Good UX: Toggle buttons with clear visual states (green for active, gray for inactive)
  6. Maintains Functionality: Totals panel still shows cumulative YTD values regardless of view mode

Technical Implementation:

  • Uses Chart.js with proper instance management
  • Toggle buttons use inline styles (acceptable for this simple case)
  • Dynamic dataset switching based on viewMode parameter
  • Separate y-axis labels for cumulative vs monthly views
  • Color coding maintained for capital gains (red for losses, green for profits)

Minor Concerns:

  1. Inline Styles: Toggle button styles are inline rather than in CSS file
  2. DOMContentLoaded: Event listener wrapping might be redundant if script is already at page bottom
  3. Binary File: data/test_db.db included in PR (should be gitignored)

Recommendation: APPROVE with minor suggestions

This is a well-executed enhancement that:

  • Directly addresses issue Monthly chart - different views #5
  • Improves code organization through refactoring
  • Adds valuable functionality without breaking existing features
  • Follows good coding practices (proper cleanup, clear naming)

Optional improvements for follow-up:

  1. Move toggle button styles to styles.css
  2. Consider removing test database from git tracking
  3. Add CSS transition effects to the toggle buttons if not already present

The PR is ready to merge as-is, with the minor improvements being nice-to-haves rather than blockers.

@MarkT1065
Copy link
Copy Markdown
Owner

I appreciate this new feature! Seeing results by monthly and cumulative over time is a nice improvement. Thanks for contributing! I'm heading out of town on PTO tomorrow. Mind if we merge when I get back?

@antamy
Copy link
Copy Markdown
Contributor Author

antamy commented Oct 13, 2025

I appreciate this new feature! Seeing results by monthly and cumulative over time is a nice improvement. Thanks for contributing! I'm heading out of town on PTO tomorrow. Mind if we merge when I get back?

Sure, that's fine. I'll look at the follow-ups in the meantime. This is the first time I've used git, Go and Claude plus my development experience was many years ago and more backend than frontend, so I'm quickly getting up to speed! Enjoy your time off.

@antamy
Copy link
Copy Markdown
Contributor Author

antamy commented Oct 23, 2025 via email

@MarkT1065
Copy link
Copy Markdown
Owner

MarkT1065 commented Oct 23, 2025 via email

@MarkT1065
Copy link
Copy Markdown
Owner

@antamy the code LGTM. Thanks for the contribution! I left 2 comments above (fixing a 404 on the readme and reverting the db). I can merge after those two fixes.

Copy link
Copy Markdown
Owner

@MarkT1065 MarkT1065 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I missed this step before heading on PTO. I reviewed and left comments but didn't "submit request changes".

Thanks for your patience!

Comment thread data/test_db.db
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were any changes were made to this or was this the result of test runs?

we probably don't need to check in changes to this database instance except for schema changes. i don't really have this written in any contributors guide because this project has been single author to date. I really appreciate your Pull Request!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes, not sure why this was included. I figured out how to remove it.

Comment thread screenshots/monthly-c.png Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New screenshots look good. The link on the README is to the old screenshot, so it would 404 now.

Claude didn't find that in review. I noticed it looking at your branch in github. so much for the AI overlords? :P

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I decided to remove the two screenshots and just have one, since both of them didn't really add anything to the README. I did update the README to address a spelling mistake.

@MarkT1065
Copy link
Copy Markdown
Owner

LGTM. squashing and merging.

@MarkT1065 MarkT1065 merged commit 30d5672 into MarkT1065:main Oct 26, 2025
@MarkT1065
Copy link
Copy Markdown
Owner

@antamy thank you for this contribution!

antamy added a commit to antamy/wheeler that referenced this pull request Oct 30, 2025
…toggle. Addresses issue MarkT1065#5. (MarkT1065#7)

* Enhanced Monthly chart to display cumulative and monthly data via UI toggle

* Enhanced Monthly chart to display cumulative and monthly data via UI toggle (code and screenshots)

* Added screenshots

* Update README.md, remove previous screenshots and add new screenshot

* Remove test database from tracking and add to .gitignore
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.

2 participants