PHPackages                             bbsnly/chartjs-php - 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. bbsnly/chartjs-php

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

bbsnly/chartjs-php
==================

PHP wrapper for Chart.js library

v4.0.1(1y ago)27108.4k↓46.4%6[1 issues](https://github.com/bbsnly/chartjs-php/issues)1MITPHPPHP &gt;=8.2CI passing

Since Jul 19Pushed 1w ago3 watchersCompare

[ Source](https://github.com/bbsnly/chartjs-php)[ Packagist](https://packagist.org/packages/bbsnly/chartjs-php)[ Docs](https://github.com/bbsnly/chartjs-php)[ RSS](/packages/bbsnly-chartjs-php/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (1)Versions (16)Used By (1)

ChartJS-PHP
===========

[](#chartjs-php)

[![Contributor Covenant](https://camo.githubusercontent.com/4ae39ae593b602cf0ae07972b61c73728b77ec8e2cf40f579a2441948208036b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6e7472696275746f72253230436f76656e616e742d322e312d3462616161612e737667)](CODE_OF_CONDUCT.md)[![Tests](https://github.com/bbsnly/chartjs-php/actions/workflows/php.yml/badge.svg)](https://github.com/bbsnly/chartjs-php/actions)[![codecov](https://camo.githubusercontent.com/8e620562c5338ac2a54d47b4994718dfe790d758cbab3e2b904fdb1ec0269536/68747470733a2f2f636f6465636f762e696f2f67682f6262736e6c792f63686172746a732d7068702f67726170682f62616467652e7376673f746f6b656e3d4d5449424e5038424454)](https://codecov.io/gh/bbsnly/chartjs-php)[![Total Downloads](https://camo.githubusercontent.com/aab1338a02e9862e97d769ef4984b8def21222e3295bbe536453cc1940f3a474/68747470733a2f2f706f7365722e707567782e6f72672f6262736e6c792f63686172746a732d7068702f642f746f74616c2e737667)](https://packagist.org/packages/bbsnly/chartjs-php)[![Latest Stable Version](https://camo.githubusercontent.com/9584d9eb1d1b8c2d93d583f1cd54e15ef68e548088cd4dff49922ca3c1c21b9a/68747470733a2f2f706f7365722e707567782e6f72672f6262736e6c792f63686172746a732d7068702f762f737461626c652e737667)](https://packagist.org/packages/bbsnly/chartjs-php)[![License](https://camo.githubusercontent.com/f2b5859773e42657f3e22bdd3a6503d6008dac56b99fa08cd3602a44ad005276/68747470733a2f2f706f7365722e707567782e6f72672f6262736e6c792f63686172746a732d7068702f6c6963656e73652e737667)](https://packagist.org/packages/bbsnly/chartjs-php)

This package transforms how you create [ChartJS](https://www.chartjs.org/ "ChartJS") elements by bringing them directly into PHP.

ChartJS-PHP eliminates the complexity of JavaScript when working with [ChartJS](https://www.chartjs.org/ "ChartJS") charts. While [ChartJS](https://www.chartjs.org/ "ChartJS") traditionally requires JavaScript implementation, our PHP solution delivers the same powerful charts through clean, efficient PHP code. By generating [ChartJS](https://www.chartjs.org/ "ChartJS") elements directly in PHP, you write less code, maintain cleaner codebases, and deliver faster results. This is the definitive solution for PHP developers building data visualizations, dashboards, or any application requiring dynamic charts.

**Note: Include the ChartJS library in your project as specified in their [official documentation](https://www.chartjs.org/docs/latest/getting-started/).**

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

[](#installation)

Installing ChartJS-PHP is straightforward with [Composer](https://getcomposer.org/). Run this command in your project directory:

```
composer require bbsnly/chartjs-php
```

Minimum Requirements:

- PHP version: 8.1 or higher
- ChartJS version: 2.0 or higher

Usage
-----

[](#usage)

Creating charts with ChartJS-PHP is simple and intuitive. Start by instantiating the `Chart` class, define your data, and render your chart. The library handles all the complexity for you.

Choose from our specialized chart classes for even faster development: `BarChart`, `BubbleChart`, `DoughnutChart`, `LineChart`, `PieChart`, `PolarAreaChart`, `RadarChart`, and `ScatterChart`.

Here's how to create a line chart:

```
use Bbsnly\ChartJs\Chart;
use Bbsnly\ChartJs\Config\Data;
use Bbsnly\ChartJs\Config\Dataset;
use Bbsnly\ChartJs\Config\Options;

$chart = new Chart;
$chart->type = 'line';

$data = new Data();
$data->labels = ['Red', 'Green', 'Blue'];

$dataset = new Dataset();
$dataset->data = [5, 10, 20];
$data->datasets[] = $dataset;

$chart->data($data);

$options = new Options();
$options->responsive = true;
$chart->options($options);

$chart->get(); // Returns the array of chart data
$chart->toJson(); // Returns the JSON representation of the chart data
$chart->toHtml('my_chart'); // Returns the HTML and JavaScript code for the chart
```

---

In the example below we will use the `toHtml` method to generate the HTML and JavaScript code for the chart.

```

    toHtml('my_chart'); ?>

```

---

In the example below we will use the `toJson` method to generate the JSON representation of the chart data.

```

  const ctx = document.getElementById('myChart');

  new Chart(ctx, toJson(); ?>);

```

Tests
-----

[](#tests)

Run the test suite with:

```
composer test
```

Contributing
------------

[](#contributing)

Read our [Contributing](CONTRIBUTING.md) guidelines and start improving ChartJS-PHP today.

License
-------

[](#license)

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

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance69

Regular maintenance activity

Popularity43

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 72.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 ~183 days

Recently: every ~375 days

Total

15

Last Release

702d ago

Major Versions

1.2.1 → 2.2.02019-03-12

1.2.2 → 2.3.02020-06-18

2.x-dev → 3.0.02020-06-18

3.0.1 → v4.0.02024-02-03

1.2.x-dev → v4.0.12024-07-31

PHP version history (4 changes)2.0.0PHP &gt;=7.0

2.1.1PHP &gt;=7.1

3.0.0PHP &gt;=7.4

v4.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8020430?v=4)[Anatoliy Babushka](/maintainers/bbsnly)[@bbsnly](https://github.com/bbsnly)

---

Top Contributors

[![bbsnly](https://avatars.githubusercontent.com/u/8020430?v=4)](https://github.com/bbsnly "bbsnly (89 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (33 commits)")[![TomSchenk](https://avatars.githubusercontent.com/u/12969197?v=4)](https://github.com/TomSchenk "TomSchenk (1 commits)")

---

Tags

analyticschart-generationchart-librarychartjschartsdata-visualizationgraphsphpphp-libraryphp-wrapperstatisticsphpchartjs

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21623.4k](/packages/imanghafoori-laravel-anypass)[halfpastfouram/phpchartjs

PHP library for ChartJS

2512.4k](/packages/halfpastfouram-phpchartjs)[epessine/axis

Draw charts with a simple API on Laravel

267.3k](/packages/epessine-axis)

PHPackages © 2026

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