PHP Classes

QGoogleVisualizationAPI 2009: Generate charts with Google Visualization API

Recommend this page to a friend!
  Info   View files View files (28)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 50%Total: 835 This week: 1All time: 4,154 This week: 560Up
Version License PHP version Categories
gvizapi 1.0GNU General Publi...5.0PHP 5, Graphics, Web services
Description 

Author

This package can be used to generate charts with Google Visualization API.

It is an enhanced version of the original QGoogleVisualizationAPI package.

This release allows integration of template based Javascript functions or classes.

It uses the ability of the Google Web API to work with JSON objects to reduce the volume of transferred data.

Picture of Tom Schaefer
  Performance   Level  
Name: Tom Schaefer is available for providing paid consulting. Contact Tom Schaefer .
Classes: 39 packages by
Country: Germany Germany
Age: ???
All time rank: 1088 in Germany Germany
Week rank: 34 Up2 in Germany Germany Up
Innovation award
Innovation award
Nominee: 9x

Winner: 1x

Details

QGoogleVisualizationApi v1.0 ================================ Google Visualization API for PHP 5+ ================================ ver 1.0.1 - complete overhaul and redesign # Intro # Configuration # Data + DataView # Visualization # Formatter ## Intro After publishing several minor releases of the QGoogleVisualizationApi I decided to completely overhaul this API. QGoogleVisualizationApi 2009 supports most advanced features of the Google Web Visualization API. I implemented a port to easily integrate template based javascript functions or classes. Basically I separated the API into following sections: - Configuration - Data Handling - Visualization - Formatting To reduce transfer volumina, the API uses the ability of the Google Web API to work with JSON objects. Config and data objects are jsonified. The - outer - visualization object renders the scriptings finally. Now, it is possible to implement scripts with custom script logic. You only have to create a template with a unique name. Inside the template (/Template/yourtemplate.phtml) you can use php or pure javascript to develop your own applications. ## Configuration The configuration section consists of following parts: - Base Config Class => Google_Config - folder ./Google/Config => contains Chart Type Config Object which all are childs of the Chart Type Default Object Config Objects come along with default settings. The nested php stdClass is parted into 3 sections: - global properties - chart type properties - viewport properties Global properties are commonly used by template scripts, Chart type properties are being used by the defined chart type. The viewport properties can be used to format the chart output container (width, height, class). Configuring a chart object is easy. You only need to know which properties a chart can handle. The Google Reference (@see http://code.google.com/apis/visualization/documentation/dev/index.html) gives you an image of these properties. Each chart object has its own set of properties. For QGoogleVisualizationAPI you need to know that the chart properties are a sub set of the configuration object. The main properties as provider, scope, version etc. are used to address a javascript library. By the way, it is possible to enhance the api to provide custom libraries which use the google api. You need to write a js adapter class which hooks onto the provider and scope property. Somewhat later I will go into detail. The default configuration: // global properties $objChart->type = stdClass; $objChart->provider = "google"; $objChart->scope = "visualization"; $objChart->version = 1; $objChart->language = "de_DE"; $objChart->port = "chart"; // chart type dependent properties $objChart->props = new stdClass(); $objChart->props->title = $title; $objChart->props->height = 600; $objChart->props->width = 800; // viewport properties $objChart->viewport = new stdClass(); $objChart->viewport->height = 680; $objChart->viewport->width = 800; sample usage: $c = new Google_Config("AreaChart", "My Title"); $c->setProperty("width", 300); $c->setProperty("height", 200); echo $c; output: {"type":"AreaChart","provider":"google",scope:"visualization","version":1,"language":"de_DE","port":"chart",props:{title:"My Title",height:200,width:300},"viewport":{height:680,width:800}} Within a template you can access the object like this: sample: <script> var cObj = --output here from above--; var chartType = cObj.type; // referencing the chart type; var viewportWidth = cObj.viewport.width // get the width of the viewport container </script> Now you can easily write your custom script without the need to handle with php api objects and methods. What does this mean? A template is set in the constructor of Google_Visualization object. The api comes a long with some default templates used by the different charts. If you need a deviating javascript application logic or further functionality then implement your own template, where you provide these capabilities. Call it as shown below: $v = new Google_Visualization("MySpecialTemplate"); // template file name => ./Template/MySpecialTemplate.phtml ## Data Handling sample usage: $o = new Google_Data_Base; $o->addColumn("0","Country","string"); $o->addColumn("1","Sales","number"); $o->addColumn("1","Expenses","number"); $o->addNewRow(); $o->addStringCellToRow("US"); $o->addNumberCellToRow(10000, "400.0"); $o->addNumberCellToRow(8000, "400.0"); echo $o; The Google_Data object gives the access to following data objects: - Google_Data_Base - Google_Data_Extend (supports database resources) The API uses the JSON Response Format for data objects. Google_Data_Base objects offer methods to setup a data structure which finally is converted into this format. Best regards Tom Schaefer P.S.: If you like it, then feel free to give me feedback and buy me a beer! ;-)

  Files folder image Files  
File Role Description
Files folder imageTemplate (9 files)
Files folder imageException (4 files)
Plain text file Google.merge.v_1_0.php Class all classes merged into a single file
Accessible without login Plain text file sample_areachart.php Example Sample Area Chart
Accessible without login Plain text file sample_areachart_piechart.php Example Sample for showing how to implement two different charts in a single page
Accessible without login Plain text file sample_bar.php Example Bar Chart Sample
Accessible without login Plain text file sample_dataview.php Example Sample Multiple DataView
Accessible without login Plain text file sample_gauge.php Example Gauge Sample
Accessible without login Plain text file sample_intensitymap.php Example Sample Intensity Map
Accessible without login Plain text file sample_pie.php Example Pie Chart Test
Accessible without login Plain text file sample_post_and_query.php Example Data Source Requests > Using The Query Language
Accessible without login Plain text file sample_scatter.php Example Scatter Chart Test
Accessible without login Plain text file sample_table_arrow.php Example Sample Table Arrow Format
Accessible without login Plain text file sample_table_color_bar.php Example Table Colorized Bar
Accessible without login Plain text file sample_table_number.php Example Sample Table Number Format
Accessible without login Plain text file sample_table_pattern.php Example Table Pattern with DataView
Accessible without login Plain text file README Doc. readme

  Files folder image Files  /  Template  
File Role Description
  Accessible without login Plain text file Base.phtml Aux. Base Layout Template
  Accessible without login Plain text file base2.phtml Aux. sample template
  Accessible without login Plain text file base3.phtml Aux. sample template
  Accessible without login Plain text file Base_Select.phtml Aux. Sample Template Listener
  Accessible without login Plain text file Default.phtml Aux. Default Template
  Accessible without login Plain text file Gauge.phtml Aux. Sample Gauge Template
  Accessible without login Plain text file Table.phtml Aux. Sample Table Template
  Accessible without login Plain text file Table_Format.phtml Aux. Sample Table Format Template
  Accessible without login Plain text file __inc.base.php Aux. sample template content

  Files folder image Files  /  Exception  
File Role Description
  Accessible without login Plain text file Google_Exception.phtml Aux. Exception
  Accessible without login Plain text file Google_Exception_Config.phtml Aux. Exception
  Accessible without login Plain text file Google_Exception_Data.phtml Aux. Data Exception
  Accessible without login Plain text file Google_Exception_Format.phtml Aux. Format Exception

 Version Control Unique User Downloads Download Rankings  
 0%
Total:835
This week:1
All time:4,154
This week:560Up
User Ratings User Comments (2)
 All time
Utility:62%StarStarStarStar
Consistency:68%StarStarStarStar
Documentation:50%StarStarStar
Examples:68%StarStarStarStar
Tests:-
Videos:-
Overall:50%StarStarStar
Rank:2688
 
Way over complicated.
14 years ago (Tom Jones)
10%Star
good stuff
14 years ago (Sarfraz Ahmed)
75%StarStarStarStar