Skip to content

fix: downsample YieldBreakdownChart and memoize chart components for long ranges - #1099

Merged
Junirezz merged 1 commit into
Junirezz:mainfrom
esthertitilayo-dev:fix/1041-yield-breakdown-chart-downsampling
Jul 29, 2026
Merged

fix: downsample YieldBreakdownChart and memoize chart components for long ranges#1099
Junirezz merged 1 commit into
Junirezz:mainfrom
esthertitilayo-dev:fix/1041-yield-breakdown-chart-downsampling

Conversation

@esthertitilayo-dev

Copy link
Copy Markdown
Contributor

Summary

Closes #1041.

Heads up for reviewers: #1041's title is an exact duplicate of #982, which was already resolved by #1027 — that PR added sampleChartSeries() downsampling to APYTrendChart and VaultPerformanceChart. This PR does not re-do that work. It closes the one real gap left over and adds a related, narrow perf win:

  • YieldBreakdownChart never got the downsampling treatment the other two charts got. It's still capped at 90 mock days today so this isn't user-visible yet, but it was the one chart that would silently render every raw point once its data source grows past the shared 120-point render cap (e.g. once it's wired to a real multi-year history like the other charts). Brought it in line: sampleChartSeries() before render, animation disabled on downsampled series (matching the other two), and the displayed period total is computed from the full (undownsampled) data so it stays accurate regardless of render-side sampling.
  • Wrapped all three chart components in React.memo. None of their props change identity across unrelated parent re-renders (APYTrendChart's default data is a stable module constant, VaultPerformanceChart takes no props at all, YieldBreakdownChart's only prop is a primitive number), so this is a safe, low-risk change that avoids repeat Recharts SVG re-renders whenever something unrelated elsewhere in the tree re-renders (TVL ticker, balance polling, etc.) — this matters most for the largest, longest-range series.

Test plan

  • npx vitest run on the touched files (YieldBreakdownChart, APYTrendChart, chartSeries) — 16/16 passed
  • Added YieldBreakdownChart.test.tsx (none existed before)
  • npx tsc -b — no new type errors (one pre-existing, unrelated ToastCenter.tsx error present on main before this change too)
  • Maintainer to confirm no visual regression in the Yield Earnings chart on /portfolio

🤖 Generated with Claude Code

…long ranges

APYTrendChart and VaultPerformanceChart already downsample their series via
sampleChartSeries() before handing data to Recharts, but YieldBreakdownChart
never got the same treatment, so an "ALL" range on a long-lived vault would
render every raw point instead of the shared 120-point cap. Bring it in line
with the other two charts, disabling animation on downsampled series the same
way, and keep the displayed period total computed from the full (undownsampled)
data so it stays accurate.

Also wrap all three chart components in React.memo, since none of their props
change identity across unrelated parent re-renders (APYTrendChart's default
data is a stable module constant, VaultPerformanceChart takes no props, and
YieldBreakdownChart's only prop is a primitive number) — this avoids repeat
Recharts SVG re-renders on every unrelated poll/tick elsewhere in the tree,
which matters most for the largest, longest-range series.

Related to Junirezz#1041, which duplicates Junirezz#982 (already resolved by Junirezz#1027 for the
other two charts).
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@esthertitilayo-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Junirezz
Junirezz merged commit d26220a into Junirezz:main Jul 29, 2026
18 of 24 checks passed
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.

Frontend: Improve chart rendering performance for long time ranges

2 participants