PHPackages                             bfg/chartjs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bfg/chartjs

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bfg/chartjs
===========

Simple package to facilitate and automate the use of ChartJs v2 library

3.2.0(4y ago)0111MITPHPPHP &gt;=5.6.4

Since Jul 13Pushed 4y agoCompare

[ Source](https://github.com/bfg-s/chartjs)[ Packagist](https://packagist.org/packages/bfg/chartjs)[ RSS](/packages/bfg-chartjs/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (35)Used By (0)

Wrapper for Chart.js v2
=======================

[](#wrapper-for-chartjs-v2)

Simple package to facilitate and automate the use of charts using the [Chart.js](http://www.chartjs.org/) v2 library from Nick Downie.

Setup:
======

[](#setup)

```
composer require bfg/chartjs

```

Usage:
======

[](#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
========================

[](#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
========

[](#examples)

1 - Line Chart / Radar Chart:

```
// ExampleController.php

$chartjs = app()->chartjs
        ->name('lineChartTest') // Not required
        ->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'));

 // Or

 $chartjs = app()->chartjs
        ->type('line')
        ->size(['width' => 400, 'height' => 200])
        ->labels(['January', 'February', 'March', 'April', 'May', 'June', 'July'])
        ->simpleDatasets('My First dataset', [65, 59, 80, 81, 56, 55, 40])
        ->simpleDatasets('My Second dataset', [12, 33, 44, 44, 55, 23, 40]);

 // example.blade.php

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

```

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

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

```

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

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

```

License
=======

[](#license)

LaravelChartJs is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 73.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~85 days

Recently: every ~152 days

Total

29

Last Release

1558d ago

Major Versions

1.3.4 → 2.0.02016-12-23

2.8.0 → 3.0.02022-01-13

PHP version history (3 changes)1.2.0PHP &gt;=5.3.0

1.3.1PHP &gt;=5.5.9

2.0.0PHP &gt;=5.6.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/59b2d162a30938ac2c3c56340ebea07a6778a3e1c86cb70b5bc28b69a1c3f04d?d=identicon)[bfg](/maintainers/bfg)

---

Top Contributors

[![fxcosta](https://avatars.githubusercontent.com/u/6624661?v=4)](https://github.com/fxcosta "fxcosta (85 commits)")[![pjeutr](https://avatars.githubusercontent.com/u/611968?v=4)](https://github.com/pjeutr "pjeutr (7 commits)")[![Xsaven](https://avatars.githubusercontent.com/u/1726771?v=4)](https://github.com/Xsaven "Xsaven (6 commits)")[![Damian89](https://avatars.githubusercontent.com/u/11396147?v=4)](https://github.com/Damian89 "Damian89 (2 commits)")[![emmerink](https://avatars.githubusercontent.com/u/5856414?v=4)](https://github.com/emmerink "emmerink (2 commits)")[![edduu](https://avatars.githubusercontent.com/u/3751934?v=4)](https://github.com/edduu "edduu (2 commits)")[![MaxGiting](https://avatars.githubusercontent.com/u/9828591?v=4)](https://github.com/MaxGiting "MaxGiting (1 commits)")[![pokke123](https://avatars.githubusercontent.com/u/8859033?v=4)](https://github.com/pokke123 "pokke123 (1 commits)")[![renato-moura-soleon](https://avatars.githubusercontent.com/u/267999688?v=4)](https://github.com/renato-moura-soleon "renato-moura-soleon (1 commits)")[![samuelterra22](https://avatars.githubusercontent.com/u/11915449?v=4)](https://github.com/samuelterra22 "samuelterra22 (1 commits)")[![wells](https://avatars.githubusercontent.com/u/2041871?v=4)](https://github.com/wells "wells (1 commits)")[![JayBizzle](https://avatars.githubusercontent.com/u/340752?v=4)](https://github.com/JayBizzle "JayBizzle (1 commits)")[![elyerinhaughie](https://avatars.githubusercontent.com/u/33913289?v=4)](https://github.com/elyerinhaughie "elyerinhaughie (1 commits)")[![flemzord](https://avatars.githubusercontent.com/u/1952914?v=4)](https://github.com/flemzord "flemzord (1 commits)")[![Hansi7](https://avatars.githubusercontent.com/u/8850691?v=4)](https://github.com/Hansi7 "Hansi7 (1 commits)")[![amouillard](https://avatars.githubusercontent.com/u/1624973?v=4)](https://github.com/amouillard "amouillard (1 commits)")[![LorenzoSapora](https://avatars.githubusercontent.com/u/25519274?v=4)](https://github.com/LorenzoSapora "LorenzoSapora (1 commits)")

---

Tags

graphicslaravel5chartchartjsreports

### Embed Badge

![Health badge](/badges/bfg-chartjs/health.svg)

```
[![Health](https://phpackages.com/badges/bfg-chartjs/health.svg)](https://phpackages.com/packages/bfg-chartjs)
```

###  Alternatives

[fx3costa/laravelchartjs

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

486471.0k4](/packages/fx3costa-laravelchartjs)[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[imanghafoori/laravel-terminator

A minimal yet powerful package to give you opportunity to refactor your controllers.

25353.0k](/packages/imanghafoori-laravel-terminator)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)[antoineaugusti/easyphpcharts

A PHP class for chartjs.org charts.

252.8k](/packages/antoineaugusti-easyphpcharts)[epessine/axis

Draw charts with a simple API on Laravel

265.6k](/packages/epessine-axis)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
