I understand that this is an old and boring question, already asked and answered here (see: Highcharts, make the yAxis start at zero), but I just came to highcharts recently and with some efforts I was able to create my charts.
Everything is fine but on a series of 5 charts one refuses to start from 0 on Y axis.
Here is the example for one of the working charts:
var myBarChart = new Chart(ctx, {
type: tipi[tipoGrafico],
data: {
labels: nameArray,
datasets: [{
label: 'Visite nel periodo alla pagina: ' + pag ,
data: valueArray,
backgroundColor:'rgba(255, 32, 0, 0.5)'
}]
},
yAxis: {min: 0, floor:0},
xAxis: {min: 0, floor:0}
});
And this is the correct result:
This is the code for the wrong chart:
var myBarChart = new Chart(ctx, {
type: tipi[tipoGrafico],
data: {
labels: nameArray,
datasets: [{
label: 'Visite in '+ nomiMesi[idxMese]+' alla pagina: '+pag,
data: valueArray,
backgroundColor:'rgba(144, 0, 144, 0.5)'
}]
},
yAxis: {floor: 0, min:0},
xAxis: {floor: 0, min:0}
});
And the resulting image, which shows that the Y axis start from 2, which is the value for the 5th column:
Pls note that I used both min:0
and floor:0
just for an extra safe.
I can not find any difference in the two codes, but maybe my eyes are tired.
Highcharts version: 2.5.0
Javascript version: jquery-2.2.4.min.js