PHPackages                             sjaakp/yii2-gcharts - 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. sjaakp/yii2-gcharts

ActiveYii2-extension

sjaakp/yii2-gcharts
===================

Google Charts the Yii 2.0 way

1.1.1(4y ago)2234.6k↓45%6[4 issues](https://github.com/sjaakp/yii2-gcharts/issues)[1 PRs](https://github.com/sjaakp/yii2-gcharts/pulls)1MITPHP

Since Oct 29Pushed 4y ago6 watchersCompare

[ Source](https://github.com/sjaakp/yii2-gcharts)[ Packagist](https://packagist.org/packages/sjaakp/yii2-gcharts)[ RSS](/packages/sjaakp-yii2-gcharts/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (1)

yii2-gcharts
============

[](#yii2-gcharts)

#### Google Charts the Yii 2.0 way

[](#google-charts-the-yii-20-way)

[![Latest Stable Version](https://camo.githubusercontent.com/4bc5e525abda84943903c14e8c630c7e4539018f126993041ba2835926dbf8b0/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d676368617274732f762f737461626c65)](https://packagist.org/packages/sjaakp/yii2-gcharts)[![Total Downloads](https://camo.githubusercontent.com/13fc0aaea1b942dd74fc221c4350ad97de183f6ccd31bd04b59e88ee5ec971ad/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d676368617274732f646f776e6c6f616473)](https://packagist.org/packages/sjaakp/yii2-gcharts)[![License](https://camo.githubusercontent.com/34b92e469188e9b97513de724fa23afe3b7e9fa38c52fe46154c344b044a2a59/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d676368617274732f6c6963656e7365)](https://packagist.org/packages/sjaakp/yii2-gcharts)

**yii2-gcharts** is a collection of widgets to render selected [Google Charts](https://developers.google.com/chart/ "Google Developers") in the [Yii 2.0](http://www.yiiframework.com/ "Yii") PHP Framework, like you would use a [GridView](http://www.yiiframework.com/doc-2.0/yii-grid-gridview.html "Yii").

Currently, **yii2-gcharts** consists of the following widgets:

- [AreaChart](https://developers.google.com/chart/interactive/docs/gallery/areachart "Google Developers")
- [BarChart](https://developers.google.com/chart/interactive/docs/gallery/barchart "Google Developers")
- [BubbleChart](https://developers.google.com/chart/interactive/docs/gallery/bubblechart "Google Developers")
- [ColumnChart](https://developers.google.com/chart/interactive/docs/gallery/columnchart "Google Developers")
- [GeoChart](https://developers.google.com/chart/interactive/docs/gallery/geochart "Google Developers")
- [LineChart](https://developers.google.com/chart/interactive/docs/gallery/linechart "Google Developers")
- [PieChart](https://developers.google.com/chart/interactive/docs/gallery/piechart "Google Developers")
- [ScatterChart](https://developers.google.com/chart/interactive/docs/gallery/scatterchart "Google Developers")

A demonstration of **Yii2-gcharts** is [here](http://www.sjaakpriester.nl/software/yii2-gcharts).

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

[](#installation)

Install **yii2-gcharts** with [Composer](https://getcomposer.org/). Either add the following to the require section of your `composer.json` file:

`"sjaakp/yii2-gcharts": "*"`

Or run:

`composer require sjaakp/yii2-gcharts "*"`

You can manually install **yii2-gcharts** by [downloading the source in ZIP-format](https://github.com/sjaakp/yii2-gcharts/archive/master.zip).

Using yii2-gcharts
------------------

[](#using-yii2-gcharts)

Use the **yii2 charts** widgets just like you would use a [GridView](http://www.yiiframework.com/doc-2.0/yii-grid-gridview.html "Yii Framework"). For instance, in the Controller you might have something like:

```

```

To render a PieChart in the View we could use:

```

...

...

```

Each of the chart types has slight variations in the column interpretation, and its own set of options. Consult the [Google Charts documentation](https://developers.google.com/chart/?hl=nl "Google Developers").

Options
-------

[](#options)

All the **yii2-gcharts** widgets share the same options:

### dataProvider

[](#dataprovider)

The data provider for the chart. This property is required. In most cases, it will be an `ActiveDataProvider` or an `ArrayDataProvider`.

### columns

[](#columns)

Chart column configuration array. Each array element configures one chart column. Each column configuration is an `array` or a `string` shortcut.

An `array` column configuration can have the following members (all are optional, but at least one must be given):

- **attribute** The attribute name associated with this column. When `value` is not specified, the value of the attribute will be retrieved from each data model.
- **formatted** The Google Charts formatted version of the data. Can be a callable of the form `function($model, $attribute, $index, $widget)`.
- **label** The label assigned to the data. If not given, it is either retrieved from the model or derived from `attribute`.
- **pattern** The Google Charts [pattern](https://developers.google.com/chart/interactive/docs/querylanguage#Format "Google Developers").
- **role** The Google Charts [role](https://developers.google.com/chart/interactive/docs/roles "Google Developers"). Can be one of:

    - `"annotation"`
    - `"annotationText"`
    - `"certainty"`
    - `"emphasis"`
    - `"interval"`
    - `"scope"`
    - `"style"`
    - `"tooltip"`
- **type** The Google Charts [data type](https://developers.google.com/chart/interactive/docs/reference#DataTable "Google Developers"). Can be one of:

    - `"number"` (default)
    - `"string"`
    - `"boolean"`
    - `"date"`
    - `"datetime"`
    - `"timeofday"`
- **value** The data value. This can be a callable of the form `function($model, $attribute, $index, $widget)`. If not given, the value of the model's `attribute` is taken.

The `string` shortcut configuration specifies the attribute, type, and label in the format `"attribute:type:label"`. Both type and label are optional; they take their default values if omitted.

### mode

[](#mode)

`string` This determines which variant of the chart is drawn. Must be one of:

- `"classic"` (default) Draws the 'ordinary' version of the chart,
- `"material"` Draws the new, Material version of the chart, if available,
- `"transition"` Draws the Material version, if available, and also applies `convertOptions()` to the options

**Notice** that only a few of the charts are currently available in Material version and that they're in early beta, lacking lots of the 'classic' options.

**Notice also** that currently, the Material options are undocumented, so the only practical way to work with Material charts is using the `"transition"` mode.

### version

[](#version)

`string` The version of the **gcharts** library used. Must be one of:

- `"current"` (default),
- `"upcoming"`,
- `number`

[More](https://developers.google.com/chart/interactive/docs/basic_load_libs#load-version-name-or-number) information.

### mapsApiKey

[](#mapsapikey)

`string` Applies to **GeoChart** only. It is advised to provide **GeoChart** with an [API-key](https://developers.google.com/chart/interactive/docs/gallery/geochart#loading) of Google Maps.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~1188 days

Total

3

Last Release

1479d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/156f636aceedc73021a2bfafb5433271c2c55d6cf4bce06b12902c85b4b491f1?d=identicon)[sjaakp](/maintainers/sjaakp)

---

Top Contributors

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

---

Tags

yii2extensionwidgetyiichartsvisualization

### Embed Badge

![Health badge](/badges/sjaakp-yii2-gcharts/health.svg)

```
[![Health](https://phpackages.com/badges/sjaakp-yii2-gcharts/health.svg)](https://phpackages.com/packages/sjaakp-yii2-gcharts)
```

PHPackages © 2026

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