Skip to content

feat(chart): add investment progression chart to simulation - #597

Merged
marcelorodrigo merged 7 commits into
masterfrom
feat/investment-progression-chart
Nov 20, 2026
Merged

marcelorodrigo merged 7 commits into
masterfrom
feat/investment-progression-chart

Conversation

@marcelorodrigo

@marcelorodrigo marcelorodrigo commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a Chart.js line chart comparing the net progression of Poupança, CDB/RDB, CDB/RDB pré, LCI/LCA and LCI/LCA pré over the simulated period, then refines its presentation after a visual review:

 buildProgressionDatasets(points, colors)
-  backgroundColor: withAlpha(colors[key], 0.08)
-  fill: true
+  fill: false                    # every series renders line-only

 palette (light / dark suffix logic unchanged)
   Poupança          amber
   CDB / RDB         sky
-  CDB / RDB pré     emerald
-  LCI / LCA         violet      # violet vs indigo were near-identical
-  LCI / LCA pré     indigo
+  CDB / RDB pré     rose
+  LCI / LCA         teal
+  LCI / LCA pré     violet

 buildProgressionOptions(colors, maxDay)
   scales.x: type linear
+             min: 0, max: maxDay  # axis ends at the last simulated day

The x-axis max matters: without it Chart.js rounds the linear scale up to the next "nice" number past the period (e.g. 720 days renders out to 800), leaving dead space on the right.

Stack context: beyond the chart feature itself (4b0dc54), the branch carries the dev-server pre-bundling and ESM fixes needed to run it (0474bd9, 6f1256e) and the scoped typecheck guardrail (2c77cc0).

Evidence

  • Before: chart.spec asserted fill: true with a tinted backgroundColor, and the x-axis had no bounds — x.min/x.max were undefined.
    After: chart.spec asserts every dataset has fill: false and no backgroundColor, and pins x.min === 0 / x.max === maxDay (10/10 in test/unit/lib/chart.spec.ts).

  • Full CI order passes locally: pnpm lint → pnpm typecheck → full suite 125/125 → pnpm generate.

  • Visual change — worth an eyeball in both light and dark themes before merge; the new rose/teal/violet hues were chosen for separation including common color-blindness.

Merge Danger

Door: two-way

Pure presentation change; revert restores the filled-area chart.

Blast Radius: chart display only

No financial logic touched (app/src untouched); buildProgressionOptions callers are all updated in the same branch.

Summary by CodeRabbit

  • New Features
    • Added an investment progression chart to the simulation, showing estimated growth over time for savings and fixed-income options, including available fixed-rate investments.
    • The chart adapts to the selected theme, formats values in Brazilian reais, and provides accessible labels. It displays a loading state when chart rendering is unavailable.
  • Quality Improvements
    • Added automated type checks to the build and test workflow and updated project guidance with type-checking instructions.

Sample the net value of each simulated investment over time (CDB net of IR/IOF,
Poupança and LCI/LCA exempt) in a new pure getNetProgression() module, and
render it as a theme-aware line chart above the result cards.

The chart reads its palette from Tailwind v4 CSS variables so dark mode and
future palette changes restyle the canvas, and it waits for a real 2D canvas
before mounting Chart.js so DOM-less test environments keep working.

vue-chartjs is pinned to 5.3.7: the 5.3.6 tarball on the registry ships without
dist/index.js/index.cjs, so pnpm's minimum release age is bypassed for it.
Address code-review findings:
- move chart presentation helpers to app/lib/chart.ts, keeping app/src for the
  pure financial logic documented in AGENTS.md
- sample progression points at monthly marks for typical durations instead of
  a fixed 10-day step
- pin the early-redemption semantics with tests: IOF inside the 30-day window,
  none at day 30, and each point using its own IR bracket
- correct the ProgressionPoint type import in app/lib/chart.ts and the
  possibly-undefined regex capture in parseHexColor (tsc --noEmit is clean for
  app sources again)
- plot progression points on a linear day axis so uneven sample intervals keep
  true time proportions instead of equal-width categories
- tighten the endpoint invariant tests to exact equality with the result-card
  values
Close the retro findings:
- add tsconfig.typecheck.json (app/src + app/lib only) with a pnpm typecheck
  script, wired into CI between lint and test; full-project tsc stays dirty
  with pre-existing test typings, so the guardrail is scoped
- document the happy-dom canvas gate for canvas-based components and the
  pnpm minimumReleaseAge pin/exclude workflow in AGENTS.md
Vite discovered chart.js and vue-chartjs at runtime on the first page
load, invalidating the optimized-dep hashes mid-flight: the browser's module
imports then failed (Importing a module script failed, cascading into an
undefined head.push), leaving the SPA broken on first load. Adding both to
vite.optimizeDeps.include pre-bundles them at server start.

Verified by walking the whole dev-server module graph from the SPA entry:
265 modules, zero non-200 responses on a cold start with a cleared Vite
cache, and no runtime dependency discovery.
nuxt-schema-org 7.0.1 ships a reactive client init plugin when
ssr is false. Nuxt 4.6.4's injectHead silently returns undefined
in the SPA plugin context, so the plugin's head.push throws on
app boot and Safari reports "undefined is not an object
(evaluating 'head.push')" — the dev server has been unusable
since the dependency bump in #596.

Remove the module: it requires SSR to add SEO value, this site is
a static SPA, so its client-side graph was invisible to crawlers
and unused by app code. Drop the site block and the
@unhead/schema-org/vue optimizeDeps entry along with it.

Add "type": "module" to package.json to stop Node re-parsing
nuxt.config.ts on every dev/test run (MODULE_TYPELESS_PACKAGE_JSON
warning).

Verified: cold dev start with no warnings or errors, module-graph
walk of 253 modules with zero failures and no schema-org modules
served, lint, typecheck, 124 tests, generate.
- spread the five series across distinct hues: CDB/RDB pre moves from
  emerald to rose, LCI/LCA from violet to teal, LCI/LCA pre from indigo
  to violet (amber/sky unchanged)
- render every series as a line-only trace (fill: false) instead of
  8%-alpha filled areas; drop the now-unused withAlpha/parseHexColor
- pin the day axis to the simulated period (min 0, max = last sampled
  day) so Chart.js no longer pads the right side with empty space
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The application adds sampled net investment progression calculations and displays the results in a themed chart. The CI workflow adds a scoped TypeScript check between linting and tests.

Changes: Investment progression chart

Layer / File(s) Summary
Sampled net progression
app/src/progression.ts, test/unit/src/progression.spec.ts
getNetProgression returns sampled values for savings, CDB, and LCX products, with optional prefixado series. Tests cover sampling, net values, taxes, and optional rates.
Chart datasets, options, and setup
app/lib/chart.ts, test/unit/lib/chart.spec.ts, package.json, nuxt.config.ts, pnpm-workspace.yaml, AGENTS.md
Chart utilities format currency, build datasets and define chart options. Chart dependencies and Nuxt configuration are updated. Tests cover formatting, datasets, and options.
Chart component and simulation integration
app/components/InvestmentChart.vue, app/components/InvestmentSimulation.vue
The simulation passes progression points to InvestmentChart. The component checks for a usable 2D canvas context and nonempty points before displaying the chart.

Scoped typecheck in CI

Layer / File(s) Summary
Typecheck command and CI step
tsconfig.typecheck.json, package.json, .github/workflows/ci.yml, AGENTS.md
The typecheck script checks TypeScript files under app/src and app/lib. CI runs the command after linting and before tests. The project guidance documents its scope and workflow position.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant InvestmentSimulation
  participant getNetProgression
  participant InvestmentChart
  participant chartUtilities
  InvestmentSimulation->>getNetProgression: calculate sampled progression
  getNetProgression-->>InvestmentSimulation: return progression points
  InvestmentSimulation->>InvestmentChart: pass progression points
  InvestmentChart->>chartUtilities: build datasets and options
Loading
Merge Risk: Minimal · up to 60410

This adds a net progression chart to the simulation and a scoped typecheck step in CI. No concrete defects were found, so it looks safe to merge after the usual visual check in light and dark themes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: a new investment progression chart added to the investment simulation. The raw summary confirms a chart component (InvestmentChart.vue), chart utilities (chart.ts), pr…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a new investment progression chart added to the investment simulation. The raw summary confirms a chart component (InvestmentChart.vue), chart utilities (chart.ts), progression computation (progression.ts), and its wiring into InvestmentSimulation.vue. The title follows conventional commit form and is concise. It omits the other changes (typecheck script, CI step, dependency swaps), which is acceptable because it does not need to cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

app/components/InvestmentChart.vue

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

app/components/InvestmentSimulation.vue

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

app/lib/chart.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

  • 5 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 00726987-73cb-4629-b84d-5796af3b1102
Commits

Reviewing files that changed from the base of the PR and between 03780f9 and 60410b1.

Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 12

  • .github/workflows/ci.yml
  • AGENTS.md
  • app/components/InvestmentChart.vue
  • app/components/InvestmentSimulation.vue
  • app/lib/chart.ts
  • app/src/progression.ts
  • nuxt.config.ts
  • package.json
  • pnpm-workspace.yaml
  • test/unit/lib/chart.spec.ts
  • test/unit/src/progression.spec.ts
  • tsconfig.typecheck.json

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@marcelorodrigo
marcelorodrigo merged commit 1e86f50 into master Nov 20, 2026
4 checks passed
@marcelorodrigo
marcelorodrigo deleted the feat/investment-progression-chart branch November 20, 2026 18:52
marcelorodrigo added a commit that referenced this pull request Nov 20, 2026
…a" (#598)

## Summary

The site is a client-only SPA (`ssr: false`): every `useSeoMeta` call
ran in the browser, so scrapers saw no description, no og:image, no
canonical, no JSON-LD — and the hand-maintained `sitemap.xml` was
already missing `/como-calcular-imposto-de-renda`. This PR makes the
whole site prerendered and hands SEO generation to `@nuxtjs/seo`:

```diff
 nuxt.config.ts
-  ssr: false
+  ssr: true            // runs at build time only — `nuxi generate` emits static HTML
+  modules: [ '@nuxtjs/seo' ]
+  site: { url, name, description, trailingSlash }
+  routeRules: ogImage per page  // rendered at build from app/components/OgImage/Main.satori.vue
```

- Per-page `useSeoMeta` (title/description/twitter card) +
`useSchemaOrg` (SoftwareApplication on home, FAQPage + BreadcrumbList on
guides)
- Sitemap, robots.txt, canonicals, `og:image` PNGs,
`_headers`/skew-protection assets — all generated at build;
hand-maintained `public/sitemap.xml` deleted
- Visible "Perguntas frequentes" sections on both guides, matching the
FAQPage JSON-LD exactly
- `pnpm verify:seo` (35 checks over `.output/public`) wired into CI and
publish, so the generate step can never silently regress
- AGENTS.md updated for the prerendered world

About #597: that PR removed `nuxt-schema-org` because under `ssr: false`
its SPA plugin crashed the dev server and its graph was client-only.
Both reasons dissolve under `ssr: true` — the module is back as part of
`@nuxtjs/seo`, and the dev server boots clean.

## Evidence

- **Before:** `curl https://rendafixa.github.io` → no `<meta
name="description">`, no `og:*`, no JSON-LD in served HTML; sitemap
missing one of four pages.
**After:** every page ships title/description/canonical/og:image/twitter
card in the static HTML; `pnpm verify:seo` passes all 35 checks (titles,
lang, canonicals, og:image PNG existence, JSON-LD types, FAQ questions
visible in markup, 4 sitemap locs, robots); `pnpm test` → 133 passed;
`pnpm generate` clean with no dev warnings.

## Merge Danger

**Door:** two-way — pure build-output change, hosting (GitHub Pages
static) untouched, `git revert` restores the SPA.

**Blast Radius:** site-wide rendering — pages now render server-side, so
anything assuming browser-only setup would break at build time (generate
+ tests cover all four pages). Post-deploy, the og:image PNGs need a
human eyeball, and Search Console should get the resubmitted sitemap +
indexing request.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Added FAQs about income tax, IOF, and savings-account interest to the
relevant guides.
* Added social sharing images and structured page information across the
main pages, with richer search-result details.
* **Improvements**
* Updated the site title and description to reflect the calculator and
its supported investments.
  * The full site title now appears in the header on small screens.
  * Updated guide links to use consistent trailing slashes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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