PHPackages                             martinsik/google-chart-generator - 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. martinsik/google-chart-generator

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

martinsik/google-chart-generator
================================

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 &lt;google-chart&gt; element

2.0.3(10y ago)23392MITPHPPHP &gt;=5.4

Since Jul 26Pushed 10y ago1 watchersCompare

[ Source](https://github.com/martinsik/google-chart-generator)[ Packagist](https://packagist.org/packages/martinsik/google-chart-generator)[ Docs](https://github.com/martinsik/google-chart-generator)[ RSS](/packages/martinsik-google-chart-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

Google Chart Generator
======================

[](#google-chart-generator)

[![Build Status](https://camo.githubusercontent.com/7bea027771456165c53a9eb0cea547ce93ec7002d34c337555fffd66496fe226/68747470733a2f2f7472617669732d63692e6f72672f6d617274696e73696b2f676f6f676c652d63686172742d67656e657261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/martinsik/google-chart-generator)

PHP 5.4+ wrapper around [Google Chart API](https://developers.google.com/chart/interactive/docs/) based on [Polymer 1.0 component ``](https://elements.polymer-project.org/elements/google-chart).

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

[](#installation)

Add `composer.json` dependency:

```
"require": {
    "martinsik/google-chart-generator": "^2.0.0"
}

```

Add `bower.json` dependency (Polymer 1.0):

```
"dependencies": {
    "google-chart": "GoogleWebComponents/google-chart#^1.0.0"
}

```

Eventually, install `google-chart` Polymer component [as you want](https://www.polymer-project.org/1.0/docs/start/getting-the-code.html).

Charts
------

[](#charts)

Right now, four chart types are supported: [line](https://developers.google.com/chart/interactive/docs/gallery/linechart), [bar](https://developers.google.com/chart/interactive/docs/gallery/barchart), [column](https://developers.google.com/chart/interactive/docs/gallery/columnchart) and [pie](https://developers.google.com/chart/interactive/docs/gallery/piechart) charts.

The PHP wrapper is very liberal, it lets you set any Google Chart options via data or chart options. It doesn't have special methods for every possible option because there are are so many of them and it doesn't make sense to make wrappers for every single one of them.

To use any chart you have to import Polymer 1.0 element and WebComponents polyfill first:

```

```

### Line chart

[](#line-chart)

Creating a line chart:

```
$chart = new LineChart(['title' => 'Test Chart #1']);
$chart->addData(new SequenceData([12, 24, 20, 18, 16, 45, 23, 15, 65, 32], ['label' => 'Line #1']));
$chart->addData(new SequenceData([31, 27, 31, 28, 30, 40, 52, 48, 78, 45], ['label' => 'Line #2']));
```

Get element HTML with `$chart->getElement()`.

```

```

See all possible options for [line charts](https://developers.google.com/chart/interactive/docs/gallery/linechart).

The above code would result into this chart.

[![Example Line Chart](https://raw.githubusercontent.com/martinsik/google-chart-generator/master/doc/line-chart.png)](https://raw.githubusercontent.com/martinsik/google-chart-generator/master/doc/line-chart.png)

### Pie chart

[](#pie-chart)

Creating pie chart:

```
$chart = new PieChart(['width' => '150px', 'height' => '150px', 'pieHole' => 0.5]);
$chart->addData([new SingleData(40, 'Arc #1'), new SingleData(60, 'Arc #2'), new SingleData(80, 'Arc #3')]);
```

Get element HTML with `$chart->getElement()`.

```

```

See all possible options for [pie charts](https://developers.google.com/chart/interactive/docs/gallery/piechart).

### Bar chart

[](#bar-chart)

Creating bar chart:

```
$chart = new BarChart();
$chart->addData(new SequenceData([20, 40, 30]));
```

Get element HTML with `$chart->getElement()`.

```

```

See all possible options for [bar charts](https://developers.google.com/chart/interactive/docs/gallery/barchart).

### Column chart

[](#column-chart)

Creating column chart:

```
$chart = new ColumnChart(['width' => '700px', 'isStacked' => true, 'legend' => ['position' => 'none']]);
$chart->addData(new SequenceData(["a1" => 20, "a2" => 40, "a3" => 30], ['label' => 'aaa']));
$chart->addData(new SequenceData(["a1" => 15, "a2" => 32, "a3" => 34], ['label' => 'bbb']));
$chart->addData(new SequenceData(["a1" => 21, "a2" => 42, "a3" => 17], ['label' => 'ccc']));
```

Get element HTML with `$chart->getElement()`.

```

```

See all possible options for [column charts](https://developers.google.com/chart/interactive/docs/gallery/columnchart).

Tests
-----

[](#tests)

All tests in this project are based on [behat](docs.behat.org/).

```
$ bin/behat

```

Then manually check generated charts in `features/generated_html`

License
-------

[](#license)

Google Chart Generator is licensed under The MIT License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 95% 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 ~37 days

Total

4

Last Release

3827d ago

### Community

Maintainers

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

---

Top Contributors

[![martinsik](https://avatars.githubusercontent.com/u/238765?v=4)](https://github.com/martinsik "martinsik (19 commits)")[![rdohms](https://avatars.githubusercontent.com/u/94331?v=4)](https://github.com/rdohms "rdohms (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/martinsik-google-chart-generator/health.svg)

```
[![Health](https://phpackages.com/badges/martinsik-google-chart-generator/health.svg)](https://phpackages.com/packages/martinsik-google-chart-generator)
```

###  Alternatives

[alexandresalome/assetic-extra-bundle

Extra feature for Assetic (asset directory)

1811.4k](/packages/alexandresalome-assetic-extra-bundle)

PHPackages © 2026

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