plugins
应放置在其自己的配置部分中,而不是嵌套在options
.
代替:
options: {
title: {
display: true,
text: graph.globals.title,
},
legend: {
display: true,
position: 'bottom',
fullWidth: false,
onClick: () => {},
labels: {
generateLabels: (chart) => {
return pieOptions.legendLeft(chart);
}
}
},
plugins: [{
beforeInit: function(chart, options) {
console.log('yolo');
}
}]
rotation: 3.9,
}
您的代码应如下所示:
options: {
title: {
display: true,
text: graph.globals.title,
},
legend: {
display: true,
position: 'bottom',
fullWidth: false,
onClick: () => {},
labels: {
// generateLabels: (chart) => {
// return pieOptions.legendLeft(chart);
// }
}
},
rotation: 3.9,
},
plugins: [{
beforeInit: function(chart, options) {
console.log('yolo');
}
}]
工作 JSFiddle:https://jsfiddle.net/r1x63b8v/ https://jsfiddle.net/r1x63b8v/