[Chartjs]-Use Chartjs-Annotation-Plugin without using "import"

0👍

Late to the party but I don’t see a response yet and I was also having trouble figuring it out.

Simply include

<script>
Chart.register('chartjs-plugin-annotation');
Chart.register('chartjs-plugin-datalabels');

// ... rest of your code
</script>

somewhere near the top of your scripts after your CDN imports.

As per the Chartjs plugin documentation, this will work with any plugin that follows the naming convention chartjs-plugin-*

Edit:
Adding a working example; credit to @dennis-bauszus for most of the chart layout.

https://codepen.io/jarrilla/pen/OJjMVEo

Leave a comment