PHPackages                             tpharaoh/laravel-charts - 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. tpharaoh/laravel-charts

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

tpharaoh/laravel-charts
=======================

Create charts and reports from Laravel

0.1.11(6y ago)116MITPHP

Since Feb 17Pushed 6y agoCompare

[ Source](https://github.com/tpharaoh/laravel-charts)[ Packagist](https://packagist.org/packages/tpharaoh/laravel-charts)[ RSS](/packages/tpharaoh-laravel-charts/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (16)Used By (0)

Laravel Charts
--------------

[](#laravel-charts)

Package to generate Chart.js charts directly from Laravel/Blade, without interacting with JavaScript.

**Notice**: Package is in early development, generating simple cases, so it's likely that syntax/parameters will change with future versions, use with cautions.

---

Simple Usage
------------

[](#simple-usage)

[![Laravel Charts - Users by Months](https://camo.githubusercontent.com/3c9dc9037d7d383e99a5bc3cbf4692067c3145155a06d54ed12d25586e43a775/68747470733a2f2f6c61726176656c6461696c792e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30322f53637265656e2d53686f742d323031392d30322d31382d61742d322e33372e30392d504d2e706e67)](https://camo.githubusercontent.com/3c9dc9037d7d383e99a5bc3cbf4692067c3145155a06d54ed12d25586e43a775/68747470733a2f2f6c61726176656c6461696c792e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30322f53637265656e2d53686f742d323031392d30322d31382d61742d322e33372e30392d504d2e706e67)

If you want to generate a chart above, grouping **users** records by the month of **created\_at** value, here's the code.

**Controller**:

```
use LaravelDaily\LaravelCharts\Classes\LaravelChart;

// ...

$chart_options = [
    'chart_title' => 'Users by months',
    'report_type' => 'group_by_date',
    'model' => 'App\User',
    'group_by_field' => 'created_at',
    'group_by_period' => 'month',
    'chart_type' => 'bar',
];
$chart1 = new LaravelChart($chart_options);

return view('home', compact('chart1'));

```

**View File**

```
@extends('layouts.app')

@section('content')

                Dashboard

                    {{ $chart1->options['chart_title'] }}
                    {!! $chart1->renderHtml() !!}

@endsection

@section('javascript')
{!! $chart1->renderChartJsLibrary() !!}
{!! $chart1->renderJs() !!}
@endsection

```

---

Installation
------------

[](#installation)

```
composer require laraveldaily/laravel-charts

```

No additional configuration or other parameters yet.

---

Usage
-----

[](#usage)

You need to create `LaravelChart` object in your Controller, passing array of options.

```
$chart = new LaravelChart($options);

```

Then pass it to the View, as a variable:

```
return view('dashboard', compact('chart'));

```

---

Available Reports and Options
-----------------------------

[](#available-reports-and-options)

Currently package support two types of charts/reports:

- `group_by_date` - amount of records from the same table, grouped by time period - day/week/month/year;
- `group_by_string` - amount of records from the same table, grouped by any string field, like `name`;
- `group_by_relationship` - amount of records from the same table, grouped by `belongsTo` relationship's field

**Example with all options**

```
$chart_options = [
    'chart_title' => 'Transactions by dates',
    'chart_type' => 'line',
    'report_type' => 'group_by_date',
    'model' => 'App\Transaction',

    'group_by_field' => 'transaction_date',
    'group_by_period' => 'day',

    'aggregate_function' => 'sum',
    'aggregate_field' => 'amount',

    'filter_field' => 'transaction_date',
    'filter_days' => 30, // show only transactions for last 30 days
    'filter_period' => 'week', // show only transactions for this week
    'continuous_time' => true, // show continuous timeline including dates without data
];

```

- `chart_title` (required) - just a text title that will be shown as legend;
- `chart_type` (required) - possible values: "line", "bar", "pie";
- `report_type` (required) - see above, can be `group_by_date`, `group_by_string` or `group_by_relationship`;
- `model` (required) - name of Eloquent model, where to take the data from;
- `group_by_field` (required) - name of database field that will be used in `group_by` clause;
- `group_by_period` (optional, only for `group_by_date` report type) - possible values are "day", "week", "month", "year";
- `relationship_name` (optional, only for `group_by_relationship` report type) - the name of model's method that contains `belongsTo` relationship.
- `aggregate_function` (optional) - you can view not only amount of records, but also their `SUM()` or `AVG()`. Possible values: "count" (default), "avg", "sum".
- `aggregate_field` (optional) - see `aggregate_function` above, the name of the field to use in `SUM()` or `AVG()` functions. Irrelevant for `COUNT()`.
- `filter_field` (optional) - show only data filtered by that datetime field (see below)
- `filter_days` (optional) - see `filter_field` above - show only last `filter_days` days of that field. Example, last **30** days by `created_at` field.
- `filter_period` (optional) - another way to filter by field, show only record from last **week** / **month** / **year**. Possible values are "week", "month", "year".
- `continuous_time` (optional) - show all dates on chart, including dates without data.

---

Example with relationship
-------------------------

[](#example-with-relationship)

```
$chart_options = [
    'chart_title' => 'Transactions by user',
    'chart_type' => 'line',
    'report_type' => 'group_by_relationship',
    'model' => 'App\Transaction',

    'relationship_name' => 'user', // represents function user() on Transaction model
    'group_by_field' => 'name', // users.name

    'aggregate_function' => 'sum',
    'aggregate_field' => 'amount',

    'filter_field' => 'transaction_date',
    'filter_days' => 30, // show only transactions for last 30 days
    'filter_period' => 'week', // show only transactions for this week
];

```

**Notice**: currently package is in early version, so these parameters may change in the future.

---

Rendering Charts in Blade
-------------------------

[](#rendering-charts-in-blade)

After you passed `$chart` variable, into Blade, you can render it, by doing **three** actions:

**Action 1. Render HTML**.

Wherever in your Blade, call this:

```
{!! $chart1->renderHtml() !!}

```

It will generate something like this:

```

```

**Action 2. Render JavaScript Library**

Package is using Chart.js library, so we need to initialize it somewhere in scripts section:

```
{!! $chart1->renderChartJsLibrary() !!}

```

It will generate something like this:

```

```

**Action 3. Render JavaScript of Specific Chart**

After Chart.js is loaded, launch this:

```
{!! $chart1->renderJs() !!}

```

---

Using Multiple Charts
---------------------

[](#using-multiple-charts)

You can show multiple charts on the same page, initialize them separately.

**Controller**:

```
public function index()
{
    $chart_options = [
        'chart_title' => 'Users by months',
        'report_type' => 'group_by_date',
        'model' => 'App\User',
        'group_by_field' => 'created_at',
        'group_by_period' => 'month',
        'chart_type' => 'bar',
        'filter_field' => 'created_at',
        'filter_days' => 30, // show only last 30 days
    ];

    $chart1 = new LaravelChart($chart_options);

    $chart_options = [
        'chart_title' => 'Users by names',
        'report_type' => 'group_by_string',
        'model' => 'App\User',
        'group_by_field' => 'name',
        'chart_type' => 'pie',
        'filter_field' => 'created_at',
        'filter_period' => 'month', // show users only registered this month
    ];

    $chart2 = new LaravelChart($chart_options);

    $chart_options = [
        'chart_title' => 'Transactions by dates',
        'report_type' => 'group_by_date',
        'model' => 'App\Transaction',
        'group_by_field' => 'transaction_date',
        'group_by_period' => 'day',
        'aggregate_function' => 'sum',
        'aggregate_field' => 'amount',
        'chart_type' => 'line',
    ];

    $chart3 = new LaravelChart($chart_options);

    return view('home', compact('chart1', 'chart2', 'chart3'));
}

```

**View**:

```
@extends('layouts.app')

@section('content')

                Dashboard

                    {{ $chart1->options['chart_title'] }}
                    {!! $chart1->renderHtml() !!}

                    {{ $chart2->options['chart_title'] }}
                    {!! $chart2->renderHtml() !!}

                    {{ $chart3->options['chart_title'] }}
                    {!! $chart3->renderHtml() !!}

@endsection

@section('javascript')
{!! $chart1->renderChartJsLibrary() !!}

{!! $chart1->renderJs() !!}
{!! $chart2->renderJs() !!}
{!! $chart3->renderJs() !!}
@endsection

```

[![Laravel Charts - Users by Months](https://camo.githubusercontent.com/3c9dc9037d7d383e99a5bc3cbf4692067c3145155a06d54ed12d25586e43a775/68747470733a2f2f6c61726176656c6461696c792e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30322f53637265656e2d53686f742d323031392d30322d31382d61742d322e33372e30392d504d2e706e67)](https://camo.githubusercontent.com/3c9dc9037d7d383e99a5bc3cbf4692067c3145155a06d54ed12d25586e43a775/68747470733a2f2f6c61726176656c6461696c792e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30322f53637265656e2d53686f742d323031392d30322d31382d61742d322e33372e30392d504d2e706e67)

[![Laravel Charts - Users by Names](https://camo.githubusercontent.com/e65f4e7f083df586229f60464b1523c7355e0001443207496263a960573f0411/68747470733a2f2f6c61726176656c6461696c792e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30322f53637265656e2d53686f742d323031392d30322d31382d61742d322e33362e35302d504d2e706e67)](https://camo.githubusercontent.com/e65f4e7f083df586229f60464b1523c7355e0001443207496263a960573f0411/68747470733a2f2f6c61726176656c6461696c792e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30322f53637265656e2d53686f742d323031392d30322d31382d61742d322e33362e35302d504d2e706e67)

[![Laravel Charts - Transactions by Dates](https://camo.githubusercontent.com/c40e9055f61507f6d06e6cf7287403060caba66c7d0645438d3731bb6418611a/68747470733a2f2f6c61726176656c6461696c792e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30322f53637265656e2d53686f742d323031392d30322d31382d61742d322e33372e32372d504d2e706e67)](https://camo.githubusercontent.com/c40e9055f61507f6d06e6cf7287403060caba66c7d0645438d3731bb6418611a/68747470733a2f2f6c61726176656c6461696c792e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031392f30322f53637265656e2d53686f742d323031392d30322d31382d61742d322e33372e32372d504d2e706e67)

---

License
-------

[](#license)

The MIT License (MIT). Please see [License File](license.md) for more information.

---

More from our LaravelDaily Team
-------------------------------

[](#more-from-our-laraveldaily-team)

- Read our [Daily Blog with Laravel Tutorials](https://laraveldaily.com)
- FREE E-book: [50 Laravel Quick Tips (and counting)](https://laraveldaily.com/free-e-book-40-laravel-quick-tips-and-counting/)
- Check out our adminpanel generator QuickAdminPanel: [Laravel version](https://quickadminpanel.com) and [Vue.js version](https://vue.quickadminpanel.com)
- Subscribe to our [YouTube channel Laravel Business](https://www.youtube.com/channel/UCTuplgOBi6tJIlesIboymGA)
- Enroll in our [Laravel Online Courses](https://laraveldaily.teachable.com/)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.4% 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 ~9 days

Recently: every ~4 days

Total

15

Last Release

2510d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bed443220c2b8506f985e92e807fc05e77037e40fd591513052e503c9527b7a6?d=identicon)[tpharaoh](/maintainers/tpharaoh)

---

Top Contributors

[![PovilasKorop](https://avatars.githubusercontent.com/u/1510147?v=4)](https://github.com/PovilasKorop "PovilasKorop (24 commits)")[![mixartemev](https://avatars.githubusercontent.com/u/5181924?v=4)](https://github.com/mixartemev "mixartemev (4 commits)")[![tpharaoh](https://avatars.githubusercontent.com/u/2931452?v=4)](https://github.com/tpharaoh "tpharaoh (3 commits)")

### Embed Badge

![Health badge](/badges/tpharaoh-laravel-charts/health.svg)

```
[![Health](https://phpackages.com/badges/tpharaoh-laravel-charts/health.svg)](https://phpackages.com/packages/tpharaoh-laravel-charts)
```

###  Alternatives

[liebig/cron

Job scheduling for Laravel

455224.3k](/packages/liebig-cron)[dollar/generators

Laravel 4 Generators w/ Bootstrap 3

7723.2k](/packages/dollar-generators)[witty/laravel-table-view

Laravel 5 Package for easily displaying table views for Eloquent Collections with search and sort functionality built in.

4612.3k](/packages/witty-laravel-table-view)

PHPackages © 2026

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