All Projects → fxcosta → Laravel Chartjs

fxcosta / Laravel Chartjs

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

Projects that are alternatives of or similar to Laravel Chartjs

Chartjs Chart Box And Violin Plot
Chart.js Box Plot addon
Stars: ✭ 91 (-77.48%)
Mutual labels:  chart, chartjs
Buy All Steam Games
see how much does it cost to buy all steam games
Stars: ✭ 110 (-72.77%)
Mutual labels:  laravel, chartjs
Chart.qml
Chart.qml like Chart.js
Stars: ✭ 100 (-75.25%)
Mutual labels:  chart, chartjs
Chart
Quick & smart charting for STDIN
Stars: ✭ 521 (+28.96%)
Mutual labels:  chart, chartjs
chart
📊📉 Add beautiful and reusable charts with one line of ruby for Rails 5.x
Stars: ✭ 42 (-89.6%)
Mutual labels:  chart, chartjs
Go Chartjs
golang library to make https://chartjs.org/ plots (this is vanilla #golang, not gopherjs)
Stars: ✭ 42 (-89.6%)
Mutual labels:  chart, chartjs
Laravel Dashboard Chart Tile
Create all the charts you want for your laravel dashboard
Stars: ✭ 102 (-74.75%)
Mutual labels:  laravel, chart
Chartkick.py
Create beautiful Javascript charts with minimal code
Stars: ✭ 695 (+72.03%)
Mutual labels:  chart, chartjs
chartjs-plugin-datasource-prometheus
Chart.js plugin for Prometheus data loading
Stars: ✭ 77 (-80.94%)
Mutual labels:  chart, chartjs
Meter
Laravel package to find performance bottlenecks in your laravel application.
Stars: ✭ 204 (-49.5%)
Mutual labels:  laravel, chart
Vue Chartjs
📊 Vue.js wrapper for Chart.js
Stars: ✭ 4,554 (+1027.23%)
Mutual labels:  chart, chartjs
chartjs-chart-timeline
Google-like timeline chart for Chart.js.
Stars: ✭ 44 (-89.11%)
Mutual labels:  chart, chartjs
Django Jchart
📈 A Django package for plotting charts using the excellent Chart.JS library.
Stars: ✭ 115 (-71.53%)
Mutual labels:  chart, chartjs
Charts
⚡ Laravel Charts — Build charts using laravel. The laravel adapter for Chartisan.
Stars: ✭ 2,337 (+478.47%)
Mutual labels:  laravel, chart
Chart.js-Rounded-Bar-Charts
Rounded Rectangles in Bar Charts
Stars: ✭ 48 (-88.12%)
Mutual labels:  chart, chartjs
React Chartjs 2
React components for Chart.js, the most popular charting library
Stars: ✭ 4,667 (+1055.2%)
Mutual labels:  chart, chartjs
Zhihu App
laravel-vue-zhihu ✨
Stars: ✭ 395 (-2.23%)
Mutual labels:  laravel
Meilisearch Laravel Scout
MeiliSearch integration for Laravel Scout
Stars: ✭ 394 (-2.48%)
Mutual labels:  laravel
Hycharts
柱状图、折/曲线图、K线图(主图、交易量图、辅助图), 图与图可以自由组合, 支持分页加载数据 -----> 低内存、低耗电、滑动缩放顺滑
Stars: ✭ 394 (-2.48%)
Mutual labels:  chart
Laravel Schedule Monitor
Monitor scheduled tasks in a Laravel app
Stars: ✭ 393 (-2.72%)
Mutual labels:  laravel

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

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

Setup:

composer require fx3costa/laravelchartjs

And add the Service Provider in your file config/app.php:

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.

Usage:

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

$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.

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!

Advanced chartjs options

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

    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:

Passing string format like a json

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

Or, if you prefer, you can pass a php array format

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

Examples

1 - Line Chart / Radar Chart:

// 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

<div style="width:75%;">
    {!! $chartjs->render() !!}
</div>

2 - Bar Chart:

// 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

<div style="width:75%;">
    {!! $chartjs->render() !!}
</div>

3 - Pie Chart / Doughnut Chart:

// 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

<div style="width:75%;">
    {!! $chartjs->render() !!}
</div>

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.

Any questions or suggestions preferably open a issue!

License

LaravelChartJs is open-sourced software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].