2017 © Pedro Peláez
 

library google-chart-generator

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 <google-chart> element

image

martinsik/google-chart-generator

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 <google-chart> element

  • Monday, November 16, 2015
  • by martinsik
  • Repository
  • 1 Watchers
  • 25 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Google Chart Generator

Build Status, (*1)

PHP 5.4+ wrapper around Google Chart API based on Polymer 1.0 component <google-chart>., (*2)

Installation

Add composer.json dependency:, (*3)

"require": {
    "martinsik/google-chart-generator": "^2.0.0"
}

Add bower.json dependency (Polymer 1.0):, (*4)

"dependencies": {
    "google-chart": "GoogleWebComponents/google-chart#^1.0.0"
}

Eventually, install google-chart Polymer component as you want., (*5)

Charts

Right now, four chart types are supported: line, bar, column and pie charts., (*6)

The PHP wrapper is very liberal, it lets you set any Google Chart options via data or chart options. It doesn't have special methods for every possible option because there are are so many of them and it doesn't make sense to make wrappers for every single one of them., (*7)

To use any chart you have to import Polymer 1.0 element and WebComponents polyfill first:, (*8)





<link rel="import" href="/bower_components/google-chart/google-chart.html">

Line chart

Creating a line chart:, (*9)

$chart = new LineChart(['title' => 'Test Chart #1']);
$chart->addData(new SequenceData([12, 24, 20, 18, 16, 45, 23, 15, 65, 32], ['label' => 'Line #1']));
$chart->addData(new SequenceData([31, 27, 31, 28, 30, 40, 52, 48, 78, 45], ['label' => 'Line #2']));

Get element HTML with $chart->getElement()., (*10)

<google-chart style=""
    type='line'
    options='{"title":"Test Chart #1"}'
    cols='[{"type":"string"},{"type":"number","label":"Line #1"},{"type":"number","label":"Line #2"}]'
    rows='[["0",12,31],["1",24,27],["2",20,31],["3",18,28],["4",16,30],["5",45,40],["6",23,52],["7",15,48],["8",65,78],["9",32,45]]'>
</google-chart>

See all possible options for line charts., (*11)

The above code would result into this chart., (*12)

Example Line Chart, (*13)

Pie chart

Creating pie chart:, (*14)

$chart = new PieChart(['width' => '150px', 'height' => '150px', 'pieHole' => 0.5]);
$chart->addData([new SingleData(40, 'Arc #1'), new SingleData(60, 'Arc #2'), new SingleData(80, 'Arc #3')]);

Get element HTML with $chart->getElement()., (*15)

<google-chart style="width:150px;height:150px;"
    type='pie'
    options='{"pieHole":0.5}'
    cols='[{"type":"string","label":"Title"},{"type":"number","label":"Value"}]'
    rows='[["Arc #1",40],["Arc #2",60],["Arc #3",80]]'>
</google-chart>

See all possible options for pie charts., (*16)

Bar chart

Creating bar chart:, (*17)

$chart = new BarChart();
$chart->addData(new SequenceData([20, 40, 30]));

Get element HTML with $chart->getElement()., (*18)

<google-chart style=""
    type='bar'
    options='[]'
    cols='[{"type":"string"},{"type":"number"}]'
    rows='[["0",20],["1",40],["2",30]]'>
</google-chart>

See all possible options for bar charts., (*19)

Column chart

Creating column chart:, (*20)

$chart = new ColumnChart(['width' => '700px', 'isStacked' => true, 'legend' => ['position' => 'none']]);
$chart->addData(new SequenceData(["a1" => 20, "a2" => 40, "a3" => 30], ['label' => 'aaa']));
$chart->addData(new SequenceData(["a1" => 15, "a2" => 32, "a3" => 34], ['label' => 'bbb']));
$chart->addData(new SequenceData(["a1" => 21, "a2" => 42, "a3" => 17], ['label' => 'ccc']));

Get element HTML with $chart->getElement()., (*21)

<google-chart style="width:700px;"
    type='bar'
    options='{"isStacked":true,"legend":{"position":"none"}}'
    cols='[{"type":"string"},{"type":"number","label":"aaa"},{"type":"number","label":"bbb"},{"type":"number","label":"ccc"}]'
    rows='[["a1",20,15,21],["a2",40,32,42],["a3",30,34,17]]'>
</google-chart>

See all possible options for column charts., (*22)

Tests

All tests in this project are based on behat., (*23)

$ bin/behat

Then manually check generated charts in features/generated_html, (*24)

License

Google Chart Generator is licensed under The MIT License., (*25)

The Versions

16/11 2015

dev-master

9999999-dev https://github.com/martinsik/google-chart-generator

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 <google-chart> element

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

16/11 2015

2.0.3

2.0.3.0 https://github.com/martinsik/google-chart-generator

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 <google-chart> element

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

26/07 2015

2.0.2

2.0.2.0 https://github.com/martinsik/google-chart-generator

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 <google-chart> element

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

26/07 2015

2.0.1

2.0.1.0 https://github.com/martinsik/google-chart-generator

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 <google-chart> element

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

26/07 2015

dev-2.0-dev

dev-2.0-dev https://github.com/martinsik/google-chart-generator

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 <google-chart> element

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

26/07 2015

2.0.0

2.0.0.0 https://github.com/martinsik/google-chart-generator

PHP 5.4+ wrapper around Google Chart API using Polymer 1.0 <google-chart> element

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires