Extend portfolio chart to always show today's data point

Previously the chart stopped at the last purchase date. Now a final
point for today is appended so current portfolio value vs total
invested is always visible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 19:18:27 +01:00
parent e93b9dfa53
commit c1371e9c72
@@ -42,6 +42,14 @@ export default function PortfolioChart({ purchases, stats }) {
investedValues.push(parseFloat(cumInvested.toFixed(2)));
});
const todayLabel = new Date().toLocaleDateString();
if (labels.length === 0 || labels[labels.length - 1] !== todayLabel) {
const currentVal = cumBtc * (stats?.current_price || 0);
labels.push(todayLabel);
portfolioValues.push(parseFloat(currentVal.toFixed(2)));
investedValues.push(parseFloat(cumInvested.toFixed(2)));
}
const currentPrice = stats?.current_price || 0;
const breakEvenLine = labels.map(() => stats?.average_price || 0);