简体   繁体   中英

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

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.

Try to do:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM