class PriceChart { constructor() { const el = document.getElementById("priceChartData"); if (!el || typeof Chart === "undefined") { return; } const data = JSON.parse(el.textContent); new Chart(document.getElementById("priceChart"), { type: "line", data: { labels: data.labels, datasets: data.series.map((s) => ({ label: s.name, data: s.values, borderWidth: 2, pointRadius: 2, tension: 0.2, spanGaps: true })) }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: data.series.length > 1 } }, scales: { y: { beginAtZero: false } } } }); } } const priceChart = new PriceChart();