2017 © Pedro Peláez
 

yii2-extension yii2-google-charts

A wrapper for Google charts in Yii2

image

mrlco/yii2-google-charts

A wrapper for Google charts in Yii2

  • Monday, July 11, 2016
  • by mrlco
  • Repository
  • 1 Watchers
  • 2 Stars
  • 231 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 15 % Grown

The README.md

yii2-google-charts

A wrapper for Google charts in Yii2, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require mrlco/yii2-google-charts "*"

or add, (*4)

"mrlco/yii2-google-charts": "*"

to the require section of your composer.json file., (*5)

Usage

For more information see Google Charts, (*6)

Remember to include the GoogleCharts.php where ever you need:, (*7)

    use mrlco\googlecharts\GoogleCharts;

And in your view:, (*8)

 'PieChart',
    'containerId' => 'chart-container',
    'data' => [
        ['Task', 'Hours per Day'],
        ['Work', 11],
        ['Eat', 2],
        ['Commute', 2],
        ['Watch TV', 2],
        ['Sleep', 7]
    ],
    'options' => ['title' => 'My Daily Activity']
]);

// LineChart
echo GoogleCharts::widget([
    'visualization' => 'LineChart',
    'containerId' => 'chart-container',
    'data' => [
        ['Task', 'Hours per Day'],
        ['Work', 11],
        ['Eat', 2],
        ['Commute', 2],
        ['Watch TV', 2],
        ['Sleep', 7]
    ],
    'options' => ['title' => 'My Daily Activity']
]);

// Another LineChart example
echo GoogleCharts::widget([
    'visualization' => 'LineChart',
    'containerId' => 'chart-container',
    'data' => [
        ['Year', 'Sales', 'Expenses'],
        ['2004', 1000, 400],
        ['2005', 1170, 460],
        ['2006', 660, 1120],
        ['2007', 1030, 540],
    ],
    'options' => [
        'title' => 'My Company Performance',
        'titleTextStyle' => ['color' => '#FF0000'],
        'vAxis' => [
            'title' => 'Vertical Axis',
            'gridlines' => [
                'color' => 'transparent' //set grid line transparent
            ]
        ],
        'hAxis' => ['title' => 'Horizontal Aixs'],
        'curveType' => 'function', //smooth curve or not
        'legend' => ['position' => 'bottom'],
    ]
]);

// ScatterChart
echo GoogleCharts::widget([
    'visualization' => 'ScatterChart',
    'containerId' => 'chart-container',
    'data' => [
        ['Sales', 'Expenses', 'Quarter'],
        [1000, 400, '2015 Q1'],
        [1170, 460, '2015 Q2'],
        [660, 1120, '2015 Q3'],
        [1030, 540, '2015 Q4'],
    ],
    'scriptAfterArrayToDataTable' => "data.setColumnProperty(2, 'role', 'tooltip');",
    'options' => [
        'title' => 'Expenses vs Sales',
    ]
]);

// Gauge
echo GoogleCharts::widget([
    'visualization' => 'Gauge',
    'containerId' => 'chart-container',
    'packages' => 'gauge',
    'data' => [
        ['Label', 'Value'],
        ['Memory', 80],
        ['CPU', 55],
        ['Network', 68],
    ],
    'options' => [
        'width' => 400,
        'height' => 120,
        'redFrom' => 90,
        'redTo' => 100,
        'yellowFrom' => 75,
        'yellowTo' => 90,
        'greenFrom' => 50,
        'greenTo' => 75,
        'minorTicks' => 5
    ]
]);

?>

The Versions

11/07 2016

dev-master

9999999-dev

A wrapper for Google charts in Yii2

  Sources   Download

GNU

The Requires

 

yii2 google charts

10/07 2016

1.0.1

1.0.1.0

A wrapper for Google charts in Yii2

  Sources   Download

GNU

The Requires

 

yii2 google charts