<script src="https://www3.nhu.edu.tw/js/public/chart.js"></script>
<style>
#myChart {
width:600px;
margin: 20px auto;
}
@media screen and (max-width: 736px) {
#myChart {
width:400px;
height:600px !important;
}
}
</style>
<canvas id="myChart" ></canvas>
<script>
const ctx = document.getElementById("myChart");
new Chart(ctx, {
type: "bubble",
data: {
datasets: [{
label: "城市人口統計",
data: [
{ x: 10, y: 20, r: 15 },
{ x: 15, y: 10, r: 10 },
{ x: 25, y: 30, r: 20 },
{ x: 30, y: 15, r: 25 }
],
backgroundColor: "rgba(54, 162, 235, 0.6)",
borderColor: "rgba(54, 162, 235, 1)"
}]
},
options: {
responsive: true,
scales: {
x: {
beginAtZero: true
},
y: {
beginAtZero: true
}
},
plugins: {
legend: {
position: "top"
}
}
}
});
</script>