import React from "react"; import { AreaChart, Area, XAxis, YAxis, Tooltip, ResponsiveContainer, Legend, ReferenceLine, } from "recharts"; function dollars(v) { if (v >= 1_000_000_000) return "$" + (v / 1_000_000_000).toFixed(1) + "B"; if (v >= 1_000_000) return "$" + (v / 1_000_000).toFixed(1) + "M"; if (v >= 1_000) return "$" + (v / 1_000).toFixed(0) + "K"; return "$" + v.toFixed(0); } function pct(v) { return (v * 100).toFixed(1) + "%"; } export default function GoalProjection({ goalProjection, financialGoal }) { const { probability_of_success, median_outcome, surplus_or_shortfall, required_cagr, method, yearly_projections, } = goalProjection; const target = financialGoal?.target_amount || 1_000_000; const years = financialGoal?.time_horizon_years || 20; const goalType = financialGoal?.goal_type || "Retirement"; const isOnTrack = surplus_or_shortfall >= 0; const tooltipFormatter = (value, name) => { const labels = { p90: "90th Percentile", p50: "Median Path", p10: "10th Percentile", }; return [dollars(value), labels[name] || name]; }; return (

Goal-Based Planning

{/* Status Banner */}
🎯 {goalType}: {pct(probability_of_success)} probability of reaching {dollars(target)} in {years} years
Probability of Success = 0.7 ? "#22c55e" : probability_of_success >= 0.4 ? "#f59e0b" : "#ef4444" }} > {pct(probability_of_success)}
Median Outcome {dollars(median_outcome)}
Surplus / Shortfall {isOnTrack ? "+" : ""} {dollars(surplus_or_shortfall)} {isOnTrack ? "↑ On track" : "↓ Off track"}
Required CAGR {pct(required_cagr)}

Projection: {goalType}

`Year ${y}`} /> {/* 10th-90th percentile band */} {/* Median path */} {/* Target line */}
Simulation Methodology
{method}
); }