/* ─── Dual-career line chart: 이정후 KBO → MLB ────────────────────────── */ /* Uses Chart.js (loaded in index.html). One canvas, two datasets that share x-axis. */ function CareerChart() { const ref = React.useRef(null); const chartRef = React.useRef(null); const [metric, setMetric] = React.useState("ops"); React.useEffect(() => { if (!ref.current) return; if (chartRef.current) { chartRef.current.destroy(); } const seasons = window.KB_DATA.career.seasons; const labels = seasons.map(s => s.y); // Build dual datasets: KBO points where lg==='kbo', MLB points where lg==='mlb' const kboData = seasons.map(s => s.lg === "kbo" ? s[metric] : null); const mlbData = seasons.map(s => s.lg === "mlb" ? s[metric] : null); const ctx = ref.current.getContext("2d"); // Gradient fills const kboGrad = ctx.createLinearGradient(0, 0, 0, 280); kboGrad.addColorStop(0, "rgba(75,156,255,0.32)"); kboGrad.addColorStop(1, "rgba(75,156,255,0)"); const mlbGrad = ctx.createLinearGradient(0, 0, 0, 280); mlbGrad.addColorStop(0, "rgba(255,75,75,0.32)"); mlbGrad.addColorStop(1, "rgba(255,75,75,0)"); chartRef.current = new Chart(ctx, { type: "line", data: { labels, datasets: [ { label: "KBO (키움)", data: kboData, borderColor: "#4B9CFF", backgroundColor: kboGrad, borderWidth: 2.5, pointRadius: 5, pointHoverRadius: 7, pointBackgroundColor: "#4B9CFF", pointBorderColor: "#0B0E14", pointBorderWidth: 2, tension: 0.32, fill: true, spanGaps: false, }, { label: "MLB (SF)", data: mlbData, borderColor: "#FF4B4B", backgroundColor: mlbGrad, borderWidth: 2.5, pointRadius: 5, pointHoverRadius: 7, pointBackgroundColor: "#FF4B4B", pointBorderColor: "#0B0E14", pointBorderWidth: 2, tension: 0.32, fill: true, spanGaps: false, }, ], }, options: { responsive: true, maintainAspectRatio: false, interaction: { mode: "index", intersect: false }, plugins: { legend: { display: false }, tooltip: { backgroundColor: "#161B22", borderColor: "rgba(255,255,255,0.14)", borderWidth: 1, padding: 12, titleColor: "#E6EDF3", bodyColor: "#8B949E", titleFont: { family: "Inter", weight: "600", size: 12 }, bodyFont: { family: "Inter", size: 12 }, displayColors: true, boxPadding: 4, callbacks: { label: (ctx) => { if (ctx.parsed.y === null) return null; const k = metric === "ops" ? "OPS" : metric === "war" ? "WAR" : "HR"; const v = metric === "ops" ? ctx.parsed.y.toFixed(3).replace(/^0/,"") : ctx.parsed.y.toFixed(1); return `${ctx.dataset.label} ${k} ${v}`; } } } }, scales: { x: { grid: { color: "rgba(255,255,255,0.04)", drawTicks: false }, ticks: { color: "#6E7681", font: { family: "Inter", size: 11 } }, border: { color: "rgba(255,255,255,0.08)" } }, y: { grid: { color: "rgba(255,255,255,0.04)" }, ticks: { color: "#6E7681", font: { family: "Inter", size: 11 }, callback: (v) => metric === "ops" ? Number(v).toFixed(2).replace(/^0/,"") : v }, border: { display: false } } } } }); return () => { if (chartRef.current) chartRef.current.destroy(); }; }, [metric]); const c = window.KB_DATA.career; const last = c.seasons[c.seasons.length - 1]; const peakKbo = c.seasons.filter(s => s.lg === "kbo").reduce((a,b) => b.ops > a.ops ? b : a); return (
이중 커리어

이정후 KBO → MLB 여정

{[["ops","OPS"],["war","WAR"],["hr","HR"]].map(([k,l])=>( ))}
{/* Header strip — legend + key milestones */}
KBO 2017–2022 · 키움 히어로즈
MLB 2024– · 샌프란시스코
KBO 정점
{peakKbo.ops.toFixed(3).replace(/^0/,"")} {peakKbo.y.split(" ")[0]}
현재 MLB
{last.ops.toFixed(3).replace(/^0/,"")} 2026
※ 2023년은 부상으로 시즌 데이터 없음 (점선 구간) 출처 · KBO 공식 · MLB Stats API
); } window.CareerChart = CareerChart;