diff --git a/btc-portfolio/frontend/src/components/PortfolioChart.js b/btc-portfolio/frontend/src/components/PortfolioChart.js index a0e3e8d..f8a0ffd 100644 --- a/btc-portfolio/frontend/src/components/PortfolioChart.js +++ b/btc-portfolio/frontend/src/components/PortfolioChart.js @@ -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);