Source for file Pie.class.php
Documentation is available at Pie.class.php 
 * This work is hereby released into the Public Domain.  
 * To view a copy of the public domain dedication,  
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to  
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.  
require_once dirname(__FILE__ ). "/Component.class.php";  
 * @package linea21.externals  
   * A colored theme for pies  
   * Intensity of the 3D effect  
   * @param array $values Pie values  
  function awPie($values, $colors =  PIE_COLORED) {  
    $this->label->setCallbackFunction('callbackPerCent');  
   * @param array $legend An array of values for each part of the pie  
   * Set a border all around the pie  
   * @param $color A color for the border  
   * Set a border all around the pie  
   * @param $color A color for the border  
      awImage::drawError('Class Pie: Method setBorder() has been deprecated since Artichow 1.0.9. Please use setBorderColor() instead.');  
   * Change 3D effect intensity  
   * @param int $size Effect size  
    $this->size = (int) $size;  
   * @param int $angle New angle in degrees  
    $this->angle = (int) $angle;  
   * @param int $precision New precision  
   * @param int $position New position in pixels  
   * @param int $number New number  
   * @param int $minimum New minimum  
    $position =  $this->angle;  
      $side =  new awSide(0, 0, 0, 0);  
    foreach($this->values as $key =>  $value) {  
      $angle =  ($value /  $sum *  360);  
      if($key ===  $count -  1) {  
        $middle =  360 -  ($position +  $angle /  2);  
        $posX =  $this->explode[$key] *  cos($middle *  M_PI /  180);  
        $posY =  $this->explode[$key] *  sin($middle *  M_PI /  180) * - 1;  
          max($side->left, $posX * - 2),  
          max($side->right, $posX *  2),  
          max($side->top, $posY * - 2),  
          max($side->bottom, $posY *  2)  
      $position, ($position +  $angle), $explode  
      // Add part to the legend  
      // Adds support for antialiased pies on non-white background  
      $background =  $this->getBackground();  
      if(is_a($background, 'awColor')) {  
        $image->setBackgroundColor($background);  
      //            elseif(is_a($background, 'awGradient')) {  
      //                $image->setBackgroundColor(new White(100));  
      $width +  $side->left +  $side->right,  
      $height +  $side->top +  $side->bottom +  $this->size +  1 /* bugs.php.net ! */  
      $driver =  $image->getDriver(  
      $height /  $image->height,  
      ($width /  2 +  $side->left) /  $image->width,  
      ($height /  2 +  $side->top) /  $image->height  
    for($i =  $this->size; $i >  0; $i-- ) {  
      foreach($values as $key =>  $value) {  
        list ($from, $to, $explode) =  $value; 
        $driver->filledArc($color, $explode->move($x, $y +  $i), $width, $height, $from, $to);  
          $point =  $explode->move($x, $y);  
            $driver->arc($this->border, $point->move(0, $this->size), $width, $height, $from, $to);  
    foreach($values as $key =>  $value) {  
      list ($from, $to, $explode) =  $value; 
      $driver->filledArc($color, $explode->move($x, $y), $width, $height, $from, $to);  
        $point =  $explode->move($x, $y);  
        $driver->arc($this->border, $point, $width, $height, $from, $to);  
      foreach($values as $key =>  $value) {  
      $mainDriver->copyResizeImage(  
      new awPoint($x1 -  $side->left /  2, $y1 -  $side->top /  2),  
      new awPoint($x1 -  $side->left /  2 +  $image->width /  2, $y1 -  $side->top /  2 +  $image->height/  2),  
      new awPoint($image->width, $image->height),  
    foreach($this->values as $key =>  $value) {  
    if($this->label->count() ===  0) { // Check that there is no user defined values  
    foreach($pc as $key =>  $value) {  
      // Limit number of labels to display  
      if($position ===  $this->number) {  
      list ($from, $to, $explode) =  $values[$key]; 
      $angle =  $from +  ($to -  $from) /  2;  
      $angleRad =  (360 -  $angle) *  M_PI /  180;  
      $x +  $explode->x +  cos($angleRad) *  ($width /  2 +  $this->position),  
      $y +  $explode->y -  sin($angleRad) *  ($height /  2 +  $this->position)  
      // We don't display labels on the 3D effect  
      if($angle >  0 and $angle <  180) {  
        $point =  $point->move(0, - 1 *  sin($angleRad) *  $this->size);  
      if($angle >=  45 and $angle <  135) {  
      } else if($angle >=  135 and $angle <  225) {  
      } else if($angle >=  225 and $angle <  315) {  
   * Return margins around the component  
   * @return array Left, right, top and bottom margins  
    $leftAxis =  $this->padding->left;  
    $rightAxis =  $this->padding->right;  
    $topAxis =  $this->padding->top;  
    $bottomAxis =  $this->padding->bottom;  
    return array($leftAxis, $rightAxis, $topAxis, $bottomAxis);  
   * Change values of Y axis  
   * This method ignores not numeric values  
    $this->checkArray($values);  
   * Return values of Y axis  
  function checkArray(&$array) {  
      awImage::drawError("Class Pie: You tried to set values that are not an array.");  
    foreach($array as $key =>  $value) {  
 * @package linea21.externals  
   * @param $color Pie part color  
  function awPiePart($color) {  
   * Get the background color or gradient of an element of the component  
   * @return Color, Gradient  
 
 
        
       |