Changed around line 1
+ function getRandomData() {
+ const data = [];
+ let lastValue = Math.random() * 100;
+ for (let i = 0; i < 30; i++) {
+ lastValue += (Math.random() - 0.5) * 10;
+ data.push(lastValue);
+ }
+ return data;
+ }
+
+ function createChart(canvasId, label) {
+ const ctx = document.getElementById(canvasId).getContext('2d');
+ return new Chart(ctx, {
+ type: 'line',
+ data: {
+ labels: Array.from({ length: 30 }, (_, i) => i + 1),
+ datasets: [{
+ label: label,
+ data: getRandomData(),
+ borderColor: '#ff7e5f',
+ backgroundColor: 'rgba(255, 126, 95, 0.1)',
+ borderWidth: 2,
+ pointRadius: 0,
+ tension: 0.4
+ }]
+ },
+ options: {
+ responsive: true,
+ maintainAspectRatio: false,
+ scales: {
+ x: {
+ display: false
+ },
+ y: {
+ display: false
+ }
+ },
+ plugins: {
+ legend: {
+ display: false
+ }
+ }
+ }
+ });
+ }
+
+ const btcChart = createChart('btcCanvas', 'BTC');
+ const ethChart = createChart('ethCanvas', 'ETH');
+ const adaChart = createChart('adaCanvas', 'ADA');
+
+ setInterval(() => {
+ btcChart.data.datasets[0].data = getRandomData();
+ btcChart.update();
+
+ ethChart.data.datasets[0].data = getRandomData();
+ ethChart.update();
+
+ adaChart.data.datasets[0].data = getRandomData();
+ adaChart.update();
+ }, 5000);