options: {
scales: {
y: {
beginAtZero: true
}
}
}
Here we have used beginAtZero: true property of Chart.js to set the minimum scale value to zero.
<canvas id="my_chart" width="400" height="200" ></canvas>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js"></script>
<script>
var ctx = document.getElementById("my_chart").getContext("2d");
new Chart(ctx, {
type: 'bar',
data: {
labels: ["January", "February", "March", "April"],
datasets: [{
label: "Title on top",
data: [30, 40, 50, 60],
fill: false,
backgroundColor: "#eebcde ",
borderColor: "#eebcde",
borderCapStyle: 'butt',
borderDash: [5, 5],
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true,
}
}
}
});
</script>
0 Comments