/**
  * Build the component group
  */
 function awComponentGroup()
 {
     parent::awComponent();
     $this->components = array();
 }
 function init($drawer)
 {
     list($x1, $y1, $x2, $y2) = $this->getPosition();
     $this->xAxis->line->setX($x1, $x2);
     $this->xAxis->label->setAlign(NULL, LABEL_BOTTOM);
     $this->xAxis->label->move(0, 3);
     $this->xAxis->setRange($this->extremum->left, $this->extremum->right);
     $this->yAxis->line->setY($y2, $y1);
     $this->yAxis->label->setAlign(LABEL_RIGHT);
     $this->yAxis->label->move(-6, 0);
     $this->yAxis->reverseTickStyle();
     $this->yAxis->setRange($this->extremum->bottom, $this->extremum->top);
     $this->xAxis->setYCenter($this->yAxis, 0);
     $this->yAxis->setXCenter($this->xAxis, 0);
     if ($this->yAxis->getLabelNumber() === NULL) {
         $number = $this->extremum->top - $this->extremum->bottom + 1;
         $this->yAxis->setLabelNumber($number);
     }
     if ($this->xAxis->getLabelNumber() === NULL) {
         $number = $this->extremum->right - $this->extremum->left + 1;
         $this->xAxis->setLabelNumber($number);
     }
     // Set ticks
     $this->xAxis->ticks['major']->setNumber($this->xAxis->getLabelNumber());
     $this->yAxis->ticks['major']->setNumber($this->yAxis->getLabelNumber());
     // Set axis labels
     $labels = array();
     for ($i = 0, $count = $this->xAxis->getLabelNumber(); $i < $count; $i++) {
         $labels[] = $i;
     }
     $this->xAxis->label->set($labels);
     $labels = array();
     for ($i = 0, $count = $this->yAxis->getLabelNumber(); $i < $count; $i++) {
         $labels[] = $i;
     }
     $this->yAxis->label->set($labels);
     parent::init($drawer);
     // Create the grid
     $this->createGrid();
     // Draw the grid
     $this->grid->draw($drawer, $x1, $y1, $x2, $y2);
 }
 /**
  * Build the component group
  */
 public function __construct()
 {
     parent::__construct();
     $this->components = array();
 }
 /**
  * Build the plot
  *
  * @param array $values Pie values
  */
 public function __construct($values, $colors = awPie::COLORED)
 {
     $this->setValues($values);
     if (is_array($colors)) {
         $this->colors = $colors;
     } else {
         switch ($colors) {
             case awPie::AQUA:
                 $this->colors = array(new awColor(131, 220, 215), new awColor(131, 190, 215), new awColor(131, 160, 215), new awColor(160, 140, 215), new awColor(190, 131, 215), new awColor(220, 131, 215));
                 break;
             case awPie::EARTH:
                 $this->colors = array(new awColor(97, 179, 110), new awColor(130, 179, 97), new awColor(168, 179, 97), new awColor(179, 147, 97), new awColor(179, 108, 97), new awColor(99, 107, 189), new awColor(99, 165, 189));
                 break;
             case awPie::DARK:
                 $this->colors = array(new awColor(140, 100, 170), new awColor(130, 170, 100), new awColor(160, 160, 120), new awColor(150, 110, 140), new awColor(130, 150, 160), new awColor(90, 170, 140));
                 break;
             default:
                 $this->colors = array(new awColor(187, 213, 151), new awColor(223, 177, 151), new awColor(111, 186, 132), new awColor(197, 160, 230), new awColor(165, 169, 63), new awColor(218, 177, 89), new awColor(116, 205, 121), new awColor(200, 201, 78), new awColor(127, 205, 177), new awColor(205, 160, 160), new awColor(190, 190, 190));
                 break;
         }
     }
     parent::__construct();
     $this->label = new awLabel();
     $this->label->setCallbackFunction('callbackPerCent');
 }
Example #5
0
 public function init(awDriver $driver)
 {
     list($x1, $y1, $x2, $y2) = $this->getPosition();
     // Get space informations
     list($leftSpace, $rightSpace, $topSpace, $bottomSpace) = $this->getSpace($x2 - $x1, $y2 - $y1);
     $this->xAxis->setPadding($leftSpace, $rightSpace);
     if ($this->space->bottom > 0 or $this->space->top > 0) {
         list($min, $max) = $this->yAxis->getRange();
         $interval = $max - $min;
         $this->yAxis->setRange($min - $interval * $this->space->bottom / 100, $max + $interval * $this->space->top / 100);
     }
     // Auto-scaling mode
     $this->yAxis->autoScale();
     // Number of labels is not specified
     if ($this->yAxis->getLabelNumber() === NULL) {
         $number = round(($y2 - $y1) / 75) + 2;
         $this->yAxis->setLabelNumber($number);
     }
     $this->xAxis->line->setX($x1, $x2);
     $this->yAxis->line->setY($y2, $y1);
     // Set ticks
     $this->xAxis->tick('major')->setNumber($this->getXAxisNumber());
     $this->yAxis->tick('major')->setNumber($this->yAxis->getLabelNumber());
     // Center X axis on zero
     if ($this->xAxisZero) {
         $this->xAxis->setYCenter($this->yAxis, 0);
     }
     // Center Y axis on zero
     if ($this->yAxisZero) {
         $this->yAxis->setXCenter($this->xAxis, 0);
     }
     // Set axis labels
     $labels = array();
     list($xMin, $xMax) = $this->xAxis->getRange();
     for ($i = $xMin; $i <= $xMax; $i++) {
         $labels[] = $i;
     }
     $this->xAxis->label->set($labels);
     parent::init($driver);
     list($x1, $y1, $x2, $y2) = $this->getPosition();
     list($leftSpace, $rightSpace) = $this->getSpace($x2 - $x1, $y2 - $y1);
     // Create the grid
     $this->createGrid();
     // Draw the grid
     $this->grid->setSpace($leftSpace, $rightSpace, 0, 0);
     $this->grid->draw($driver, $x1, $y1, $x2, $y2);
 }
Example #6
0
	/**
	 * Draw a component on the image
	 *
	 * @var awComponent $component A component
	 */
	public function drawComponent(awComponent $component) {
		
		$shadow = $this->shadow->getSpace(); // Image shadow
		$border = $this->border->visible() ? 1 : 0; // Image border size
	
		$drawer = clone $this->drawer;
		$drawer->setImageSize(
			$this->width - $shadow->left - $shadow->right - $border * 2,
			$this->height - $shadow->top - $shadow->bottom - $border * 2
		);
	
		// No absolute size specified
		if($component->w === NULL and $component->h === NULL) {
		
			list($width, $height) = $drawer->setSize($component->width, $component->height);
	
			// Set component size in pixels
			$component->setAbsSize($width, $height);
			
		} else {
		
			$drawer->setAbsSize($component->w, $component->h);
		
		}
		
		if($component->top !== NULL and $component->left !== NULL) {
			$drawer->setAbsPosition(
				$border + $shadow->left + $component->left,
				$border + $shadow->top + $component->top
			);
		} else {
			$drawer->setPosition($component->x, $component->y);
		}
		
		$drawer->movePosition($border + $shadow->left, $border + $shadow->top);
		
		list($x1, $y1, $x2, $y2) = $component->getPosition();
		
		$component->init($drawer);
		
		$component->drawComponent($drawer, $x1, $y1, $x2, $y2, $this->antiAliasing);
		$component->drawEnvelope($drawer, $x1, $y1, $x2, $y2);
		
		$component->finalize($drawer);
	
	}