diff --git a/resources/js/components/accounts/account-balance-chart.tsx b/resources/js/components/accounts/account-balance-chart.tsx index 7d582c44..b09ec3a7 100644 --- a/resources/js/components/accounts/account-balance-chart.tsx +++ b/resources/js/components/accounts/account-balance-chart.tsx @@ -601,6 +601,25 @@ export function AccountBalanceChart({ return null; }, [activeChartData, currentInvestedAmount, hasCurrencyToggle]); + // A lone invested point (e.g. a freshly connected account whose history was + // backfilled with balances but cost basis only for the latest date) renders + // as a single dot with nothing to connect to. Only draw the invested + // overlay once there are at least two points to plot. + const hasInvestedSeries = useMemo( + () => + activeChartData.filter( + (point) => + point.invested_amount !== null && + point.invested_amount !== undefined, + ).length >= 2, + [activeChartData], + ); + + const showInvestedOverlay = + showInvestmentBenefits && + activeCurrentInvestedAmount !== null && + hasInvestedSeries; + const activeShortTrend = useMemo(() => { if (currencyMode !== 'user' || !hasCurrencyToggle) return shortTrend; const historicalData = activeChartData.filter((d) => !d.projected); @@ -1043,23 +1062,20 @@ export function AccountBalanceChart({ activeDot={{ r: 5 }} fillOpacity={1} /> - {showInvestmentBenefits && - activeCurrentInvestedAmount !== - null && ( - - )} + {showInvestedOverlay && ( + + )} - ) : showInvestmentBenefits && - activeCurrentInvestedAmount !== null ? ( + ) : showInvestedOverlay ? (