(function() { const canvas = document.getElementById('marketcapChart'); const ctx = canvas.getContext('2d'); const years = ['2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024']; const marketcap = [94.5, 78.2, 88.6, 61.4, 71.8, 43.2, 58.7, 48.3, 65.9, 78.4]; const width = canvas.width = canvas.offsetWidth * 2; const height = canvas.height = 800; const padding = 120; const chartWidth = width - padding * 2; const chartHeight = height - padding * 2; const maxCap = Math.max(...marketcap); const minCap = Math.min(...marketcap); const range = maxCap - minCap; ctx.clearRect(0, 0, width, height); ctx.strokeStyle = '#e0e0e0'; ctx.lineWidth = 2; for(let i = 0; i <= 5; i++) { const y = padding + (chartHeight / 5) * i; ctx.beginPath(); ctx.moveTo(padding, y); ctx.lineTo(width - padding, y); ctx.stroke(); const value = (maxCap - (range / 5) * i).toFixed(1); ctx.fillStyle = '#666'; ctx.font = '28px sans-serif'; ctx.textAlign = 'right'; ctx.fillText('$' + value + 'B', padding - 20, y + 10); } ctx.strokeStyle = '#EC0000'; ctx.lineWidth = 4; ctx.beginPath(); marketcap.forEach((cap, index) => { const x = padding + (chartWidth / (years.length - 1)) * index; const y = padding + chartHeight - ((cap - minCap) / range) * chartHeight; if(index === 0) { ctx.moveTo(x, y); } else { ctx.lineTo(x, y); } }); ctx.stroke(); marketcap.forEach((cap, index) => { const x = padding + (chartWidth / (years.length - 1)) * index; const y = padding + chartHeight - ((cap - minCap) / range) * chartHeight; ctx.fillStyle = '#EC0000'; ctx.beginPath(); ctx.arc(x, y, 8, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = '#2c3e50'; ctx.font = '26px sans-serif'; ctx.textAlign = 'center'; ctx.fillText(years[index], x, height - padding + 50); }); ctx.fillStyle = '#2c3e50'; ctx.font = 'bold 32px sans-serif'; ctx.textAlign = 'center'; ctx.fillText('Market Capitalization (in Billions USD)', width / 2, 60); })();