PHPackages                             tomvandenberk/chartjs-wrapper - 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. tomvandenberk/chartjs-wrapper

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

tomvandenberk/chartjs-wrapper
=============================

A wrapper for ChartJs data.

v1.0.1(1y ago)011UnlicensePHPPHP &gt;=8.3

Since Mar 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/TomBerkGH/chartjs-wrapper)[ Packagist](https://packagist.org/packages/tomvandenberk/chartjs-wrapper)[ RSS](/packages/tomvandenberk-chartjs-wrapper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

chartjs-wrapper
===============

[](#chartjs-wrapper)

This is a lightweight PHP wrapper designed to simplify the use of ChartJs in combination with APIs. It takes raw data and transforms it into a structured JSON format that can be directly used with ChartJs.

This is especially useful in scenarios where data is retrieved dynamically via an API. The wrapper ensures the data is correctly formatted and ready for use, making it easier to generate charts such as line graphs, bar charts, and pie charts without additional processing. This helps to streamline the process of connecting a PHP backend to ChartJs on the frontend.

Example usage in Laravel:

```
return response()->json(new Data(
    $data->pluck('label')->toArray(), [
        new DataSet($data->pluck('value')->toArray(), [
            'backgroundColor' => $data->pluck('color'),
        ])
    ]
)->addExtraValues('ids', $data->pluck('id')->toArray())->addExtraValues('person_ids', $data->pluck('person_id')->toArray()));
```

```
$datasets = [];
$items->each(function ($item) use (&$datasets, $weeks) {
    $datasets[] = new DataSet($item->pluck('total_hours')->toArray(), [
        'label' => $item->pluck('person')->first() ?? '',
    ])->withColorsBasedOnLabel();
});

return response()->json(new Data($weeks, $datasets));
```

output can be directly used in ChartJS

```
{
    "labels": [
        "2024-W52",
        "2025-W01",
        "2025-W02",
        "2025-W03",
        "2025-W04",
        "2025-W05",
        "2025-W06",
        "2025-W07",
        "2025-W08",
        "2025-W09",
        "2025-W10"
    ],
    "datasets": [
        {
            "label": "Label 1",
            "data": [
                0,
                13.2,
                13.2,
                26.4,
                13.2,
                19.8,
                6.6,
                19.8,
                33,
                6.6,
                0
            ],
            "pointRadius": 5,
            "pointHoverRadius": 20,
            "borderRadius": 5,
            "fill": true,
            "tension": 0,
            "borderColor": "#f26656",
            "backgroundColor": "rgba(242, 102, 86, 0.5)"
        },
        {
            "label": "Label 2",
            "data": [
                0,
                3.75,
                13.2,
                19.8,
                5.6,
                26.4,
                13.2,
                41.78333333333333,
                0,
                6.6,
                0
            ],
            "pointRadius": 5,
            "pointHoverRadius": 20,
            "borderRadius": 5,
            "fill": true,
            "tension": 0,
            "borderColor": "#50220a",
            "backgroundColor": "rgba(80, 34, 10, 0.5)"
        }
    ]
}
```

```
new Chart(document.getElementById('chart'), {
    type: 'line',
    data: @json($chart_data),
    options: {
        responsive: true,
        maintainAspectRatio: false,
    }
});
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance47

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

430d ago

### Community

Maintainers

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

---

Top Contributors

[![TomBerkGH](https://avatars.githubusercontent.com/u/54434138?v=4)](https://github.com/TomBerkGH "TomBerkGH (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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