Source for file xml2pdf.graph.circle.php

Documentation is available at xml2pdf.graph.circle.php

  1. <?php
  2. /**
  3.  * Xml2Pdf circle graph plugin file
  4.  * @filesource
  5.  *
  6.  * @author guillaume l. <guillaume@geelweb.org>
  7.  * @link http://www.geelweb.org geelweb-dot-org
  8.  * @license http://opensource.org/licenses/bsd-license.php BSD License
  9.  * @copyright copytight © 2006, guillaume luchet
  10.  * @version 0.6.10.8
  11.  * @package Xml2Pdf
  12.  * @subpackage Graph
  13.  */
  14.  
  15. /**
  16.  * plugin class xml2pdf_graph_circle
  17.  * 
  18.  * Draw a circular graph.
  19.  *
  20.  * <code>
  21.  * <graph type='circle' width='100' height='80' mode='3D' legend='%l (%p)' fontsize='10'>
  22.  *   <value legend='Lille' data='1510' color='#f0f5ff'/>
  23.  *   <value legend='Paris' data='1610' color='#feefc1'/>
  24.  *   <value legend='Toulouse' data='1400' color='#ffaaaa'/>
  25.  *   <value legend='Lyon' data='700'/>
  26.  *   <value legend='Bordeaux' data='1001'/>
  27.  * </graph>
  28.  *
  29.  * </code>
  30.  *
  31.  * @author guillaume l. <guillaume@geelweb.org>
  32.  * @link http://www.geelweb.org geelweb-dot-org
  33.  * @license http://opensource.org/licenses/bsd-license.php BSD License
  34.  * @copyright copytight © 2006, guillaume luchet
  35.  * @version 0.6.10.7
  36.  * @package Xml2Pdf
  37.  * @subpackage Graph
  38.  * @tutorial Xml2Pdf/Xml2Pdf.Graph.circle.pkg
  39.  */
  40. class xml2pdf_graph_circle // {{{
  41.  
  42.     // xml2pdf_graph_circle::__construct() {{{
  43.         /**
  44.      * Constructor.
  45.      *
  46.      * Draw a circular graph
  47.      *
  48.      * @param Object $graph Object Xml2Pdf_Tag_graph
  49.      * @return void 
  50.      */
  51.     public function __construct($graph{
  52.         $graph->pdf->SetFont('Courier'''$graph->fontSize);
  53.         $graph->setLegends();
  54.  
  55.         $XPage $graph->pdf->GetX();
  56.         $YPage $graph->pdf->GetY();
  57.         $marge 2;
  58.         $hLegende 5;
  59.         $rayon min($graph->width $marge $hLegende $graph->legendWidth
  60.                      $graph->height $marge 2);
  61.         $rayon floor($rayon 2);
  62.         $XDiag $XPage $marge $rayon;
  63.         $YDiag $YPage $marge $rayon;
  64.         //Secteurs
  65.         $graph->pdf->SetLineWidth(0.2);
  66.  
  67.         $loop $graph->mode=='3d'?4:1;
  68.         
  69.         for($delta=$delta<$loop $delta++{
  70.             $angleDebut 0;
  71.             $angleFin 0;
  72.             $i 0;
  73.             reset($graph->data);
  74.             foreach($graph->data as $val{
  75.                 $angle floor(($val 360doubleval($graph->sum));
  76.                 if ($angle != 0{
  77.                     $angleFin $angleDebut $angle;
  78.                     if($graph->colors[$i!= null{
  79.                         $tab Xml2Pdf::ConvertColor($graph->colors[$i]);
  80.                         $graph->pdf->SetFillColor($tab['r'],$tab['g'],$tab['b']);
  81.                     else {
  82.                         $tab Xml2Pdf::getColor();
  83.                         $graph->pdf->SetFillColor($tab['r'],$tab['g'],$tab['b']);
  84.                         $graph->colors[$i$tab;
  85.  
  86.                     }
  87.                     if($delta>&& $delta<$loop-1{
  88.                         $graph->pdf->SetDrawColor($tab['r'],$tab['g'],$tab['b']);
  89.                     else {
  90.                         $graph->pdf->SetDrawColor(0,0,0);
  91.                     }
  92.                     $graph->sector($XDiag$YDiag-$delta$rayon
  93.                                    $angleDebut$angleFin,$graph->colors[$i]);
  94.                     $angleDebut += $angle;
  95.                 }
  96.                 $i++;
  97.             }
  98.             if ($angleFin != 360{
  99.                 $graph->sector($XDiag$YDiag-$delta$rayon
  100.                                $angleDebut $angle360
  101.                                $graph->colors[$i-1]);
  102.             }
  103.         }
  104.         //Légendes
  105.         $graph->pdf->SetFont('Courier'''$graph->fontSize);
  106.         $x1 $XPage $rayon $marge;
  107.         $x2 $x1 $hLegende $marge;
  108.         $y1 $YDiag $rayon ($rayon $graph->nbVal*($hLegende $marge)) 2;
  109.         for($i=0$i<$graph->nbVal$i++{
  110.             $tab Xml2Pdf::ConvertColor($graph->colors[$i]);
  111.             $graph->pdf->SetFillColor($tab['r'],$tab['g'],$tab['b']);
  112.             $graph->pdf->Rect($x1$y1$hLegende$hLegende'DF');
  113.             $graph->pdf->SetXY($x2$y1);
  114.             $graph->pdf->Cell(0,$hLegende,$graph->legends[$i]);
  115.             $y1 += $hLegende $marge;
  116.         }
  117.     
  118.     
  119.     // }}}
  120. // }}}
  121. ?>

Documentation generated on Wed, 11 Oct 2006 22:27:14 +0200 by phpDocumentor 1.3.0