Back

Call to undefined method ConsoleTVs\Charts\Builder::new()


Dkna posted 2 weeks ago

Hi guys, I am new here, I want to try making a pie chart in laravel. I have tried using lavachat but it feels too complicated to me and there isn't much resources for me to look at as well. So I tried using ConsoleTVs/Charts package but I am having trouble with it at the start.

I am getting this error,Call to undefined method ConsoleTVs\Charts\Builder::new(), in my laravel version 5.5.22 when installing ConsoleTVs/Charts composer package. I have followed the tutorial properly and I don't see any part where I had gone wrong, I even use dump-autoload, php artisan cache:clear,php artisan config:cache and php artisan config:clear but nothing happen. Can anybody help me? Thanks in advance

This is the link that I followed: https://devhub.io/zh/repos/ConsoleTVs-Charts#pie

testController:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
//use ConsoleTVs\Charts\Charts; --> if use this "Class 'ConsoleTVs\Charts\Charts' not found" error will appear
use Charts;

class PieController extends Controller
{
       public function index()
    {
        $chart = Charts::new('line', 'highcharts')
            ->setTitle('My nice chart')
            ->setLabels(['First', 'Second', 'Third'])
            ->setValues([5,10,20])
            ->setDimensions(1000,500)
            ->setResponsive(false);
        return view('pie', ['chart' => $chart]);
    }
}

config/app.php

Providers: ConsoleTVs\Charts\ChartsServiceProvider::class,

Aliases:

'Charts' => ConsoleTVs\Charts\Charts::class,
or 
'Charts' => ConsoleTVs\Charts\Facades\Charts::class,

pie.blade.php


<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>My Charts</title>

    {!! Charts::assets() !!}

</head>
<body>
    <center>
        {!! $chart->render() !!}
    </center>
</body>
</html> ``` ```

Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us