download camembert.inc.php
Language: PHP
LOC: 94
Project Info
epnadmin
Server: Savannah NonGNU
Type: cvs
...epnadmin\epnadmin\epnadmin\
   6cartes.inc.php
   add_message.sh
   add_message_file.sh
   animateur.php
   ...eurs-disponibilites.php
   animateurs-horaires.php
   animateurs.inc.php
   autoeval.js
   barcode.inc.php
   basdepage.inc.php
   camembert.inc.php
   cartes.inc.php
   common.initial.sql
   config.php
   configuration.php
   constantes.inc.php
   courriel.php
   dateheure.inc.php
   debug.inc.php
   domaines.php
   en.lang.inc.php
   entete.inc.php
   epnadmin.css
   epnadminv.css
   exemple.sql
   fonctions.inc.php
   footer.inc.php
   fr.initial.sql
   fr.lang.inc.php
   header.inc.php
   horaires.php
   i25object.inc.php
   image.inc.php
   index.php
   initial.sql
   initiations.inc.php
   initiations.php
   inscription_session.php
   localisations.php
   logiciels.php
   materiels.php
   menu2.js
   mysql.inc.php
   parcours.inc.php
   parcours.php
   positionnement.php
   prets.php
   print.php
   questions.php
   remove_message.sh
   reservations.inc.php
   reservations.php
   session.php
   sessions.inc.php
   siteweb.inc.php
   siteweb.php
   stats.php
   structure.sql
   structures.inc.php
   structures.php
   table_horaire.php
   table_horaire_session.php
   tableaux.inc.php
   tarifs.php
   themes.php
   usagers.inc.php
   usagers.php
   usages.php

<?php
/*
 *
 *
 * Avertissement : Cette librairie de fonctions PHP est distribuee avec l'espoir
 * qu'elle sera utile, mais elle l'est SANS AUCUNE GARANTIE; sans meme la garantie de
 * COMMERCIALISATION ou d'UTILITE POUR UN BUT QUELCONQUE.
 * Elle est librement redistribuable tant que la presente licence, ainsi que les credits des
 * auteurs respectifs de chaque fonctions sont laisses ensembles.
 * En aucun cas, Nexen.net ne pourra etre tenu responsable de quelques consequences que ce soit
 * de l'utilisation ou la mesutilisation de ces fonctions PHP.

*/

/****
 * Titre : Camembert statistique
 * Auteur : Cedric Fronteau
 * Email : charlie@nexen.net
 * Url :
 * Description : Reprsente les valeurs d'un tableau sous forme de camembert.

****/
function draw_camembert($stats,$x,$y,$margin,$filename){
/* Parametres : 
   *     $stats : tableau de valeurs
   *     $x : largeur de l'image  crer
   *     $y : hauteur de l'image  crer
   *     $margin : marge entre le bord, le cercle et la legende
   *     $filename : nom  donner  de l'image
   */
   if (!is_array($stats) || ($x <= 0) || ($y <= 0))
      return FALSE;
   $vals = array_values($stats);
   $keys = array_keys($stats);
   
   $pic = imagecreate($x,$y);
   $min = min($vals);
   $max = max($vals);
   $taille = sizeof($vals);
   
   $white = imagecolorallocate($pic,255,255,255);
   $black = imagecolorallocate($pic,0,0,0);
   
   /* remplit le fond de l'image */
   imagefill($pic,0,0,$white);
   
   $total = somme($vals);
   $diametre = min($y,2/3*$x) - 2*$margin;
   $cx = floor($diametre/2) + $margin;
   $cy = floor($diametre/2) + $margin;
   srand((double)microtime()*1000000);
  
   /* cadre de la legende */
   $legendeW = $x - $diametre - 2*$margin;
   $legendeH = min(20 + (20 + 15)*$taille,$y-$margin);
   $nbmaxcar = floor(($legendeW-35)/8) - 1;
   imagerectangle($pic,
                  $x - $legendeW,$y - $legendeH,
                  $x - $margin,$y - $margin,
                  $black);
   /* dessin du graphe et de la legende */
   $legende_y = $y - $margin - 20;
   $debut = 270;
   for($i=0;$i<$taille;$i++)
      {
      $r = rand(1,254);
      $g = rand(1,254);
      $b = rand(1,254);
      $col = imagecolorallocate($pic,$r,$g,$b);
      
      $fin = round($debut + $vals[$i]/$total*360);
      imagearc($pic,$cx,$cy,$diametre,$diametre,$debut,$fin,$col);

      $tx1 = round(cos(deg2rad($debut))*$diametre/2+$cx);
      $ty1 = round(sin(deg2rad($debut))*$diametre/2+$cy);
      $tx2 = round(cos(deg2rad($fin))*$diametre/2+$cx);
      $ty2 = round(sin(deg2rad($fin))*$diametre/2+$cy);
      
      imageline($pic,$cx,$cy,$tx1,$ty1,$col);
      imageline($pic,$cx,$cy,$tx2,$ty2,$col);

      $mid = floor(($fin - $debut)/2 + $debut);
      $px = round(cos(deg2rad($mid))*($diametre/2-$margin)+$cx);
      $py = round(sin(deg2rad($mid))*($diametre/2-$margin)+$cy);

      imagefilltoborder($pic,$px,$py,$col,$col);
      imagestring($pic,2,$px,$py,$vals[$i],$black);

      $debut = $fin;
      
      if ($legende_y >= ($y - $legendeH))
         {
         $xb = floor($x - $legendeW +10);
         $yb = floor($legende_y);
         $xe = floor($x - $legendeW +25);
         $ye = floor($legende_y + 15);
         imagefilledrectangle($pic,
                     $xb,$yb,
                     $xe,$ye,
                     $col);
      
         if (is_string($keys[$i]))
            {
            if (strlen($keys[$i]) > $nbmaxcar)
               $str = substr($keys[$i],0,$nbmaxcar - 1);
            else
               $str = $keys[$i];
            }
         else
            {
            if ($nbmaxcar > 8)
               $str = "Cl : ".$keys[$i];
            else
               $str = $keys[$i];
            }
         imagestring($pic,2,$x - $legendeW +35,$legende_y,$str,$black);
         }
      $legende_y -= (20+15);
      }
   imagearc($pic,$cx,$cy,$diametre,$diametre,0,360,$black);
   imagearc($pic,$cx,$cy,$diametre+7,$diametre+7,0,360,$black);
   imagefilltoborder($pic,$cx+($diametre+3)/2,$cy,$black,$black);
      
   @imagepng($pic,$filename);
   if (!file_exists($filename))
      return FALSE;
   return TRUE;
}

/****
 * Titre : Somme 
 * Auteur : Damien Seguy 
 * Email : damien.seguy@nexen.net
 * Url : www.nexen.net/
 * Description : Somme tous les arguments.
****/
function somme(){
$args = func_get_args();
        $elements = array_pop($args);
        foreach ($args as $a) {
                $elements = array_merge($elements, $a);
        }
        $b = 0;
        @eval('$b = intval("'.implode('") + intval("', $elements).'");');
        return $b;
}


?>

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us