PHP Classes

Remote PHP Google Charts Graphics: Show graphics using data got from Web service

Recommend this page to a friend!
  Info   View files Example   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 116 This week: 1All time: 9,536 This week: 560Up
Version License PHP version Categories
graphics 1.0.0The PHP License5HTML, PHP 5, Graphics, Web services
Description 

Author

This class can show graphics using data got from Web services.

It can send an HTTP request to the Web service API server to retrieve data in JSON format.

The class can process the retrieved data and generates HTML with JavaScript to show a chart on a Web page using the Google Charts API.

Innovation Award
PHP Programming Innovation award winner
April 2022
Winner
Google Charts is a popular API used by many developers to generate graphics to display on their Web pages quickly.

Google Charts API takes a set of data with parameters that define values.

This package can pull data from a given Web service API and convert the data to generate a graphic chart.

This way, this package allows combining the two Web services, minimizing the effort of developers that need to display Web charts on their Web site pages.

Manuel Lemos
Picture of António Lira Fernandes
Name: António Lira Fernandes <contact>
Classes: 11 packages by
Country: Portugal Portugal
Age: ???
All time rank: 240434 in Portugal Portugal
Week rank: 52 Up2 in Portugal Portugal Up
Innovation award
Innovation award
Nominee: 3x

Winner: 2x

Example

<?php
//echo "ola";
//require __DIR__ . '/../../config.php';
//require __DIR__ . '/../../autoload.php';
//require __DIR__ . '/../../bootstrap.php';

use classes\graphic\GraphicGoogle;

//Create the class
$gr = new GraphicGoogle();
$grb = new GraphicGoogle();
$gra = new GraphicGoogle();
$grc = new GraphicGoogle();
$grcb = new GraphicGoogle();
$grg = new GraphicGoogle();
$grp = new GraphicGoogle();

//send the options for the graphic - see google graphics for more details
$opt="{
  title: 'As minhas atividades',
  is3D: true,
}"
;
$gr->setOptions($opt);

$opt="{
          chart: {
            title: 'Company Performance',
            subtitle: 'Sales, Expenses, and Profit: 2014-2017',
          },
          bars: 'horizontal' // Required for Material Bar Charts.
        };"
;
$grb->setOptions($opt);

$opt="{
          title: 'Company Performance',
          hAxis: {title: 'Year', titleTextStyle: {color: '#333'}},
          vAxis: {minValue: 0}
        };"
;
$gra->setOptions($opt);
$opt="{
      legend:'none'
    }"
;
$grc->setOptions($opt);

$opt="{
          title : 'Monthly Coffee Production by Country',
          vAxis: {title: 'Cups'},
          hAxis: {title: 'Month'},
          seriesType: 'bars',
          series: {3: {type: 'line'}}
        }"
;
$grcb->setOptions($opt);

$opt="{
          width: 400, height: 120,
          redFrom: 90, redTo: 100,
          yellowFrom:75, yellowTo: 90,
          minorTicks: 5
        }"
;
$grg->setOptions($opt);

$opt="{}";
$grp->setOptions($opt);


//send the data using json web service
$gr->getDataJson("https://esmonserrate.org/public//stats/criadores","name","num");
$grb->getDataJson("https://esmonserrate.org/public//stats/criadores/2ultimos","name","Dois Anos antes,Ultimo Ano,Ano Atual");
$gra->getDataJson("https://esmonserrate.org/public//stats/artigos/meses/seccao","dataMes","num","title");
//$gra->getDataJson("https://esmonserrate.org/public/stats/artigos/meses","dataMes","num");
$grc->getDataJson("https://esmonserrate.org/public//stats/criadores/2ultimos","name","Três Anos antes,Dois Anos antes,Ultimo Ano,Ano Atual");
$grcb->getDataJson("https://esmonserrate.org/public//stats/criadores/2ultimos","name","Três Anos antes,Dois Anos antes,Ultimo Ano,Ano Atual");
$grg->getDataJson("https://esmonserrate.org/public//stats/artigos/local","pp","num");
$grp->getDataJson("https://esmonserrate.org/public//stats/mapa","Country","Popularity");
//$gr->setData($dataForGrp);

//HTML with 2 call for tha classe
?>
<html>
  <head>
    <?php echo $gr->includes(); ?>
  </head>
  <body>
    <?php echo $grp->geochart('GeoChart'); ?>
    <div id="GeoChart" style="width: 900px; height: 500px;"></div>
    <?php echo $grg->gauge('gauge'); ?>
    <div id="gauge" style="width: 100%; height: 130px"></div>
    <?php echo $grcb->comboChart('ComboChart'); ?>
    <div id="ComboChart" style="width: 900px; height: 500px;"></div>
    <?php echo $grc->candlestickChar('candlestickChar'); ?>
    <div id="candlestickChar" style="width: 900px; height: 500px;"></div>
    <?php echo $gra->corechart('areachart'); ?>
    <div id="areachart" style="width: 900px; height: 500px;"></div>
    <?php echo $gr->piechart('piechart'); ?>
    <div id="piechart" style="width: 900px; height: 500px;"></div>
    <?php echo $grb->barchart('barchart'); ?>
     <div id="barchart" style="width: 900px; height: 500px;"></div>
  </body>
</html>


Details

// ----------------------------------------- // @version 1.0 - readme.txt // -------------------------------------------------------------------------------- // License GNU/LGPL - April 2022 // @author António Lira Fernandes - alf@esmonserrate.org // https://github.com/alfZone // --------------------------------------------------------------------------------

0 - Sommaire 1 - Introduction 2 - What's new 3 - Corrected bugs 4 - Known bugs or limitations 5 - License 6 - Warning 7 - Documentation 8 - Author 9 - Contribute

1 - Introduction

GraphicGoogle is a php class based on javascript google graphics to creat graphics.

The idea is to read a json web service and produce a graphic.

Documentation can be found at https://github.com/alfZone/graphics/wiki

2 - What's new Version 1.0 3 - Corrected bugs 4 - Known bugs or limitations

5 - License Is released under GNU/LGPL license. This library is free, so you can use it at no cost.

I will also appreciate that you send me a mail (alf@esmonserrate.org), just to be aware that someone is using #GraphicGoogle.

For more information about GNU/LGPL license : http://www.gnu.org

6 - Warning This library and the associated files are non commercial, non professional work. It should not have unexpected results. However if any damage is caused by this software the author can not be responsible. The use of this software is at the risk of the user.

7 - Documentation Documentation can be found at https://github.com/alfZone/graphics/wiki

8 - Author This software was written by António Lira Fernandes (alf@esmonserrate.org) on its leasure time.

9 - Contribute If you want to contribute to the development of class, please contact alf@esmonserrate.org.


  Files folder image Files  
File Role Description
Files folder imageimages (5 files)
Plain text file GraphicGoogle.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file testGraphics.php Example Example script

  Files folder image Files  /  images  
File Role Description
  Accessible without login Plain text file aaa Data Auxiliary data
  Accessible without login Image file area.JPG Data Auxiliary data
  Accessible without login Image file graphics.png Data Auxiliary data
  Accessible without login Image file multiBars.JPG Data Auxiliary data
  Accessible without login Image file pie.JPG Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:116
This week:1
All time:9,536
This week:560Up
User Comments (1)
Thats a very good class ;-)
1 year ago (José Filipe Lopes Santos)
80%StarStarStarStarStar