PHPackages                             shahariaazam/google-charts - 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. shahariaazam/google-charts

ActiveCakephp-plugin[Utility &amp; Helpers](/categories/utility)

shahariaazam/google-charts
==========================

A CakePHP plugin for creating Google Charts.

2.0(12y ago)026Apache-2.0PHPPHP &gt;=5.3

Since Aug 25Pushed 11y agoCompare

[ Source](https://github.com/shahariaazam/GoogleCharts)[ Packagist](https://packagist.org/packages/shahariaazam/google-charts)[ Docs](http://github.com/scottharwell/GoogleChart)[ RSS](/packages/shahariaazam-google-charts/feed)WikiDiscussions master Synced 1mo ago

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

About
=====

[](#about)

This is an attempt to build a multipurpose CakePHP plugin to interface with the Google Charts Javascript API.

I welcome any assistance for enhancing / fixing issues with this plugin!

Requirements
------------

[](#requirements)

- CakePHP 2.0+
- PHP 5.3+

Currently, this plugin only works with 2D charts (line, bar, pie, etc.)

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

[](#installation)

Clone this repository or download a copy to the CakePHP or your application's `Plugins` directory. Be sure to name the folder `GoogleCharts`.

Be sure that you load plugins in your application's bootstrap file:

```
CakePlugin::loadAll();

```

Usage
-----

[](#usage)

There are two phases to using this plugin:

1. Building the data.
2. Building the Javascript for display.

\##Controller Setup &amp; Actions##

Include the `GoogleCharts` class in your controller: `App::uses('GoogleCharts', 'GoogleCharts.Lib');`. This class will help build the data for your charts.

Also, include the GoogleChartsHelper class in your controller so we can use it in the view: `public $helpers = array('GoogleCharts.GoogleCharts');`

The GoogleCharts class is meant to mimic the properties needed per the Google Chart API. Each chart that you want to display on your page needs it's own instance of this class. Once you have prepared the class with settings and data, then set for your view to pass to the View Helper.

```
//Get data from model
//Get the last 10 rounds for score graph
$rounds = $this->Round->find(
	'all',
	array(
		'conditions' => array(
			'Round.user_id' => $this->Auth->user('id')
		),
		'order' => array('Round.event_date' => 'ASC'),
		'limit' => 10,
		'fields' => array(
			'Round.score',
			'Round.event_date'
		)
	)
);

//Setup data for chart
$chart = new GoogleCharts();

$chart->type("LineChart");
	//Options array holds all options for Chart API
	$chart->options(array('title' => "Recent Scores"));
	$chart->columns(array(
		//Each column key should correspond to a field in your data array
		'event_date' => array(
			//Tells the chart what type of data this is
			'type' => 'string',
			//The chart label for this column
			'label' => 'Date'
		),
		'score' => array(
			'type' => 'number',
			'label' => 'Score',
			//Optional NumberFormat pattern
			'format' => '#,###'
		)
	));

//Loop through our data and creates data rows
//Data will be added to rows based on the column keys above (event_date, score).
//If there are missing fields in your data or the keys do not match, then this will not work.
foreach($model as $round){
	$chart->addRow($round['Round']);
}

//You can also use this way to loop through data and creates data rows:
foreach($rounds as $row){
	//$chart->addRow(array('event_date' => $row['Model']['field1'], 'score' => $row['Model']['field2']));
	$chart->addRow(array('event_date' => $row['Round']['event_date'], 'score' => $row['Round']['score']));
}

//You can also manually add rows:
$chart->addRow(array('event_date' => '1/1/2012', 'score' => 55));

//Set the chart for your view
$this->set(compact('chart'));

```

\##View##

1. Create a div for the chart.
    - You can use the default `chart_div` as the id or set your own.
    - If you set your own div ID (or need to for more than one chart) then update your chart object: ``
2. Use the `GoogleChartsHelper` to display your chart(s).
    - ``

License
=======

[](#license)

Copyright 2012 Scott Harwell

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.7% 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

Unknown

Total

1

Last Release

4644d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b54bd4f801cd13d8413a2a3484c2eb64180741b147419c2490555059fc7c48e?d=identicon)[shahariaazam](/maintainers/shahariaazam)

---

Top Contributors

[![scottharwell](https://avatars.githubusercontent.com/u/805434?v=4)](https://github.com/scottharwell "scottharwell (22 commits)")[![PhantomWatson](https://avatars.githubusercontent.com/u/1965565?v=4)](https://github.com/PhantomWatson "PhantomWatson (5 commits)")[![shahariaazam](https://avatars.githubusercontent.com/u/1095008?v=4)](https://github.com/shahariaazam "shahariaazam (5 commits)")[![mhafellner](https://avatars.githubusercontent.com/u/4519792?v=4)](https://github.com/mhafellner "mhafellner (1 commits)")[![sakilimran](https://avatars.githubusercontent.com/u/3876178?v=4)](https://github.com/sakilimran "sakilimran (1 commits)")

---

Tags

plugingooglecakephpcharts

### Embed Badge

![Health badge](/badges/shahariaazam-google-charts/health.svg)

```
[![Health](https://phpackages.com/badges/shahariaazam-google-charts/health.svg)](https://phpackages.com/packages/shahariaazam-google-charts)
```

###  Alternatives

[rochamarcelo/cake-pimple-di

A cakephp plugin for dependency injection based on Pimple library

12176.8k](/packages/rochamarcelo-cake-pimple-di)

PHPackages © 2026

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