When using the following code to generate a chart, I am not able to set the scale to begin at zero, even setting that option.
Here is the code (JSFiddle)
var simpleChart = new Chart(document.getElementById('chart'), {
type: 'bar',
data: {
labels: ['Online', 'Offline'],
datasets: [{
label: "# of servers",
data: [1, 7],
backgroundColor: [
'#009245',
'#c02a31'
]
}]
},
options: {
title: {
display: false
},
scales: {
yAxes: [{
beginAtZero: true
}]
}
}
});
Is this a bug? What should I do to be able to set the scale to really start at 0?
Also, how can I disable that "# of servers"
label from being rendered?
I had the same problems. You have to define "ticks" within the yAxes-definition:
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
Updated fiddle: https://jsfiddle.net/r90Ljzvo/5/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With