https://github.com/jbroadway/gchart
An Elefant CMS app for easy integration with Google Charts.
https://github.com/jbroadway/gchart
Last synced: about 2 months ago
JSON representation
An Elefant CMS app for easy integration with Google Charts.
- Host: GitHub
- URL: https://github.com/jbroadway/gchart
- Owner: jbroadway
- Created: 2012-10-17T15:22:22.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2018-11-25T21:56:34.000Z (over 6 years ago)
- Last Synced: 2025-01-13T12:27:18.928Z (3 months ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gCharts
An [Elefant CMS](http://www.elefantcms.com/) app for easier integration of
[Google Charts](https://developers.google.com/chart/).### Usage
In the Dynamic Objects menu of the Elefant wysiwyg editor, you'll find
several embeddable chart types there.For developers, you can render a chart from any handler like this:
```php
run ('gchart/pie', array (
'title' => 'How Much Pizza I Ate Last Night',
'width' => 500,
'height' => 300,
'labels' => array (
'string:Topping',
'number:Slices'
),
'data' => array (
array ('Pepperoni', 3),
array ('Mushroom', '2),
array ('Onions', 1),
array ('Feta', 2),
array ('Anchovies', 1)
)
));?>
```And in any view template, you can render the same chart like this:
```php
{! gchart/pie
?title=How Much Pizza I Ate Last Night
&width=500
&height=300
&labels=[labels|none]
&data=[data|none]
!}
```This example assumes `View::render()` was passed a data array with keys
`labels` and `data` containing the same structures as in the PHP example
above.### Types of charts
* `gchart/bar`
* `gchart/column`
* `gchart/pie`
* `gchart/qrcode`> More to come soon.
### Options
The following options are available to all chart types:
#### `data`
A 2D array of the chart data values, for example:
```php
array (
array ('Toronto', 537, 482, 399),
array ('Vancouver', 395, 423, 367),
array ('Winnipeg', 235, 123, 467)
)
```> Note: Data can also be passed as CSV data, in which case the labels
> will be taken from the first row.#### `labels`
An array of labels for the data columns, with optional type hints. If
no type hints are provided, it will assume the first column is a string
and the rest are numbers.```php
array (
'string:City',
'number:2010',
'number:2011',
'number:2012'
)
```> Note: This can also be passed as the first entry in the data array.
#### `width`
The width of the chart graphic.
#### `height`
The height of the chart graphic.
#### `title`
The title of the chart graphic.
#### `bgcolor`
The background colour of the chart, specified as `'f5f5f5'`.
#### `legend`
Whether to show the legend. Use the value `'none'` to hide it.
### QR Codes
To generate a QR code, use the following handler call:
```php
run ('gchart/qrcode', array (
'data' => 'http://www.example.com/',
'width' => 150,
'height' => 150,
'color' => '900',
'bgcolor' => 'cde'
));?>
```The only required option is `data`. The defaults for the others are:
* `width=100`
* `height=100`
* `color=000`
* `bgcolor=null` (transparent)The same QR code can be also generated with the following template include:
```
{! gchart/qrcode
?data=http://www.example.com/
&width=15
&height=150
&color=900
&bgcolor=cde !}
```QR codes are generated by the [jQuery.qrcode](http://larsjung.de/qrcode/) plugin.