1👍
✅
According to the documentation you need to use Chart.plugins.register
, not Chart.pluginService.register
. Otherwise your code seems to work.
Here’s a working example:
Chart.plugins.register({
beforeDraw: function(chart) {
console.log(chart.config.type)
}
});
new Chart(document.getElementById("chart"), {
type: "doughnut"
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<canvas id="chart"></canvas>
Source:stackexchange.com