PHPackages                             saad-tazi/g-chart-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. saad-tazi/g-chart-bundle

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

saad-tazi/g-chart-bundle
========================

A super simple Bundle that facilitate the usage of Google Chart Tool, Google Chart Image API and Google Infographics.

4.1.0(2y ago)20167.1k↓33.3%18[2 issues](https://github.com/saadtazi/SaadTaziGChartBundle/issues)MITPHP

Since Jul 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/saadtazi/SaadTaziGChartBundle)[ Packagist](https://packagist.org/packages/saad-tazi/g-chart-bundle)[ RSS](/packages/saad-tazi-g-chart-bundle/feed)WikiDiscussions master Synced 1mo ago

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

What is it?
===========

[](#what-is-it)

This is a super simple Bundle that facilitates the usage of [Google Chart Tool](https://developers.google.com/chart/), [Google Chart Image API](http://code.google.com/apis/chart/image/) and [Google Infographics](http://code.google.com/apis/chart/infographics/).

It allows to render:

- QRCode
- Pie Chart (3 ways: canvas or svg, simple image from url, simple 3d image from url)
- Column Chart
- Bar Chart
- Area Chart
- scatter Chart
- Combo Chart
- Table
- Gauge
- Candlestick Chart
- Map tree
- Dynamic Icons

Added (special recommendations are below):

- Calendar
- Bubble Chart
- Donut Chart (you don't really need it as you can do it with Pie Chart and configuration but it is a shortcut)
- Gantt (beware gantt are betas)
- Geo Chart
- Histogram
- Interval
- Map
- Org Chart
- Sankey
- Stepped Area Chart
- Timeline
- Trendline
- Waterfall
- Word Tree

Make sure you read the [Chart Image terms](http://code.google.com/apis/chart/image/terms.html) and [Chart tool terms](http://code.google.com/apis/chart/interactive/terms.html) before using that bundle.

It also contains some Twig extension that facilitates the integration.

Versions
--------

[](#versions)

You should use a different version of this bundle depending on your symfony version:

Symfony versionbundle version5+4.xsf 4.4+ (&lt; 5)3.2.1+sf 3.x to 4.33.1.1Demo
----

[](#demo)

How to install it?
------------------

[](#how-to-install-it)

Thanks to [AaronDDM](http://example.com/ "AaronDDM"), you can use [composer](http://packagist.org/packages/saad-tazi/g-chart-bundle "composer") to install the bundle.

```
composer require saad-tazi/g-chart-bundle

```

Or you can use the following method:

1. Add this bundle to your `vendor/` dir:

    - Using the vendors script.

        Add the following lines in your `deps` file:

        ```
        [SaadTaziGChartBundle]
            git=git://github.com/saadtazi/SaadTaziGChartBundle.git
            target=/bundles/SaadTazi/GChartBundle

        ```

        Run the vendors script:

        ```
        ./bin/vendors install

        ```
    - Using git submodules.

        ```
        $ git submodule add git://github.com/saadtazi/SaadTaziGChartBundle.git vendor/bundles/SaadTazi/GChartBundle

        ```
2. Add the SaadTazi namespace to your autoloader:

```
          // app/autoload.php
          $loader->registerNamespaces(array(
                'SaadTazi' => __DIR__.'/../vendor/bundles',
                // your other namespaces
          ));
```

3. Add this bundle to your application's kernel:

```
          // app/ApplicationKernel.php
          public function registerBundles()
          {
              return array(
                  // ...
                  new SaadTazi\GChartBundle\SaadTaziGChartBundle(),
                  // ...
              );
          }
```

Demo pages
==========

[](#demo-pages)

This is optional: If you want to see the demo page, add the following to your routing.yml:

```
    _demo:
        resource: "@SaadTaziGChartBundle/Resources/config/routing.yml"
        type:     yaml
        prefix:   /gchart
```

You should have `templating` installed (`php ../composer.phar require templating`) and should have activated it in `config/packages/framework.yml:

```
framework:
    templating:
        engines: ['twig']

```

Then you should be able to go to

Don't forget to include the required javascript in your layout, for example:

```

            // adds the package you need. See https://developers.google.com/chart/interactive/docs/basic_load_libs
            google.charts.load('current', {packages:["corechart", 'table', 'gauge']});

```

How to use it?
--------------

[](#how-to-use-it)

Mmm, please check the Controller\\DemoController to see how to build DataTable, and Resources\\views\\Demo\\demo.html.twig

Notes
-----

[](#notes)

I implemented almost all the corechart chart types from the Google Chart Tool. But I only implemented 3 Google Chart Image types, because (they are ugly and) almost all of them can be built using the Google Chart Tool. From the Visualization, I only implemented the marker.

Ohh, please feel free to fork, add to it and send me pull requests!

Note: You don't have to use the Twig functions: you can use the php classes (in DataTable and or in Chart). But you will probably find it a little bit "painful".

Using the added charts
----------------------

[](#using-the-added-charts)

Calendar, Interval and gantt (charts needing dates as datas) :

These are special charts see

These charts needs javascript Date Objects in first column.

As the Js Date Object need to be written (in json) like :

```

    [ new Date(2012, 3, 13), 37032 ],
    [ new Date(2012, 3, 14), 38024 ],
    [ new Date(2012, 3, 15), 38024 ],
    [ new Date(2012, 3, 16), 38108 ],
    [ new Date(2012, 3, 17), 38229 ],

```

I encountered issues with PHP and Json\_encode. To avoid this you had to make your datas like this :

```
    $datas = array(
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-01"), 'md' => 3),
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-02"), 'md' => 5),
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-03"), 'md' => 1),
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-04"), 'md' => 9),
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-10"), 'md' => 24),
    );
    $res = new DataTable();
    $res->addColumn('date', 'Date', 'date');
    $res->addColumn('my_datas', 'My Datas', 'number');
    foreach($datas as $data) {
        // js month starts at 0 for Jan !
        $date => $data['date']->format("Y, ").(intval($data['date']->format("m"))-1).$data['date']->format(", d");
        $res->addRow([['v' => "new Date[[[{$date}]]]"], ['v' => $data['md']]);
    }
```

It gives the following json (don't get scared by the '"new Date\[\[\[' and '\]\]\]"', they are substituded when needed in the twig) :

```

    [ "new Date[[[2016, 2, 1]]]", 3 ],....

```

You can had a Tooltip to your datas by using this code :

```
    // 'role_tooltip' must be written as i showed because it makes all the magic.
    $res->addColumn('role_tooltip', 'Tooltip', 'string');

    // ....

    foreach($datas as $data) {
        // js month starts at 0 for Jan !
        $date => $data['date']->format("Y, ").(intval($data['date']->format("m"))-1).$data['date']->format(", d");
        $res->addRow([['v' => "new Date[[[{$date}]]]"], ['v' => $data['md'], ['v' => "My wonderfull Tooltip for this row"]]);
    }
```

Support for events
------------------

[](#support-for-events)

You can define your own callback functions and associate it to the corresponding chart event like this:

```
    &nbsp;

        $(function() {
            var myMo = function (ee) {
                console.log('Mouse over');
            }
            var myMou = function (ee) {
                console.log('Mouse out');
            }
            var myR = function () {
                console.log('Ready');
            }

            {{ gchart_calendar(calDatas, 'calChart', 950, 180, 'My cal datas', {tooltip:{isHtml: true,trigger: 'selection'}},
                [{'eventName': 'ready', 'callbackFunc': 'myR'},
                 {'eventName': 'onmouseover', 'callbackFunc': 'myMo'},
                 {'eventName': 'onmouseout', 'callbackFunc': 'myMou'},
          ]) }}
        });

```

Have fun with those mods ;-)

Mods
----

[](#mods)

2012-03-20

- added composer support (thanks to AaronDDM)

2011-10-23

- removed jQuery dependency (and div output - needs to be done "manually" now... Provides more control)

2011-09-22

- zero value bug fix

2011-09-06

- Added DataTable::toStrictArray() that checks array keys (ticket #1)

2011-06-23

- Initial commit

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 59.3% 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 ~256 days

Recently: every ~472 days

Total

16

Last Release

840d ago

Major Versions

v1.5.0 → v2.0.02017-01-10

v2.0.0 → v3.0.02018-02-01

v3.1.1 → v4.0.02021-01-28

v3.2.1 → 4.1.02024-01-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/092540e0b436b25159bf863312a5c1ff3be064543c064b0914ea202bafec736d?d=identicon)[saadtazi](/maintainers/saadtazi)

---

Top Contributors

[![saadtazi](https://avatars.githubusercontent.com/u/168223?v=4)](https://github.com/saadtazi "saadtazi (51 commits)")[![symio](https://avatars.githubusercontent.com/u/52332?v=4)](https://github.com/symio "symio (14 commits)")[![edhgoose](https://avatars.githubusercontent.com/u/1108173?v=4)](https://github.com/edhgoose "edhgoose (6 commits)")[![amorebietakoUdala](https://avatars.githubusercontent.com/u/30795155?v=4)](https://github.com/amorebietakoUdala "amorebietakoUdala (3 commits)")[![raphaabreu](https://avatars.githubusercontent.com/u/3214715?v=4)](https://github.com/raphaabreu "raphaabreu (3 commits)")[![haet](https://avatars.githubusercontent.com/u/794626?v=4)](https://github.com/haet "haet (1 commits)")[![wolfish](https://avatars.githubusercontent.com/u/2969877?v=4)](https://github.com/wolfish "wolfish (1 commits)")[![Xen3r0](https://avatars.githubusercontent.com/u/2823704?v=4)](https://github.com/Xen3r0 "Xen3r0 (1 commits)")[![AaronDDM](https://avatars.githubusercontent.com/u/314152?v=4)](https://github.com/AaronDDM "AaronDDM (1 commits)")[![zhil](https://avatars.githubusercontent.com/u/981783?v=4)](https://github.com/zhil "zhil (1 commits)")[![andreia](https://avatars.githubusercontent.com/u/38911?v=4)](https://github.com/andreia "andreia (1 commits)")[![bouke-nederstigt](https://avatars.githubusercontent.com/u/3441985?v=4)](https://github.com/bouke-nederstigt "bouke-nederstigt (1 commits)")[![cbeyer](https://avatars.githubusercontent.com/u/1151497?v=4)](https://github.com/cbeyer "cbeyer (1 commits)")[![GCalmels](https://avatars.githubusercontent.com/u/5655839?v=4)](https://github.com/GCalmels "GCalmels (1 commits)")

---

Tags

googlechart

### Embed Badge

![Health badge](/badges/saad-tazi-g-chart-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/saad-tazi-g-chart-bundle/health.svg)](https://phpackages.com/packages/saad-tazi-g-chart-bundle)
```

###  Alternatives

[nnnick/chartjs

Simple HTML5 charts using the canvas element.

67.3k1.1M15](/packages/nnnick-chartjs)[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[spatie/laravel-google-calendar

Manage events on a Google Calendar

1.4k1.5M21](/packages/spatie-laravel-google-calendar)[egeloen/google-map-bundle

Provides a google map integration for your Symfony2 Project.

216716.3k3](/packages/egeloen-google-map-bundle)[emcconville/google-map-polyline-encoding-tool

A simple class to handle polyline-encoding for Google Maps

1572.3M2](/packages/emcconville-google-map-polyline-encoding-tool)[amenadiel/jpgraph

Composer Friendly, full refactor of JpGraph, library to make graphs and charts

1492.2M7](/packages/amenadiel-jpgraph)

PHPackages © 2026

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