0👍
setChartPlugin({
title: {
display: false
},
legend: {
labels: {
filter: function(legendItem, chartData) {
if (legendItem.datasetIndex === 0) {
return true;
}
return false;
}
},
onClick: function(e, legendItem, legend){
const index = legendItem.datasetIndex;
const ci = legend.chart;
if (ci.isDatasetVisible(index)) {
ci.hide(index);
ci.hide(index+1);
legendItem.hidden = true;
} else {
ci.show(index);
ci.show(index+1);
legendItem.hidden = false;
}
}
},
});
add this code block in chart plugin. It works.
- Chartjs-Chart.js – Scale of secondary Y axis
- Chartjs-How to show label for second y-axis in charts.js?
Source:stackexchange.com