PHP Classes

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

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 116 All time: 9,555 This week: 488Up
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: 239934 in Portugal Portugal
Week rank: 195 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 (8)  
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 (8)  /  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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:116
This week:0
All time:9,555
This week:488Up
User Comments (1)
Thats a very good class ;-)
2 years ago (José Filipe Lopes Santos)
80%StarStarStarStarStar