How to import chart.js plugin into script on typical html site

1.1k views Asked by At

I have a index.php with html and script sections. I have few canvas with charts on it and now I need to import plugin 'chartjs-plugin-annotation ' which looks like typical ES6 module. If I used React the solution would be simple, I would just add it to the project with npm. But I don't know how to do it on my site.

I was trying to do this somehow like this, but it didin't worked. Even tried to add type= "module" but it also didn't worked.

<script src="../Chart.bundle.min.js"></script>

where path was like: /chartjs-annotation-plugin/src/annotation.js etc. Link to plugin on github: chartjs-plugin-annotation. I'm not very experienced in javascript cause I'm backend dev so this could be also the problem.

1

There are 1 answers

0
Or Assayag On

Try to do:

<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-annotation/0.5.7/chartjs-plugin-annotation.min.js"></script>