vendredi 7 février 2020

How to install chartjs on Laravel?

I would like to install smoothly chartjs on my Laravel Projects, using npm install, add config for webpack and see on my index page with some chartjs example.

My first try I got this error on browser, maybe I'm not configuring the webpack correctly .

Uncaught ReferenceError: Chart is not defined
    at (index):134

So I copied and pasted this require that I found on chartjs doc integration:

require(['path/to/chartjs/dist/Chart.min.js'], function(Chart){
    var myChart = new Chart(ctx, {...});
});

I and got this error on npm run dev:

ERROR in ./resources/js/app.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /home/sa/laravelproject/resources/js/app.js: Unexpected token (37:37)

  35 | 
  36 | require(['path/to/chartjs/dist/Chart.min.js'], function(Chart){
> 37 |     var myChart = new Chart(ctx, {...});
     |                                      ^
  38 | });


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3buMgr8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire