Attention!
Some files seem to have corrupted file names after downloading. Do not know why this happened. Please check the core files on error regarding following Syntax: Q<charttype>GoogleGraph.class.php
!!!Google Code Blog Recommendation!!!
Google Visualization API now in PHP
Tuesday, August 19, 2008
By Nir Bar-Lev, Product Management
Here at the Google Visualization HQ we focus hard on making the Visualization API the easiest and simplest platform for visualizing and reporting data on the web. We're always excited to see the community uptake and develop our product, making it even more useful and accessible to other developers. One such initiative is the PHP wrapper class that Thomas Schaefer wrote for the Visualization API.
The class wraps the API and enables PHP application developers to quickly integrate visualizations into their code. Thomas even published reference applications that enable you to get started even quicker.
We love your work Thomas, keep it up!
===============================================================
This package can be used to generate structured charts with Google Visualization API.
It provide a base class that can generate the necessary HTML to embed charts rendered by Google Visualization API in Web pages.
It also provides several classes that wrap the configuration of the different types of supported charts like line charts, bar charts and column charts.
Added:
- Area chart
- Gauge chart
- Pie chart
- Intensity Map
- Mashup
- Wordcloud
- Orgchart
- Table
- Scatterchart (for commendation by Jorge Garifuna at Digg)
- Annotated Timeline (for commendation by Jorge Garifuna at Dzone)
- Map
- Motionchart
I released all classes. If you think, something is missing then let me know.
Regards Tom Schaefer
############################
** QVisualisationGoogleGraph Extraction from QLib**
@license BSD
@author Thomas Schäfer
@since 2008-30-06
@version 0.1
== Introduction ==
Google Visualisation API produces javascript code visualising data in different formats.
QVisualisationGoogleGraph provides some wrapper classes to dynamically produces
javascript code using the google jsapi lib.
provided chart types:
* Annotated timeline (Flash)
* Area chart
* Bar chart
* Column chart
* Gauge
* Intensity Map
* Map
* Motion chart (Flash)
* Pie chart
* Scatter chart
* Tables
* Word clouds (user def.)
* Organisation chart
* Mash-Up
Additional classes used by QVisualisationGoogleGraph:
* QInflector (inflecting for namespace)
* QConfig (debug, config properties)
* QTracer (debug trace)
* QTool (context namespace)
== methods ==
=== setColumns ===
This method adds column names to a chart. The method expects an array of arrays.
The first entry of column data array defines the data type.
The second entry holds the value. If you choose an intensity map chart then
a third parameters is required. In this very case the third parameter holds the
country name flag.
You may define columns as many as you want, but you have to structure it as described.
e.g. for intensity map
$chart->addColumns(
array(
array('string', '', 'Country'),
array('number', 'Population (mil)', 'a'),
array('number', 'Area (km2)', 'b'),
)
);
e.g. for other chart types
$chart->addColumns(
array(
array('date', 'Date'),
array('number', 'Sold Pencils'),
array('number', 'Sold Pens'),
array('string', 'title'),
array('string', 'text'),
)
);
=== setValues ===
The setValues method pushes the data into the chart object where
it will be rendered contextually. If a chart type needs the
Google API setCell method it switches automatically.
While setting the values the addRows method will be rendered, too.
e.g. setValue for annotated timeline charts
$chart->setValues(
array(
array(0, 0, 'new Date(2008, 1 ,1)'),
array(0, 1, 30000),
array(0, 2, 40645),
)
);
=== drawProperties ===
The setDrawProperties allows you to change the default chart property values.
You have to visit the Google Visualization Web Api reference for getting an
image of what can be done.
** Contextual Reference Link **
$chart = new QAnnotatedtimelineGoogleGraph();
echo $chart->getReferenceLink();
This command provides a link to the chapter where annotated timelines are explained.
Usually the chart class checks the draw properties against configuration properties.
The configuration property is part of each chart class. Each has an individual repertoire.
This class property holds the supported features with their data types, and optionally value ranges.
=== render ===
The last method you need to know is the render command.
This method collects, merges and returns the script.
== conclusion ==
Making chart types with the Google Visualization API is pretty simple.
You need not to know anything about javascript. PHP does it for you.
If you are mature with both languages you can write your own classes
to enhance the functionality.
|