const PALETTE = ['#2f5bea', '#e0702b', '#1b9e77', '#a14b9c', '#c9a227', '#d6336c', '#37a0d6', '#6b8e23']; /** Swimlane: one lane per subfield, papers as dots on a venue-date axis. */ export function SubfieldTimeline({ lanes, cite }: { lanes: { name: string; papers: { id: number; date: string; title: string }[] }[]; cite: Record }) { const all = lanes.flatMap((l) => l.papers); if (!all.length) return null; const ts = (d: string) => new Date(d + (d.length === 7 ? '-15' : '') + 'T00:00:00Z').getTime(); const lo = Math.min(...all.map((p) => ts(p.date))) - 25 * 864e5, hi = Math.max(...all.map((p) => ts(p.date))) + 25 * 864e5; const W = 760, L = 210, R = 16, laneH = 34, top = 8, H = top + lanes.length * laneH + 30; const X = (t: number) => L + ((t - lo) / (hi - lo || 1)) * (W - L - R); const months: number[] = []; for (let d = new Date(lo); d.getTime() <= hi; d.setUTCMonth(d.getUTCMonth() + 1)) months.push(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1)); return ( {months.map((m) => ({new Date(m).toISOString().slice(0, 7)}))} {lanes.map((l, i) => { const y = top + i * laneH + laneH / 2; const byDate: Record = {}; return ( {l.name.length > 32 ? l.name.slice(0, 31) + '…' : l.name} {l.papers.map((p) => { const k = (byDate[p.date] = (byDate[p.date] ?? 0) + 1); const dx = ((k - 1) % 6) * 7 - 17, dy = Math.floor((k - 1) / 6) * 7 - 5; return ( {`[${cite[p.id]}] ${p.title} (${p.date})`} ); })} ); })} ); } /** Horizontal workflow: boxes with arrows, wrapping. */ export function WorkflowFlow({ steps }: { steps: string[] }) { if (!steps.length) return null; return (
{steps.map((s, i) => (
{i + 1}{s}{i < steps.length - 1 && →}
))}
); }