17👍
✅
There is callback method in which you can get the array of values which will show on yAxes.
The first element of that array will be the highest value for the yAxes. Below is the sample code for the same.
var yAxesticks = [];
var highestVal;
var chartInstanceHoverModeNearest = new Chart(ctx, {
type: 'bar',
data: data,
options:{
scales: {
yAxes : [{
ticks : {
beginAtZero : true,
callback : function(value,index,values){
yAxesticks = values;
return value;
}
}
}]
}
}
});
highestVal = yAxesticks[0];
0👍
With Chart.js 4.3.0, the min and max can be obtained directly from chart.scales[scaleId]
:
let yMax = chartInstance.scales.y.max;
let yMin = chartInstance.scales.y.min;
Source:stackexchange.com