Google Charts the Yii Way
yii2-gcharts demo

This is a demonstration of a few Yii 2.0 classes rendering a selection of Google Charts.

ColumnChart

<?php
use sjaakp\gcharts\ColumnChart;

$dataProvider = new ActiveDataProvider([
        'query' => Eu::find()->orderBy(['gdp' => SORT_DESC]),
        'pagination' => false
    ]);
?>
    ...
<?= ColumnChart::widget([
    'height' => '400px',
    'dataProvider' => $dataProvider,
    'columns' => [
        'code:string',  // first column: domain
        'gdp',          // second column: data
        [               // third column: tooltip
            'value' => function($model, $a, $i, $w) {
                return "$model->name\nGDP: $ $model->gdp";
            },
            'type' => 'string',
            'role' => 'tooltip',
        ],
    ],
    'options' => [
        'title' => 'EU: Gross Domestic Product per Capita',
    ],
]) ?>
    ...

PieChart

<?php
use sjaakp\gcharts\PieChart;

$dataProvider = new ActiveDataProvider([
        'query' => Eu::find()->orderBy(['population' => SORT_DESC]),
        'pagination' => false
    ]);
?>
    ...
<?= PieChart::widget([
    'height' => '400px',
    'dataProvider' => $dataProvider,
    'columns' => [
        'columns' => [
            'name:string',  // first column: domain
            'population'    // second column: data
        ],
    ],
    'options' => [
        'title' => 'EU Population',
        'sliceVisibilityThreshold' => 0.022
    ],
]) ?>
    ...

GeoChart

<?php
use sjaakp\gcharts\GeoChart;

$dataProvider = new ActiveDataProvider([
        'query' => Eu::find(),
        'pagination' => false
    ]);
?>
    ...
<?= GeoChart::widget([
    'height' => '400px',
    'dataProvider' => $dataProvider,
    'columns' => [
        'columns' => [
            'name:string',  // first column: domain
            'gini'          // second column: data
        ],
    ],
    'options' => [
        'region' => '150',   // Europe
        // notice that GeoChart doesn't have a title option
    ],
]) ?>
    ...

ScatterChart

<?php
use sjaakp\gcharts\ScatterChart;

$dataProvider = new ActiveDataProvider([
        'query' => Eu::find(),
        'pagination' => false
    ]);
?>
    ...
<?= ScatterChart::widget([
    'height' => '400px',
    'dataProvider' => $dataProvider,
    'columns' => [
        'columns' => [
            'gdp',      // first column, data X values
            'hdi',      // second column, data Y values
            [           // third column, tooltips
                'value' => function($model, $a, $i, $w) {
                    return "$model->name\nGDP: $ $model->gdp -- HDI: $model->hdi";
                },
                'type' => 'string',
                'role' => 'tooltip',
            ],
        ],
    ],
    'options' => [
        'title' => "EU: Gross Domestic Product per Capita\nvs Human Development Index",
        'hAxis' => [ 'title' => 'GDP' ],
        'vAxis' => [ 'title' => 'HDI' ],
    ],
]) ?>
    ...

Other charts available are AreaChart, BarChart, BubbleChart, LineChart. There may be more in the future.

Data

Total 28 items.
NamePopulationArea (km2)GDP (dollars)Gini (inequality)HDI (human development)
Austria8511000838554703129.10.895
Belgium11203992305284380033.00.897
Bulgaria72456771109941832629.20.782
Croatia4246809565942116929.00.805
Cyprus85800092513076931.20.848
Czech Republic10398697788663089525.80.873
Denmark5621607430754545124.70.901
Estonia1315819452272799436.00.846
Finland54512703384244083826.90.892
France660769096748434101832.70.893
Germany807046913570214689528.30.920
Greece109927831319902677334.30.860
Hungary9877365930302589530.00.831
Ireland4604029702735111834.30.916
Italy611527983013383581136.00.881
Latvia2001468645892454035.70.814
Lithuania2943472652002821035.80.818
Luxembourg54968025869317330.80.875
Malta4253843163454425.80.847
Netherlands17082000415434831730.90.921
Poland380180003126852621034.90.821
Portugal10427301923902762438.50.816
Romania199426422383912052631.50.786
Slovakia5400598490352920925.80.840
Slovenia2061085202733050831.20.892
Spain465077605040303489932.00.885
Sweden96448644499644722825.00.916
United Kingdom645968002436104067636.00.875

(These data are from October, 2015. They were taken from Wikipedia.)