<!DOCTYPE html> <html lang="ja"> <head> <title>ในใ๐ ในใ๐ ใฐใ๐ ใฐใฉใ๐คค</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <script src="https://cdn.jsdelivr.net/npm/chart.js/dist/chart.min.js"></script> </head> <body> <div class="chart-container"> <canvas id="myChart"></canvas> </div> </body> </html>
const labels = [ 'Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange' ]; const data = { labels: labels, datasets: [{ label: 'ในใ๐ ในใ๐ ใฐใ๐ ใฐใฉใ๐คค', data: [5, 7, 3, 5, 2, 3], backgroundColor: [ 'rgba(255, 99, 132, .7)', 'rgba( 54, 162, 235, .7)', 'rgba(255, 206, 86, .7)', 'rgba( 75, 192, 192, .7)', 'rgba(153, 102, 255, .7)', 'rgba(255, 159, 64, .7)' ], borderColor: [ 'rgba(255, 99, 132, 1)', 'rgba( 54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba( 75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] } const config = { type: 'bar', data: data, options: { maintainAspectRatio: false, scales: { y: { beginAtZero: true } } } } const myChart = new Chart( document.getElementById('myChart').getContext('2d'), config ); //myChart.canvas.parentNode.style.width = '200px'; //myChart.canvas.parentNode.style.height = '400px';
.chart-container { position: relative; width: 200px; height: 400px }