Posted inTechnology / Ajax / JavaScript / jQuery / Laravel

Laravel Free charts and graphs for HTML5, JQuery and Javascript

Laravel Free charts and graphs for HTML5, JQuery and Javascript

In this Post We Will Explain About is Laravel Free charts and graphs for HTML5, JQuery and Javascript With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to PHP Charts & Graphs – Charts made simpleExample

In this post we will show you Best way to implement Laravel Tutorial on Creating Charts | CanvasJS JavaScript Charts
, hear for Laravel Adding Charts to Your Site with Highchartswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Laravel 5 Chart example using Charts Package

  • Live 1. line chart
  • Live 2. area chart
  • Live 3. bar chart
  • Live 4. pie chart
  • Live 5. donut chart
  • Live 6. geo chart
  • Live 7. gauge chart
  • Live 8. temp chart
  • Live 9. percentage chart
  • Live 10. progressbar chart
  • Live 11. areaspline chart
  • Live 12. scatter chart

And then done simple this demo your new output look as like this

Phase : 1 Install Require Package steps

We are the first of all the install consoletvs/charts and then chart package for simple integrate chart in PHP frameworks like as a laravel web-application using following simple cmd means command.

composer require consoletvs/charts

Phase : 2 Configure Package

And then install successfully simple package we are simple should be settings or configure this simple package service provider as well as alias in config/app.php file.


'providers' => [
	....
	ConsoleTVs\Charts\ChartsServiceProvider::class,
],
'aliases' => [
	....
	'Charts' => ConsoleTVs\Charts\Facades\Charts::class,
],

Done settings then after publish simple vendor directorys sub using following simple cmd means command

php artisan vendor:publish

And then run this simple cmd means command you can see in config directory config/charts.php file automatic generated. and all default chart view file is generated in resources/views/vendor directory

Phase : 3 Add Dummy Records

We are required some dummy data into the any table, which we are use in our chart. so we are add some drecords in user table using tinker. simply run following simple cmd means command

php artisan tinker
>>> factory(App\User::class, 20)->create();

Phase : 4 Create Route

And then simple add one route in your routes/web.php file.

Route::get('bar-chart', 'ChartController@index');

Phase : 5 Create Controller

And then simple create ChartController.php file in app/Http/Controllers/ directorys and put into it folowing simple source code

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Charts;
use App\User;
use DB;

class ChartController extends Controller
{
    public function index()
    {
    	$users = User::where(DB::raw("(DATE_FORMAT(created_at,'%Y'))"),date('Y'))
    				->get();
        $chart = Charts::database($users, 'bar', 'highcharts')
			      ->title("Monthly new Register Users")
			      ->elementLabel("Total Users")
			      ->dimensions(1000, 500)
			      ->responsive(true)
			      ->groupByMonth(date('Y'), true);
        return view('chart',compact('chart'));
    }
}

Phase : 6 Create View File

And then simple we are create view file for display chart, so create chart.blade.php file in as well as resources/views/ directory and put following simple source code into it.

First opeen your simple laravel like as a resources/views/layouts/app.blade.php file and add one simple following line and this commands into head ssection data.

{!! Charts::styles() !!}


@extends('layouts.app')

@section('content')
Chart Demo
{!! $chart->html() !!}
{!! Charts::scripts() !!} {!! $chart->script() !!} @endsection

And then simple we are ready to run our example so run bellow simple cmd means command ro quick run:

php artisan serve

And then simple you can open bellow URL on your browser:

http://localhost:8000/bar-chart

Another chart example and some configure simple source code

1. Pie Chart Live Example

Charts::create('pie', 'highcharts')
    ->title('Live24u web-tutorials chart')
    ->labels(['First', 'Second', 'Third'])
    ->values([5,10,20])
    ->dimensions(1000,500)
    ->responsive(true);

2. Donut and Doughnut Chart Live Example

Charts::create('donut', 'highcharts')
    ->title('Live24u web-tutorials chart')
    ->labels(['First', 'Second', 'Third'])
    ->values([5,10,20])
    ->dimensions(1000,500)
    ->responsive(true);

3. Line Chart Live Example

Charts::create('line', 'highcharts')
    ->title('Live24u web-tutorials chart')
    ->elementLabel('Live24u web-tutorials label')
    ->labels(['First', 'Second', 'Third'])
    ->values([5,10,20])
    ->dimensions(1000,500)
    ->responsive(true);

4. Area Chart Live Example

Charts::create('area', 'highcharts')
    ->title('Live24u web-tutorials chart')
    ->elementLabel('Live24u web-tutorials label')
    ->labels(['First', 'Second', 'Third'])
    ->values([5,10,20])
    ->dimensions(1000,500)
    ->responsive(true);

5. Areaspline Chart Live Example

Charts::multi('areaspline', 'highcharts')
    ->title('Live24u web-tutorials chart')
    ->colors(['#ff0000', '#ffffff'])
    ->labels(['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday','Saturday', 'Sunday'])
    ->dataset('John', [3, 4, 3, 5, 4, 10, 12])
    ->dataset('Jane',  [1, 3, 4, 3, 3, 5, 4]);

6. Geo Chart Live Example

Charts::create('geo', 'highcharts')
    ->title('Live24u web-tutorials chart')
    ->elementLabel('Live24u web-tutorials label')
    ->labels(['ES', 'FR', 'RU'])
    ->colors(['#3D3D3D', '#985689'])
    ->values([5,10,20])
    ->dimensions(1000,500)
    ->responsive(true);

7. Percentage Chart Live Example

Charts::create('percentage', 'justgage')
    ->title('Live24u web-tutorials chart')
    ->elementLabel('Live24u web-tutorials label')
    ->values([65,0,100])
    ->responsive(true)
    ->height(300)
    ->width(0);

Example

I hope you have Got What is Laravel Best Chart Generation Options with PHP Components And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype