PHP Classes

cwGraph: Generate Bar, Pie, Line graph images

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: 223 All time: 8,240 This week: 53Up
Version License PHP version Categories
cwgraph 1.0.0BSD License5PHP 5, Graphics
Description 

Author

This package can generate Bar, Pie, Line graph images.

It can generate chart graphs from arrays with the date for the charts.

It generates an image as a local file so it can be used for serving the chart as image directly.

The chart image width and height, the labels text and rotation angle, the pie radius and angle, etc., are configurable parameters.

Picture of Fernando André
Name: Fernando André is available for providing paid consulting. Contact Fernando André .
Classes: 5 packages by
Country: Portugal Portugal
Age: 41
All time rank: 124316 in Portugal Portugal
Week rank: 187 Up5 in Portugal Portugal Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php
/**
 * Basic example for pChart usage with cwGraph
 *
 *
 */

$Data = array();
if (
count($Data) > 0 ){
   
$cwgraph = new cwGraph();
   
$cwgraph->setHeight(180)->setWidth(400);
   
$cwgraph->setData($Data)->setTitle("Comandos emitidos por dia entre $datainicio e $datafim");
   
$cwgraph->setX("Data criado", "datacriado")->setAnguloTextoX(40);
   
$cwgraph->addVariavel("Data criado", "datacriado");
   
$cwgraph->addVariavel("Total", "total");

   
$cwgraph->drawByEngine();
    print
'<img src="../../../data/'.$cwgraph->getFilename().'" /><br>';
}


if (
count($DataG) > 0 ){
   
$cwgraph = new cwGraph("bar");
   
$cwgraph->setHeight(180)->setWidth(400);
   
$cwgraph->setData($DataG);//->setTitle("Total de comandos por estado");
   
$cwgraph->setX("Data criado", "datacriado")->setAnguloTextoX(40);
   
$cwgraph->addVariavel("Data criado", "datacriado");
   
$cwgraph->addVariavel("Total", "total");
   
$cwgraph->drawByEngine();
    print
'<img src="'.$cwgraph->getFilename().'" /><br>';
}

$Data = array();
$total = 0;

if (
count($DataA) > 0 ){
   
$cwgraph = new cwGraph("pie");
   
$cwgraph->setData($DataA)->setHeight(150)->setWidth(200);
   
$cwgraph->setX("Estados", "estado");
   
$cwgraph->setPieAngle()->setPieGapRadius();
   
$cwgraph->setDisplayValues(true);

   
$cwgraph->addVariavel("total", "total");
   
$cwgraph->addVariavel("Estados", "estado");

   
$cwgraph->drawByEngine();
    print
'<img src="'.$cwgraph->getFilename().'" /><br>';
}


Details

cwGraph class to use the methods of pChart to create fast charts with basic knowledge of pChart library. pChart library is required for usage. This provides a layer of abstraction for other libraries but only pChart was implemented. In the example directory can be found a basic example that I got from old code using this class. Example in: src/php/example/example.php Source in: src/php/cwGraph.php 2 class's exists: cwGraph cwFont

  Files folder image Files (4)  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file LICENSE.txt Doc. Documentation
Accessible without login Plain text file README Doc. Documentation

  Files folder image Files (4)  /  src  
File Role Description
Files folder imagephp (1 directory)

  Files folder image Files (4)  /  src  /  php  
File Role Description
Files folder imageNetcrash (1 directory)

  Files folder image Files (4)  /  src  /  php  /  Netcrash  
File Role Description
Files folder imagecwGraph (1 file, 1 directory)

  Files folder image Files (4)  /  src  /  php  /  Netcrash  /  cwGraph  
File Role Description
Files folder imageexample (1 file)
  Plain text file cwGraph.php Class Class source

  Files folder image Files (4)  /  src  /  php  /  Netcrash  /  cwGraph  /  example  
File Role Description
  Accessible without login Plain text file example.php Example Example script

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:223
This week:0
All time:8,240
This week:53Up