0👍
found it!
options = {
title: {
display: true,
text: 'Stuff'
},
scales: {
yAxes: [{
ticks: {
min: 0,
max: numOfItems,
},
beforeUpdate: function (scale) {
let maxValue = 0
if (scale.chart.config && scale.chart.config.data && scale.chart.config.data.datasets) {
scale.chart.config.data.datasets.forEach(dataset => {
if (dataset && dataset.data) {
var visibleDataSets = new Array();
dataset._meta[1].data.forEach(dataset => {
if (dataset.hidden === false) {
visibleDataSets.push(dataset._index);
}
});
visibleDataSets.forEach(index => {
maxValue = maxValue + dataset.data[index];
});
}
})
}
scale.options.ticks.max = maxValue;
if (maxValue === 0) {
scale.options.ticks.display = false;
} else {
scale.options.ticks.display = true;
}
}
}]
},
responsive: true
};
TL;DR dataset._meta[1].data[i].hidden
is the answer…
- [Chartjs]-How to add text inside the doughnut chart using Chart.js?
- [Chartjs]-How do I draw a vertical line on a horizontal bar chart with ChartJS?
Source:stackexchange.com