import React, { useState } from 'react'; const GrowthComparisonWidget: React.FC = () => { const [linearRate, setLinearRate] = useState(10); // +10 per step const [expRate, setExpRate] = useState(10); // +10% per step const start = 100; const steps = 10; // Generate Data const data = Array.from({ length: steps + 1 }, (_, i) => { return { x: i, lin: start + linearRate * i, exp: start * Math.pow(1 + expRate/100, i) }; }); const maxY = Math.max(data[steps].lin, data[steps].exp); // Scales const width = 100; const height = 60; const getX = (i: number) => (i / steps) * width; const getY = (val: number) => height - (val / maxY) * height; // Inverted Y const linPath = `M ${data.map(d => `${getX(d.x)},${getY(d.lin)}`).join(' L ')}`; const expPath = `M ${data.map(d => `${getX(d.x)},${getY(d.exp)}`).join(' L ')}`; return (
Exponential growth eventually overtakes Linear growth, even if the linear rate seems larger at first!