<script src="https://www3.nhu.edu.tw/js/public/chart.js"></script>
<style>
#trendChart {
width:600px;
margin: 20px auto;
}
@media screen and (max-width: 736px) {
#trendChart {
width:400px;
height:600px !important;
}
}
</style>
<canvas id="trendChart" ></canvas>
<script>
const ctx = document.getElementById("trendChart");
new Chart(ctx, {
type: "line",
data: {
labels: ["1月", "2月", "3月", "4月", "5月", "6月"],
datasets: [{
label: "銷售額",
data: [0, 150, 170, 140, 180, 800],
borderColor: "blue",
backgroundColor: "rgba(0, 0, 255, 0.1)",
fill: true,
tension: 0.9
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>