2017 © Pedro Peláez
 

library laravelchartjs

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

image

fx3costa/laravelchartjs

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  • Tuesday, February 20, 2018
  • by fxcosta
  • Repository
  • 21 Watchers
  • 227 Stars
  • 44,111 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 54 Forks
  • 13 Open issues
  • 25 Versions
  • 17 % Grown

The README.md

laravel-chartjs - Chart.js v2 wrapper for Laravel 5.x

⛔️ DEPRECATED

This repository is now deprecated. Use @icehouse-ventures instead for newer updates, (*1)

No Longer Maintained. This lib is basically a bridge to Chartjs so it is very likely that some problem or issue is better resolved in the Chartjs repository itself., (*2)

Simple package to facilitate and automate the use of charts in Laravel 5.x using the Chart.js v2 library from Nick Downie., (*3)

Setup:

composer require fx3costa/laravelchartjs

And add the Service Provider in your file config/app.php:, (*4)

Fx3costa\LaravelChartJs\Providers\ChartjsServiceProvider::class

Finally, for now, you must install and add to your layouts / templates the Chartjs library that can be easily found for download at: http://www.chartjs.org. This setting will also be improved., (*5)

Usage:

You can request to Service Container the service responsible for building the charts and passing through fluent interface the chart settings., (*6)

$service = app()->chartjs
    ->name()
    ->type()
    ->size()
    ->labels()
    ->datasets()
    ->options();

For now the builder needs the name of the chart, the type of chart that can be anything that is supported by chartjs and the other custom configurations like labels, datasets, size and options., (*7)

In the dataset interface you can pass any configuration and option to your chart. All options available in chartjs documentation are supported. Just write the configuration with php array notations and its work!, (*8)

Advanced chartjs options

Since the current version allows it to add simple json string based options, it is not possible to generate options like:, (*9)

    options: {
        scales: {
            xAxes: [{
                type: 'time',
                time: {
                    displayFormats: {
                        quarter: 'MMM YYYY'
                    }
                }
            }]
        }
    }

Using the method optionsRaw(string) its possible to add a the options in raw format:, (*10)

Passing string format like a json, (*11)

        $chart->optionsRaw("{
            legend: {
                display:false
            },
            scales: {
                xAxes: [{
                    gridLines: {
                        display:false
                    }  
                }]
            }
        }");

Or, if you prefer, you can pass a php array format, (*12)

$chart->optionsRaw([
    'legend' => [
        'display' => true,
        'labels' => [
            'fontColor' => '#000'
        ]
    ],
    'scales' => [
        'xAxes' => [
            [
                'stacked' => true,
                'gridLines' => [
                    'display' => true
                ]
            ]
        ]
    ]
]);

Examples

1 - Line Chart / Radar Chart:, (*13)

// ExampleController.php

$chartjs = app()->chartjs
        ->name('lineChartTest')
        ->type('line')
        ->size(['width' => 400, 'height' => 200])
        ->labels(['January', 'February', 'March', 'April', 'May', 'June', 'July'])
        ->datasets([
            [
                "label" => "My First dataset",
                'backgroundColor' => "rgba(38, 185, 154, 0.31)",
                'borderColor' => "rgba(38, 185, 154, 0.7)",
                "pointBorderColor" => "rgba(38, 185, 154, 0.7)",
                "pointBackgroundColor" => "rgba(38, 185, 154, 0.7)",
                "pointHoverBackgroundColor" => "#fff",
                "pointHoverBorderColor" => "rgba(220,220,220,1)",
                'data' => [65, 59, 80, 81, 56, 55, 40],
            ],
            [
                "label" => "My Second dataset",
                'backgroundColor' => "rgba(38, 185, 154, 0.31)",
                'borderColor' => "rgba(38, 185, 154, 0.7)",
                "pointBorderColor" => "rgba(38, 185, 154, 0.7)",
                "pointBackgroundColor" => "rgba(38, 185, 154, 0.7)",
                "pointHoverBackgroundColor" => "#fff",
                "pointHoverBorderColor" => "rgba(220,220,220,1)",
                'data' => [12, 33, 44, 44, 55, 23, 40],
            ]
        ])
        ->options([]);

return view('example', compact('chartjs'));


 // example.blade.php



{!! $chartjs->render() !!}

2 - Bar Chart:, (*14)

// ExampleController.php

$chartjs = app()->chartjs
         ->name('barChartTest')
         ->type('bar')
         ->size(['width' => 400, 'height' => 200])
         ->labels(['Label x', 'Label y'])
         ->datasets([
             [
                 "label" => "My First dataset",
                 'backgroundColor' => ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)'],
                 'data' => [69, 59]
             ],
             [
                 "label" => "My First dataset",
                 'backgroundColor' => ['rgba(255, 99, 132, 0.3)', 'rgba(54, 162, 235, 0.3)'],
                 'data' => [65, 12]
             ]
         ])
         ->options([]);

return view('example', compact('chartjs'));


 // example.blade.php



{!! $chartjs->render() !!}

3 - Pie Chart / Doughnut Chart:, (*15)

// ExampleController.php

$chartjs = app()->chartjs
        ->name('pieChartTest')
        ->type('pie')
        ->size(['width' => 400, 'height' => 200])
        ->labels(['Label x', 'Label y'])
        ->datasets([
            [
                'backgroundColor' => ['#FF6384', '#36A2EB'],
                'hoverBackgroundColor' => ['#FF6384', '#36A2EB'],
                'data' => [69, 59]
            ]
        ])
        ->options([]);

return view('example', compact('chartjs'));


 // example.blade.php



{!! $chartjs->render() !!}

OBS:

This README, as well as the package, is in development, but will be constantly updated and I will keep you informed as soon as it is ready for production. Thank you for understanding., (*16)

Any questions or suggestions preferably open a issue!, (*17)

License

LaravelChartJs is open-sourced software licensed under the MIT license., (*18)

The Versions

20/02 2018

dev-master

9999999-dev

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

20/02 2018

2.5.0

2.5.0.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

19/02 2018

2.4.0

2.4.0.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

08/09 2017

2.3.1

2.3.1.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

13/08 2017

2.3.0

2.3.0.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

24/05 2017

2.2.4

2.2.4.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

24/05 2017

dev-hotfix/instance_error_bottom_page

dev-hotfix/instance_error_bottom_page

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

08/04 2017

2.2.3

2.2.3.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

24/02 2017

2.2.2

2.2.2.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

09/02 2017

2.2.1

2.2.1.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

07/02 2017

dev-hotfix/remove-return-types

dev-hotfix/remove-return-types

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

06/02 2017

2.2.0

2.2.0.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

03/02 2017

dev-hotfix/support_php56

dev-hotfix/support_php56

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

08/01 2017

2.1.0

2.1.0.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

08/01 2017

dev-feature/new-charts-support

dev-feature/new-charts-support

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

23/12 2016

2.0.0

2.0.0.0

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

23/12 2016

dev-laravelchartjs2

dev-laravelchartjs2

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

09/04 2016

1.3.4

1.3.4.0

Simples package para facilitar e automatizar o uso de graficos no Laravel 5.x usando a lib Chartjs

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

04/03 2016

1.3.3

1.3.3.0

Simples package para facilitar e automatizar o uso de graficos no Laravel 5.x usando a lib Chartjs

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

09/02 2016

1.3.2

1.3.2.0

Simples package para facilitar e automatizar o uso de graficos no Laravel 5.x usando a lib Chartjs

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

12/01 2016

1.3.1

1.3.1.0

Simples package para facilitar e automatizar o uso de graficos no Laravel 5.x usando a lib Chartjs

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

17/12 2015

1.3.0

1.3.0.0

Simples package para facilitar e automatizar o uso de graficos no Laravel 5.x usando a lib Chartjs

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

15/12 2015

1.2.1

1.2.1.0

Simples package para facilitar e automatizar o uso de graficos no Laravel 5.x usando a lib Chartjs

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

30/07 2015

1.2.0

1.2.0.0

Simples package para facilitar e automatizar o uso de graficos no Laravel 5.x usando a lib Chartjs

  Sources   Download

MIT

The Requires

 

by felix

chartjs chart laravel5 reports graphics fx3costa

13/07 2015

1.0.0

1.0.0.0

Simples package para facilitar e automatizar o uso de graficos no Laravel 5.x usando a lib Chartjs

  Sources   Download

MIT

by felix