4π
β
In Chart.js 2.x version, legend
, title
and tooltips
must be defined in options
node and not in plugins
one.
options: {
...
legend: {
position: 'top',
display: true,
labels: {
generateLabels: function(chart) {
let data = chart.data;
if (data.labels.length && data.datasets.length) {
return data.labels.map((label, i) => {
return {
text: label
}
})
}
return [];
},
}
},
title: {
display: true,
text: 'Attendees'
},
plugins: {
labels: {
render: () => {}
}
}
...
}
Source:stackexchange.com