Laravel 5.6 Bar,pie,line,donut,area,geo charts and graphs

Laravel 5.6 Bar,pie,line,donut,area,geo charts and graphs

In this Post We Will Explain About is Laravel 5.6 Bar,pie,line,donut,area,geo charts and graphs With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Laravel 5.6 Chart example using Charts Package Example

In this post we will show you Best way to implement Laravel 5.6 – Generate Free Charts and Graphs Example, hear for How To Generate Charts in Laravel 5.6 using ChartJS with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Phase 1: Install ConsoleTVs Package

here simple step by step first of all I will install Laravel package Like as ConsoleTVs/Charts simple Laravel composer package by following CMD to run composer main command in your web project laravel 5.6 web-application.

composer require consoletvs/charts

And then successfully all the libs install package, so second one open this path Like as config/app.php file as well as insert Laravel service provider and include Laravel alias.

Also Read :   PHP Registration Form With Validation using Jquery MySQL Source code


//Laravel 5.6 - Generate Free Charts and Graphs Example
'providers' => [
.... //some Laravel providers
'aliases' => [
.... //some Laravel aliases
'Charts' => ConsoleTVs\Charts\Facades\Charts::class,

Phase 2: Make Students Dummy Records

you have more students table by executing default Laravel Database migrations of latest version of the laravel. Therefor I have to create dummy more records for sample apps or demo in students table. Therefor let’s execute bellow Laravel some command as well as fetch dummy records.

php artisan tinker

>>> factory(App\User::class, 25)->create();

Phase 3: Add Routes

And then I will put Laravel routes for sample example, Therefor simply Put following Laravel 5.6 route in your web.php route file:


//How to create charts using Laravel in your web application

Phase 4: Add New Controller

In this Phase,I need to make new Laravel controller Like as a liveChartGraphsController that will all the data model and view manage index method of Laravel route. Therefor let’s Insert bellow some source code.

Also Read :   Convert Array to XML and XML to Array using PHP


In this example available to Laravel 5.6 Bar,pie,line,donut,area,geo charts and graphs

//highcharts in laravel 5.6
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Charts;
use App\User;
use DB;
//highcharts in laravel 5.6 Example
class liveChartGraphsController extends Controller

    public function livecreateChart($type)
        switch ($type) {
            case 'bar':
                $students = User::where(DB::raw("(DATE_FORMAT(created_at,'%Y'))"),date('Y')) 
                $chart = Charts::database($students, 'bar', 'highcharts') 
                            ->title("Monthly create new Register Students") 
                            ->elementLabel("Total Students") 
                            ->dimensions(900, 450) 
                            ->groupByMonth(date('Y'), true);
            case 'pie':
                $chart = Charts::create('pie', 'highcharts')
                            ->title(' Laravel Pie Chart')
                            ->labels(['Codeigniter', 'Laravel', 'PHP'])
            case 'donut':
                $chart = Charts::create('donut', 'highcharts')
                            ->title(' Laravel Donut Chart')
                            ->labels(['starter', 'silver', 'Golden'])
            case 'line':
                $chart = Charts::create('line', 'highcharts')
                            ->title(' Laravel Line Chart')
                            ->elementLabel(' Laravel Line Chart Lable')
                            ->labels(['starter', 'silver', 'Golden'])
            case 'area':
                $chart = Charts::create('area', 'highcharts')
                            ->title(' Laravel Area Chart')
                            ->elementLabel(' Laravel Line Chart label')
                            ->labels(['starter', 'silver', 'Golden'])
            case 'geo':
                $chart = Charts::create('geo', 'highcharts')
                            ->title(' Laravel GEO Chart')
                            ->elementLabel(' Laravel GEO Chart label')
                            ->labels(['jd', 'ak', 'ks'])
                            ->colors(['#c60000', '#cc33cc'])
                # code...
        return view('chart', compact('chart'));

Phase 5: Make Blade File

Lastly I need to make Lable blade file Like name as a livechart.blade.php, will include bootstrap HTML layout. Therefor let’s Pit bellow some source code:

Also Read :   Vuejs Expressions – Numbers Strings Objects Array eval using Vuejs


<!DOCTYPE html>
<html lang="en">
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Live Charts - free download source code here</title>
        {!! Charts::styles() !!}
        <div class="app">
                {!! $chart->html() !!}

        {!! Charts::scripts() !!}
        {!! $chart->script() !!}

Good Luck, finally I am ready to execute this Project. Therefor you can run simple Laravel Project as well as check on simple localhost following path:


You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example


I hope you have Got What is Laravel 5.6 Chart example using Charts Package And how it works.I would Like to have FeedBack From My Blog( readers.Your Valuable FeedBack,Any Question,or any Comments about This Article( Are Most Always Welcome.