| 12345678910111213141516171819202122232425262728293031323334353637 |
- 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();
|