<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: "doughnut",
data: {
labels: ["教育", "交通", "醫療", "國防"],
datasets: [{
label: "預算分配",
data: [40, 30, 20, 10],
backgroundColor: [
"rgba(255, 99, 132, 0.7)",
"rgba(54, 162, 235, 0.7)",
"rgba(255, 206, 86, 0.7)",
"rgba(75, 192, 192, 0.7)"
],
borderColor: [
"rgba(255, 99, 132, 1)",
"rgba(54, 162, 235, 1)",
"rgba(255, 206, 86, 1)",
"rgba(75, 192, 192, 1)"
],
borderWidth: 1
}]
},
options: {
responsive: true,
cutout: "50%",
plugins: {
legend: {
position: "right"
}
}
}
});
</script>