Wednesday, March 29, 2017

Uncaught ReferenceError: Chart is not defined

I've installed chart.js using npm by : npm install chart.js --save-dev, in "resources/assets/js/bootstrap.js" I refere to it by : require('chart.js'); then in my console npm run dev and finally it's successfully compiled in "public/js/app.js" , however when I try to use it in my view as follow

<script src="/js/app.js"></script><script> var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { ......... </script>

the browser returns 'Uncaught ReferenceError: Chart is not defined'.

How come it's declared in app.js and can't refere to it ? Thanks in advance.



via zLegend

Advertisement