fxcosta / laravel-chartjs

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library
486 stars 112 forks source link

Controller? #22

Closed justinwerner closed 7 years ago

justinwerner commented 7 years ago

Forgive me, I am a newb here. How should the controller be set up? Just copy and paste one of the examples from the ExampleController.php examples in the ReadMe? Also, what is meant by "Finnaly, for now, you must install and add to your layouts / templates the Chartjs library that can be easily found for download at: http://www.chartjs.org. This setting will also be improved."? Does that just mean installing chart.js (npm install chart.js --save)? When I follow the instructions I get the error that the variable chargejs is unknown in the view. So do I need to put something in routes? Sorry for being a newb.

fxcosta commented 7 years ago

@tytondon1234

Just copy and paste one of the examples from the ExampleController.php examples in the ReadMe?

Yes. Just it.

Does that just mean installing chart.js (npm install chart.js --save)? When I follow the instructions I get the error that the variable chargejs is unknown in the view.

You need to declare the chartjs lib in your template. It does not matter if you downloaded the zip, cdn or via npm, since something similar to this in your layout.blade.php or index.blade.php, whatever:

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>

Any problem or error, report us :-)