Chart.JS: How can I only display data labels when the bar width is big enough for the text?
问题 I am using Chart.JS with the Chart.JS datalabel plugin. Is it possible to only show the data labels when the bar width is big enough for the text? I have the following example: https://jsfiddle.net/f5p3twcg/2/ var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { plugins: [ChartDataLabels], type: 'bar', options: { plugins: { datalabels: { color: '#000000', display: true, formatter: function(value, ctx) { return value + "kWh"; } } } }, data: { labels: ["Red", "Blue",