LaravelDaily / laravel-charts

Package to draw charts in Laravel with Chart.js
MIT License
522 stars 116 forks source link

Undefined array key "data" #87

Closed elmarzouguidev closed 2 years ago

elmarzouguidev commented 2 years ago

Undefined array key "data" vendor\laraveldaily\laravel-charts\src\views\javascript.blade.php

data: {

        labels: [

            @if (count($datasets) > 0)

                @foreach ($datasets[0]['data'] as $group => $result)

                    "{{ $group }}",

                @endforeach

            @endif

Laravel 8

elmarzouguidev commented 2 years ago

Fixed it's a error by me $chart_options = [ 'chart_title' => 'Users by months', 'report_type' => 'group_by_date', 'model' => 'App\Models\Sameleon\User', 'group_by_field' => 'created_at', 'group_by_period' => 'month', 'chart_type' => 'bar', 'filter_field' => 'created_at', 'filter_days' => 30, // show only last 30 days ];

I have a Folder named "Sameleon" in Moldes Directory so i forget to put them in the Model key : 'model' => 'App\Models\Sameleon\User',


richyzak commented 11 months ago

I got same problem

elmarzouguidev commented 11 months ago

@richyzak the problem is coming from the Namespace of the Model verify your Model's namespace