DEV Community

Discussion on: Use Laravel charts in Laravel.

Collapse
 
beenitanep profile image
Beenitanep

Hello,
I follow all your steps as per your instruction but i gives me error: Undefined variable: usersChart
when i do dd(usersChart ) it does not give any output.
steps:

  1. Add package: composer require consoletvs/charts
  2. php artisan vendor:publish --tag=charts_config
  3. php artisan make:chart UserChart
  4. make controller add code in controller: public function index() { $usersChart = new UserChart; $usersChart->labels(['Jan', 'Feb', 'Mar']); $usersChart->dataset('Users by trimester', 'line', [10, 25, 13]); return view('users', [ 'usersChart' => $usersChart ] ); }
  5. In my blade added: {!! $usersChart->container() !!}
Collapse
 
arielmejiadev profile image
Ariel Mejia

Hi Beenitanep, please execute this in your controller:

dd($usersChart);

You should see the chart class object, if this is not the case I maintain another package for charts...

I hear too many reasons why this package is not working as ideally expected in this post comments, so a few months ago I created a library inspired in this package, here the post:

dev.to/arielmejiadev/create-charts...

I maintain this other package, I add a more clear documentation and if you have some trouble with this normally I can bring support quickly.

Expect this is helpful in someway.