16👍
After you do npm install chart.js
,
You can simply use
import Chart from 'chart.js'
to import chart.js
Hope it helps.
3👍
As seen on this issue, if you use Angular CLI you only need to add this to the scripts array in angular-cli.json:
"../node_modules/chart.js/dist/Chart.bundle.min.js"
Restart your application, live reload won’t do the trick.
2👍
Using webpack, I’ve found that I had to add Chart
to the global context like so:
// Ensure the Chart class is loaded in the global context
import Chart from 'chart.js/auto';
window.Chart = Chart
0👍
I was struggling with all those issues as well, but then I found this answer to a follow-up trouble. It is well explained and it solved my import problems.
- [Chartjs]-Chart.js: Bar Chart Click Events
- [Chartjs]-How to plot multiple time series in chartjs where each time series has different times
Source:stackexchange.com