3👍
I ran into this on a Blazor WASM project I’m working on.
The fix for me was to use the UMD bunlde. (There is a pr on the Chart.js repo here discussing a similar problem)
I am thinking that updating your script tag to use the UMD bundle like so could resolve your issue.
<script type="module" src="https://unpkg.com/chart.js@4.2.1/dist/chart.umd.js" integrity="sha512-v3ygConQmvH0QehvQa6gSvTE2VdBZ6wkLOlmK7Mcy2mZ0ZF9saNbbk19QeaoTHdWIEiTlWmrwAL4hS8ElnGFbA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
- [Chartjs]-Multiple Range Highlighting of Background in Chart.js
- [Chartjs]-How to remove rectangle box next to the legend text in Chart.js
1👍
Based on Chart.js Docs, CDNJS and jsDelivr are available for CDN installation.
However, CDNJS is not working with below error message.
Chart.js uncaught TypeError: Failed to resolve module specifier "@kurkle/color"
jsDelivr works very well.
With jsDelivr, don’t forget to add ‘type’ attribute in script tag like below.
(If type attribute is skipped, then you may get another error message.)
<script type="module" src="https://cdn.jsdelivr.net/npm/chart.js@4.3.0/dist/chart.umd.min.js"></script>
- [Chartjs]-Vue.js this.$el.getContext('2d') is not a function
- [Chartjs]-Mixed chart scatter plot with chart.js
Source:stackexchange.com