PHPackages                             mukadi/chartjs-bundle - 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. mukadi/chartjs-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

mukadi/chartjs-bundle
=====================

build awesome charts directly from your ORM Entities

3.2.1(1y ago)49.5k61MITPHPPHP &gt;=8.0

Since Jun 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mbo2olivier/MukadiChartJSBundle)[ Packagist](https://packagist.org/packages/mukadi/chartjs-bundle)[ RSS](/packages/mukadi-chartjs-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (5)Versions (13)Used By (1)

Mukadi ChartJs Bundle
=====================

[](#mukadi-chartjs-bundle)

Build awesome charts directly from ORM Entities, using `MukadiChartJsBundle` to create high quality chart mapped directly to your data model. `MukadiChartJsBundle` is an adaptation of the [mukadi/chartjs-builder](https://github.com/mbo2olivier/mukadi-chartjs-builder) package for symfony, Here are some provided features:

- a service for build chart from DQL queries and native SQL queries
- a Twig extension for render chart in the view

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

[](#installation)

Install the bundle via composer by running the following command:

`php composer.phar require mukadi/chartjs-bundle`

And run `php bin/console assets:install` for installing assets in the public web directory

Chart Factory
-------------

[](#chart-factory)

The bundle provide the `Mukadi\ChartJSBundle\Factory\ChartFactory` service (or `@mukadi.chart.factory` if you are not using autowiring):

You can use chart factory like any other symfony service:

```
namespace App\Controller;

use App\Chart\VideoGame;
use Mukadi\ChartJSBundle\Factory\ChartFactory;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class AppController extends AbstractController{

    #[Route('/', name: 'app_app')]
    public function index(ChartFactory $factory): Response {
        $chart = $factory
                ->withDql() # if you plan to use DQL query
                ->createChartBuilder()
                ->asBar()
                    ->query("SELECT COUNT(j) total, AVG(j.prix) prix, j.console console FROM \App\Entity\VideoGame j group by j.console")
                    ->labels('console')
                    ->dataset("Prix moyen")
                        ->data('prix')->useRandomBackgroundColor()
                    ->end()
                    ->dataset("Nombre")
                        ->data('total')->useRandomBackgroundColor()
                    ->end()
                ->build()
                ->getChart()
                ;

        $chart2 = $factory
                ->withNativeSql() # if you gonna use native SQL query
                ->createChartBuilder()
                ->asBar()
                    ->query("SELECT COUNT(*) total, AVG(prix) prix, console FROM jeux_video GROUP BY console")
                    ->labels('console')
                    ->dataset("Prix moyen")
                        ->data('prix')->useRandomBackgroundColor()
                    ->end()
                    ->dataset("Nombre")
                        ->data('total')->useRandomBackgroundColor()
                    ->end()
                ->build()
                ->getChart()
                ;

        return $this->render('app/index.html.twig', [
            'chart' => $chart,
            'chart2' => $chart2,
        ]);
    }
}
```

Please, see the [mukadi/chartjs-builder documentation](https://github.com/mbo2olivier/mukadi-chartjs-builder) if you want to learn more about chart construction.

Render chart in twig template
-----------------------------

[](#render-chart-in-twig-template)

In twig template use the dedicated function for chart rendering:

```
{{ mukadi_chart(chart) }}
```

Don't forget to include libraries in your page:

```

```

And that's all !

Use chart definitions
---------------------

[](#use-chart-definitions)

The Charts definition is an elegant way to build your charts in separate classes, so you get a more readable code and also reusable charts (a very powerful feature when combining with parametrized query). Read more about chart definition in the core [mukadi/chartjs-builder](https://github.com/mbo2olivier/mukadi-chartjs-builder) library.

Create your chart by implementing the `Mukadi\Chart\ChartDefinitionInterface` interface:

```
namespace App\Chart;

use Mukadi\Chart\ChartDefinitionBuilderInterface;
use Mukadi\Chart\ChartDefinitionInterface;

class VideoGameChart implements ChartDefinitionInterface {

    public function define(ChartDefinitionBuilderInterface $builder): void
    {
        $sql = "SELECT COUNT(*) total, AVG(prix) prix, console FROM jeux_video WHERE possesseur = :possesseur GROUP BY console";

        $builder
            ->asPolarArea()
            ->query($sql)
            ->labels('console')
            ->dataset("Total")
                ->data('total')->useRandomBackgroundColor()
            ->end()
            ->dataset("Prix moyen")
                ->data('prix')->useRandomBackgroundColor()
            ->end()
        ;
    }
}
```

In your controller you only have to write this:

```
 $chart = $factory
                ->withNativeSql()
                ->createFromDefinition(VideoGameChart::class)
                ->setParameter(':possesseur', 'Michel')
                ->getChart()
                ;
```

Note: you can use the FCQN of the chart definition only if the class is managed by the DI component, if you are using the standard symfony `services.yml` file so it's automatically handled for you, if you don't you must do it by yourself.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 90.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 ~242 days

Recently: every ~140 days

Total

12

Last Release

609d ago

Major Versions

0.0.2 → 1.0.02018-07-21

1.0.2 → 2.0.02020-11-13

2.x-dev → 3.0.02023-03-02

PHP version history (4 changes)0.0.1PHP &gt;=5.3.7

1.0.0PHP &gt;=5.4

2.0.0PHP ^7.1.3

3.0.0PHP &gt;=8.0

### Community

Maintainers

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

---

Top Contributors

[![mbo2olivier](https://avatars.githubusercontent.com/u/6231735?v=4)](https://github.com/mbo2olivier "mbo2olivier (20 commits)")[![psyray](https://avatars.githubusercontent.com/u/1230954?v=4)](https://github.com/psyray "psyray (2 commits)")

---

Tags

graphicschartjsSymfony BundlechartsChart builder

### Embed Badge

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

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

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)

PHPackages © 2026

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