Source for file stat.graph.php
Documentation is available at stat.graph.php
* @desc Funzioni per la generazione dei grafici
* @author Mario Marcello Verona <marcelloverona@gmail.com>
* @copyright 2007 Mario Marcello Verona
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
* Funzione per la generazione dei grafici a barre
* Utilizza PEAR ed il pacchetto Image/Graph
* I grafici vengono generati nella cartella tmp in formato PNG
* @param string $nome_file
* @param string $colore_sfondo
function barre($data,$labels,$scala= 5,$testo= "",$nome_file= "image",
$x= 490,$y= 280,$colore= 'orange',$left= 160,$format= '%.2f', $colore_sfondo= 'ivory'){
include_once 'Image/Graph.php';
$Graph = & Image_Graph::factory('graph', array($x, $y));
Image_Graph::factory('title', array($testo, 12)),
$Plotarea = Image_Graph::factory('plotarea', array('category', 'axis', 'horizontal')),
$Legend = Image_Graph::factory('legend'),
$Grid = & $Plotarea->addNew('line_grid', array(), IMAGE_GRAPH_AXIS_Y);
$Grid->setLineColor('black@0.1');
$Dataset = & Image_Graph::factory('dataset');
for($i= (count($data)- 1);$i>= 0;$i-- ){
$Dataset->addPoint($labels[$i], $data[$i]);
$Font = & $Graph->addNew('font', 'Verdana');
$Graph->setBackgroundColor($colore_sfondo. '@0.2');
$Fill = & Image_Graph::factory('Image_Graph_Fill_Array');
$Fill->addColor('white');
$Plotarea->setFillStyle($Fill);
$Plot = & $Plotarea->addNew('bar', &$Dataset);
$Fill = & Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, $colore[0], $colore[1]));
$Plot->setFillStyle($Fill);
$Fill = & Image_Graph::factory('Image_Graph_Fill_Array');
$Fill->addColor($colore);
$Plot->setFillStyle($Fill);
$Graph->done( array('filename' => FRONT_REALPATH. "/tmp/$nome_file.png") );
* Funzione per la generazione dei grafici a torta
* Utilizza PEAR ed il pacchetto Image/Graph
* Nella versione di Image/Graph 0.72 c'è un bug nella generazione delle etichette.
* Utilizzare la versione CVS o precedente|successiva del file Image/Graph/Plot/Pie.php
* I grafici vengono generati nella cartella tmp in formato PNG
* @param string $nome_file
function torta($data,$labels,$testo= "",$nome_file= "image",$x= 490,$y= 300){
include_once 'Image/Graph.php';
$Graph = & Image_Graph::factory('graph', array($x, $y));
Image_Graph::factory('title', array($testo, 12)),
$Plotarea = Image_Graph::factory('plotarea'),
$Legend = Image_Graph::factory('legend'),
$Legend->setPlotarea($Plotarea);
$Dataset = & Image_Graph::factory('dataset');
for($i= (count($data)- 1);$i>= 0;$i-- ){
$Dataset->addPoint($labels[$i], $data[$i],$labels[$i]);
$Plot = & $Plotarea->addNew('pie', array(&$Dataset));
$Font = & $Graph->addNew('font', 'Verdana');
$Graph->setBackgroundColor('white');
// create a Y data value marker
$Marker = & $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL);
// create a pin-point marker type
$PointingMarker = & $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(15, &$Marker));
// and use the marker on the 1st plot
$Plot->setMarker($PointingMarker);
// format value marker labels as percentage values
$Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
$FillArray = & Image_Graph::factory('Image_Graph_Fill_Array');
$Plot->setFillStyle($FillArray);
for($i= 0;$i< count($labels);$i++ ){
$Graph->done( array('filename' => FRONT_REALPATH. "/tmp/$nome_file.png") );
* @desc Genera un seed per i numeri pseudocasuali
return (float) $sec + ((float) $usec * 100000);
* @desc Genera un colore pseudocasuale in formato esadecimale
|