/**
  * Render Axis labels
  *
  * Render labels for an axis.
  *
  * @param ezcGraphRenderer $renderer Renderer used to draw the chart
  * @param ezcGraphBoundings $boundings Boundings of the axis
  * @param ezcGraphCoordinate $start Axis starting point
  * @param ezcGraphCoordinate $end Axis ending point
  * @param ezcGraphChartElementAxis $axis Axis instance
  * @return void
  */
 public function renderLabels(ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphChartElementAxis $axis)
 {
     // receive rendering parameters from axis
     $steps = $axis->getSteps();
     $this->steps = $steps;
     $axisBoundings = new ezcGraphBoundings($start->x, $start->y, $end->x, $end->y);
     // Determine normalized axis direction
     $this->direction = new ezcGraphVector($start->x - $end->x, $start->y - $end->y);
     $this->direction->unify();
     if ($this->outerGrid) {
         $gridBoundings = $boundings;
     } else {
         $gridBoundings = new ezcGraphBoundings($boundings->x0 + $renderer->xAxisSpace * abs($this->direction->y), $boundings->y0 + $renderer->yAxisSpace * abs($this->direction->x), $boundings->x1 - $renderer->xAxisSpace * abs($this->direction->y), $boundings->y1 - $renderer->yAxisSpace * abs($this->direction->x));
     }
     // Determine additional required axis space by boxes
     $firstStep = reset($steps);
     $lastStep = end($steps);
     $this->widthModifier = 1 + $firstStep->width / 2 + $lastStep->width / 2;
     // Draw steps and grid
     foreach ($steps as $nr => $step) {
         $position = new ezcGraphCoordinate($start->x + ($end->x - $start->x) * ($step->position + $step->width) / $this->widthModifier, $start->y + ($end->y - $start->y) * ($step->position + $step->width) / $this->widthModifier);
         $stepWidth = $step->width / $this->widthModifier;
         $stepSize = new ezcGraphCoordinate($axisBoundings->width * $stepWidth, $axisBoundings->height * $stepWidth);
         if ($this->showLabels) {
             // Calculate label boundings
             switch (true) {
                 case abs($this->direction->x) > abs($this->direction->y) && $this->direction->x <= 0:
                     $labelBoundings = new ezcGraphBoundings($position->x - $stepSize->x + $this->labelPadding, $position->y + $this->labelPadding, $position->x - $this->labelPadding, $position->y + $renderer->yAxisSpace - $this->labelPadding);
                     $alignement = ezcGraph::CENTER | ezcGraph::TOP;
                     break;
                 case abs($this->direction->x) > abs($this->direction->y) && $this->direction->x > 0:
                     $labelBoundings = new ezcGraphBoundings($position->x + $this->labelPadding, $position->y + $this->labelPadding, $position->x + $stepSize->x - $this->labelPadding, $position->y + $renderer->yAxisSpace - $this->labelPadding);
                     $alignement = ezcGraph::CENTER | ezcGraph::TOP;
                     break;
                 case $this->direction->y <= 0:
                     $labelBoundings = new ezcGraphBoundings($position->x - $renderer->xAxisSpace + $this->labelPadding, $position->y - $stepSize->y + $this->labelPadding, $position->x - $this->labelPadding, $position->y - $this->labelPadding);
                     $alignement = ezcGraph::MIDDLE | ezcGraph::RIGHT;
                     break;
                 case $this->direction->y > 0:
                     $labelBoundings = new ezcGraphBoundings($position->x - $renderer->xAxisSpace + $this->labelPadding, $position->y + $this->labelPadding, $position->x - $this->labelPadding, $position->y + $stepSize->y - $this->labelPadding);
                     $alignement = ezcGraph::MIDDLE | ezcGraph::RIGHT;
                     break;
             }
             $renderer->drawText($labelBoundings, $step->label, $alignement);
         }
         // major grid
         if ($axis->majorGrid) {
             $this->drawGrid($renderer, $gridBoundings, $position, $stepSize, $axis->majorGrid);
         }
         // major step
         $this->drawStep($renderer, $position, $this->direction, $axis->position, $this->majorStepSize, $axis->border);
     }
 }
Example #2
0
 /**
  * __set 
  * 
  * @param mixed $propertyName 
  * @param mixed $propertyValue 
  * @throws ezcBaseValueException
  *          If a submitted parameter was out of range or type.
  * @throws ezcBasePropertyNotFoundException
  *          If a the value for the property options is not an instance of
  * @return void
  * @ignore
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'labelCount':
             if (!is_numeric($propertyValue) || $propertyValue <= 1) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'int > 1');
             }
             $this->properties['labelCount'] = (int) $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
             break;
     }
 }
 /**
  * Render Axis labels
  *
  * Render labels for an axis.
  *
  * @param ezcGraphRenderer $renderer Renderer used to draw the chart
  * @param ezcGraphBoundings $boundings Boundings of the axis
  * @param ezcGraphCoordinate $start Axis starting point
  * @param ezcGraphCoordinate $end Axis ending point
  * @param ezcGraphChartElementAxis $axis Axis instance
  * @return void
  */
 public function renderLabels(ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphChartElementAxis $axis, ezcGraphBoundings $innerBoundings = null)
 {
     // receive rendering parameters from axis
     $this->steps = $steps = $axis->getSteps();
     $axisBoundings = new ezcGraphBoundings($start->x, $start->y, $end->x, $end->y);
     // Determine normalized axis direction
     $this->direction = new ezcGraphVector($end->x - $start->x, $end->y - $start->y);
     $this->direction->unify();
     // Get axis space
     $gridBoundings = null;
     list($xSpace, $ySpace) = $this->getAxisSpace($renderer, $boundings, $axis, $innerBoundings, $gridBoundings);
     // Determine optimal angle if none specified
     $this->determineAngle($steps, $xSpace, $ySpace, $axisBoundings);
     $degTextAngle = $this->determineTextOffset($axis, $steps);
     $labelLength = $this->calculateLabelLength($start, $end, $xSpace, $ySpace, $axisBoundings);
     // Determine additional required axis space by boxes
     $firstStep = reset($steps);
     $lastStep = end($steps);
     $this->widthModifier = 1 + $firstStep->width / 2 + $lastStep->width / 2;
     // Draw steps and grid
     foreach ($steps as $nr => $step) {
         $position = new ezcGraphCoordinate($start->x + ($end->x - $start->x) * ($step->position + $step->width) / $this->widthModifier, $start->y + ($end->y - $start->y) * ($step->position + $step->width) / $this->widthModifier);
         $stepWidth = $step->width / $this->widthModifier;
         $stepSize = new ezcGraphCoordinate($axisBoundings->width * $stepWidth, $axisBoundings->height * $stepWidth);
         // Calculate label boundings
         $labelSize = $this->calculateLabelSize($steps, $nr, $step, $xSpace, $ySpace, $axisBoundings);
         $lengthReducement = min(abs(tan(deg2rad($this->angle)) * ($labelSize / 2)), abs($labelLength / 2));
         $this->renderLabelText($renderer, $axis, $position, $step->label, $degTextAngle, $labelLength, $labelSize, $lengthReducement);
         // Major grid
         if ($axis->majorGrid) {
             $this->drawGrid($renderer, $gridBoundings, $position, $stepSize, $axis->majorGrid);
         }
         // Major step
         $this->drawStep($renderer, $position, $this->direction, $axis->position, $this->majorStepSize, $axis->border);
     }
 }
Example #4
0
 /**
  * Set the element with the given offset. 
  *
  * This method is part of the ArrayAccess interface to allow access to the
  * data of this object as if it was an array. 
  * 
  * @param string $key
  * @param ezcGraphChartElementAxis $value
  * @return void
  *
  * @throws ezcBaseValueException
  *         If supplied value is not an ezcGraphChartElementAxis
  */
 public function offsetSet($key, $value)
 {
     if (!$value instanceof ezcGraphChartElementAxis) {
         throw new ezcBaseValueException($key, $value, 'ezcGraphChartElementAxis');
     }
     if ($key === null) {
         $key = count($this->data);
     }
     // Add axis and configure it with current font and palette
     $this->data[$key] = $value;
     $value->font = $this->chart->options->font;
     $value->setFromPalette($this->chart->palette);
     return $value;
 }
Example #5
0
 /**
  * __set 
  * 
  * @param mixed $propertyName 
  * @param mixed $propertyValue 
  * @throws ezcBaseValueException
  *          If a submitted parameter was out of range or type.
  * @throws ezcBasePropertyNotFoundException
  *          If a the value for the property options is not an instance of
  * @return void
  * @ignore
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'min':
         case 'max':
             if (!is_numeric($propertyValue)) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'float');
             }
             $this->properties[$propertyName] = (double) $propertyValue;
             $this->properties['initialized'] = true;
             break;
         case 'base':
             if (!is_numeric($propertyValue) || $propertyValue <= 0) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0');
             }
             $this->properties[$propertyName] = (double) $propertyValue;
             break;
         case 'logarithmicalFormatString':
             $this->properties['logarithmicalFormatString'] = (string) $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
             break;
     }
 }
 /**
  * Render Axis labels
  *
  * Render labels for an axis.
  *
  * @param ezcGraphRenderer $renderer Renderer used to draw the chart
  * @param ezcGraphBoundings $boundings Boundings of the axis
  * @param ezcGraphCoordinate $start Axis starting point
  * @param ezcGraphCoordinate $end Axis ending point
  * @param ezcGraphChartElementAxis $axis Axis instance
  * @return void
  */
 public function renderLabels(ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphChartElementAxis $axis, ezcGraphBoundings $innerBoundings = null)
 {
     // receive rendering parameters from axis
     $steps = $axis->getSteps();
     $axisBoundings = new ezcGraphBoundings($start->x, $start->y, $end->x, $end->y);
     // Determine normalized axis direction
     $direction = new ezcGraphVector($end->x - $start->x, $end->y - $start->y);
     $direction->unify();
     // Get axis space
     $gridBoundings = null;
     list($xSpace, $ySpace) = $this->getAxisSpace($renderer, $boundings, $axis, $innerBoundings, $gridBoundings);
     // Draw steps and grid
     foreach ($steps as $nr => $step) {
         $position = new ezcGraphCoordinate($start->x + ($end->x - $start->x) * $step->position, $start->y + ($end->y - $start->y) * $step->position);
         $stepSize = new ezcGraphCoordinate($axisBoundings->width * $step->width, $axisBoundings->height * $step->width);
         if (!$step->isZero) {
             // major grid
             if ($axis->majorGrid) {
                 $this->drawGrid($renderer, $gridBoundings, $position, $stepSize, $axis->majorGrid);
             }
             // major step
             $this->drawStep($renderer, $position, $direction, $axis->position, $this->majorStepSize, $axis->border);
         }
         // draw label
         if ($this->showLabels && ($this->showZeroValue || !$step->isZero)) {
             // Calculate label boundings
             if (abs($direction->x) > abs($direction->y)) {
                 // Horizontal labels
                 switch (true) {
                     case $nr === 0:
                         // First label
                         $labelSize = min($xSpace * 2, $step->width * $axisBoundings->width);
                         break;
                     case $step->isLast:
                         // Last label
                         $labelSize = min($xSpace * 2, $steps[$nr - 1]->width * $axisBoundings->width);
                         break;
                     default:
                         $labelSize = min($step->width * $axisBoundings->width, $steps[$nr - 1]->width * $axisBoundings->width);
                         break;
                 }
                 $labelBoundings = new ezcGraphBoundings($position->x - $labelSize / 2 + $this->labelPadding, $position->y + $this->labelPadding, $position->x + $labelSize / 2 - $this->labelPadding, $position->y + $ySpace - $this->labelPadding);
                 $alignement = ezcGraph::CENTER | ezcGraph::TOP;
             } else {
                 // Vertical labels
                 switch (true) {
                     case $nr === 0:
                         // First label
                         $labelSize = min($ySpace * 2, $step->width * $axisBoundings->height);
                         break;
                     case $step->isLast:
                         // Last label
                         $labelSize = min($ySpace * 2, $steps[$nr - 1]->width * $axisBoundings->height);
                         break;
                     default:
                         $labelSize = min($step->width * $axisBoundings->height, $steps[$nr - 1]->width * $axisBoundings->height);
                         break;
                 }
                 $labelBoundings = new ezcGraphBoundings($position->x - $xSpace + $this->labelPadding, $position->y - $labelSize / 2 + $this->labelPadding, $position->x - $this->labelPadding, $position->y + $labelSize / 2 - $this->labelPadding);
                 $alignement = ezcGraph::MIDDLE | ezcGraph::RIGHT;
             }
             $renderer->drawText($labelBoundings, $step->label, $alignement);
         }
         // Iterate over minor steps
         if (!$step->isLast) {
             foreach ($step->childs as $minorStep) {
                 $minorStepPosition = new ezcGraphCoordinate($start->x + ($end->x - $start->x) * $minorStep->position, $start->y + ($end->y - $start->y) * $minorStep->position);
                 $minorStepSize = new ezcGraphCoordinate($axisBoundings->width * $minorStep->width, $axisBoundings->height * $minorStep->width);
                 if ($axis->minorGrid) {
                     $this->drawGrid($renderer, $gridBoundings, $minorStepPosition, $minorStepSize, $axis->minorGrid);
                 }
                 // major step
                 $this->drawStep($renderer, $minorStepPosition, $direction, $axis->position, $this->minorStepSize, $axis->border);
             }
         }
     }
 }
 /**
  * Render Axis labels
  *
  * Render labels for an axis.
  *
  * @param ezcGraphRenderer $renderer Renderer used to draw the chart
  * @param ezcGraphBoundings $boundings Boundings of the axis
  * @param ezcGraphCoordinate $start Axis starting point
  * @param ezcGraphCoordinate $end Axis ending point
  * @param ezcGraphChartElementAxis $axis Axis instance
  * @return void
  */
 public function renderLabels(ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphChartElementAxis $axis, ezcGraphBoundings $innerBoundings = null)
 {
     // receive rendering parameters from axis
     $steps = $axis->getSteps();
     $axisBoundings = new ezcGraphBoundings($start->x, $start->y, $end->x, $end->y);
     // Determine normalized axis direction
     $direction = new ezcGraphVector($end->x - $start->x, $end->y - $start->y);
     $direction->unify();
     // Get axis space
     $gridBoundings = null;
     list($xSpace, $ySpace) = $this->getAxisSpace($renderer, $boundings, $axis, $innerBoundings, $gridBoundings);
     // Draw steps and grid
     foreach ($steps as $nr => $step) {
         $position = new ezcGraphCoordinate($start->x + ($end->x - $start->x) * $step->position, $start->y + ($end->y - $start->y) * $step->position);
         $stepSize = new ezcGraphCoordinate($axisBoundings->width * $step->width, $axisBoundings->height * $step->width);
         if (!$step->isZero) {
             // major grid
             if ($axis->majorGrid) {
                 $this->drawGrid($renderer, $gridBoundings, $position, $stepSize, $axis->majorGrid);
             }
             // major step
             $this->drawStep($renderer, $position, $direction, $axis->position, $this->majorStepSize, $axis->border);
         }
         if ($this->showLabels) {
             switch ($axis->position) {
                 case ezcGraph::RIGHT:
                 case ezcGraph::LEFT:
                     $labelWidth = $axisBoundings->width * $steps[$nr - $step->isLast]->width / ($this->showLastValue + 1);
                     $labelHeight = $ySpace;
                     if ($this->renderLastOutside === true && $step->isLast === true) {
                         $labelWidth = ($boundings->width - $axisBoundings->width) / 2;
                     }
                     break;
                 case ezcGraph::BOTTOM:
                 case ezcGraph::TOP:
                     $labelWidth = $xSpace;
                     $labelHeight = $axisBoundings->height * $steps[$nr - $step->isLast]->width / ($this->showLastValue + 1);
                     if ($this->renderLastOutside === true && $step->isLast === true) {
                         $labelHeight = ($boundings->height - $axisBoundings->height) / 2;
                     }
                     break;
             }
             $showLabel = true;
             switch (true) {
                 case !$this->showLastValue && $step->isLast:
                     // Skip last step if showLastValue is false
                     $showLabel = false;
                     break;
                     // Draw label at top left of step
                 // Draw label at top left of step
                 case $axis->position === ezcGraph::BOTTOM && !$step->isLast || $axis->position === ezcGraph::BOTTOM && $step->isLast && $this->renderLastOutside || $axis->position === ezcGraph::TOP && $step->isLast && !$this->renderLastOutside:
                     $labelBoundings = new ezcGraphBoundings($position->x - $labelWidth + $this->labelPadding, $position->y - $labelHeight + $this->labelPadding, $position->x - $this->labelPadding, $position->y - $this->labelPadding);
                     $alignement = ezcGraph::RIGHT | ezcGraph::BOTTOM;
                     break;
                     // Draw label at bottom right of step
                 // Draw label at bottom right of step
                 case $axis->position === ezcGraph::LEFT && !$step->isLast || $axis->position === ezcGraph::LEFT && $step->isLast && $this->renderLastOutside || $axis->position === ezcGraph::RIGHT && $step->isLast && !$this->renderLastOutside:
                     $labelBoundings = new ezcGraphBoundings($position->x + $this->labelPadding, $position->y + $this->labelPadding, $position->x + $labelWidth - $this->labelPadding, $position->y + $labelHeight - $this->labelPadding);
                     $alignement = ezcGraph::LEFT | ezcGraph::TOP;
                     break;
                     // Draw label at bottom left of step
                 // Draw label at bottom left of step
                 case $axis->position === ezcGraph::TOP && !$step->isLast || $axis->position === ezcGraph::TOP && $step->isLast && $this->renderLastOutside || $axis->position === ezcGraph::RIGHT && !$step->isLast || $axis->position === ezcGraph::RIGHT && $step->isLast && $this->renderLastOutside || $axis->position === ezcGraph::BOTTOM && $step->isLast && !$this->renderLastOutside || $axis->position === ezcGraph::LEFT && $step->isLast && !$this->renderLastOutside:
                     $labelBoundings = new ezcGraphBoundings($position->x - $labelWidth + $this->labelPadding, $position->y + $this->labelPadding, $position->x - $this->labelPadding, $position->y + $labelHeight - $this->labelPadding);
                     $alignement = ezcGraph::RIGHT | ezcGraph::TOP;
                     break;
             }
             if ($showLabel) {
                 $renderer->drawText($labelBoundings, $step->label, $alignement);
             }
         }
         if (!$step->isLast) {
             // Iterate over minor steps
             foreach ($step->childs as $minorStep) {
                 $minorStepPosition = new ezcGraphCoordinate($start->x + ($end->x - $start->x) * $minorStep->position, $start->y + ($end->y - $start->y) * $minorStep->position);
                 $minorStepSize = new ezcGraphCoordinate($axisBoundings->width * $minorStep->width, $axisBoundings->height * $minorStep->width);
                 if ($axis->minorGrid) {
                     $this->drawGrid($renderer, $gridBoundings, $minorStepPosition, $minorStepSize, $axis->minorGrid);
                 }
                 // major step
                 $this->drawStep($renderer, $minorStepPosition, $direction, $axis->position, $this->minorStepSize, $axis->border);
             }
         }
     }
 }
Example #8
0
 /**
  * Render odometer chart
  * 
  * @param ezcGraphBoundings $boundings 
  * @param ezcGraphChartElementAxis $axis
  * @param ezcGraphOdometerChartOptions $options
  * @return ezcGraphBoundings
  */
 public function drawOdometer(ezcGraphBoundings $boundings, ezcGraphChartElementAxis $axis, ezcGraphOdometerChartOptions $options)
 {
     $height = $boundings->height * $options->odometerHeight;
     // Draw axis
     $oldAxisSpace = $axis->axisSpace;
     $axis->axisSpace = 0;
     $axis->render($this, $boundings);
     // Reset axisspaces to correct values
     $this->xAxisSpace = $boundings->width * $oldAxisSpace;
     $this->yAxisSpace = ($boundings->height - $height) / 2;
     $this->drawAxisLabels();
     // Reduce size of chart boundings respecting requested odometer height
     $boundings->x0 += $this->xAxisSpace;
     $boundings->x1 -= $this->xAxisSpace;
     $boundings->y0 += $this->yAxisSpace;
     $boundings->y1 -= $this->yAxisSpace;
     $gradient = new ezcGraphLinearGradient(new ezcGraphCoordinate($boundings->x0, $boundings->y0), new ezcGraphCoordinate($boundings->x1, $boundings->y0), $options->startColor, $options->endColor);
     // Simply draw box with gradient and optional border
     $this->drawBox($boundings, $gradient, $options->borderColor, $options->borderWidth);
     // Return modified chart boundings
     return $boundings;
 }
Example #9
0
 /**
  * __set 
  * 
  * @param mixed $propertyName 
  * @param mixed $propertyValue 
  * @throws ezcBaseValueException
  *          If a submitted parameter was out of range or type.
  * @throws ezcBasePropertyNotFoundException
  *          If a the value for the property options is not an instance of
  * @return void
  * @ignore
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'min':
             if (!is_numeric($propertyValue)) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'float');
             }
             $this->properties['min'] = (double) $propertyValue;
             $this->properties['initialized'] = true;
             break;
         case 'max':
             if (!is_numeric($propertyValue)) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'float');
             }
             $this->properties['max'] = (double) $propertyValue;
             $this->properties['initialized'] = true;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
             break;
     }
 }
Example #10
0
 /**
  * Calculate bar chart step width
  * 
  * @return void
  */
 protected function calculateStepWidth(ezcGraphChartElementAxis $mainAxis, ezcGraphChartElementAxis $secondAxis, $width)
 {
     $steps = $mainAxis->getSteps();
     $stepWidth = null;
     foreach ($steps as $step) {
         if ($stepWidth === null) {
             $stepWidth = $step->width;
         } elseif ($step->width !== $stepWidth) {
             throw new ezcGraphUnregularStepsException();
         }
     }
     $step = reset($steps);
     if (count($step->childs)) {
         // Keep this for BC reasons
         $barCount = ($mainAxis->getMajorStepCount() + 1) * ($mainAxis->getMinorStepCount() - 1);
         $stepWidth = 1 / $barCount;
     }
     $checkedRegularSteps = true;
     return $mainAxis->axisLabelRenderer->modifyChartDataPosition($secondAxis->axisLabelRenderer->modifyChartDataPosition(new ezcGraphCoordinate($width * $stepWidth, $width * $stepWidth)));
 }
 /**
  * Render Axis labels
  *
  * Render labels for an axis.
  *
  * @param ezcGraphRenderer $renderer Renderer used to draw the chart
  * @param ezcGraphBoundings $boundings Boundings of the axis
  * @param ezcGraphCoordinate $start Axis starting point
  * @param ezcGraphCoordinate $end Axis ending point
  * @param ezcGraphChartElementAxis $axis Axis instance
  * @return void
  */
 public function renderLabels(ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphChartElementAxis $axis)
 {
     // receive rendering parameters from axis
     $steps = $axis->getSteps();
     $this->steps = $steps;
     $axisBoundings = new ezcGraphBoundings($start->x, $start->y, $end->x, $end->y);
     // Determine normalized axis direction
     $this->direction = new ezcGraphVector($end->x - $start->x, $end->y - $start->y);
     $this->direction->unify();
     $axisAngle = -$this->direction->angle(new ezcGraphVector(1, 0));
     if ($this->outerGrid) {
         $gridBoundings = $boundings;
     } else {
         $gridBoundings = new ezcGraphBoundings($boundings->x0 + $renderer->xAxisSpace, $boundings->y0 + $renderer->yAxisSpace, $boundings->x1 - $renderer->xAxisSpace, $boundings->y1 - $renderer->yAxisSpace);
     }
     // Determine optimal angle if none specified
     if ($this->angle === null) {
         $minimumStepWidth = null;
         foreach ($steps as $nr => $step) {
             if ($minimumStepWidth === null || $step->width < $minimumStepWidth) {
                 $minimumStepWidth = $step->width;
             }
         }
         $width = abs($axisBoundings->width * $minimumStepWidth * $this->direction->x + $axisBoundings->height * $minimumStepWidth * $this->direction->y);
         $height = abs($renderer->yAxisSpace * $this->direction->x + $renderer->xAxisSpace * $this->direction->y);
         $length = sqrt(pow($width, 2) + pow($height, 2));
         $this->angle = rad2deg(acos($height / $length));
     }
     // Determine additional required axis space by boxes
     $firstStep = reset($steps);
     $lastStep = end($steps);
     $textAngle = $axisAngle + deg2rad($this->angle) + ($axis->position & (ezcGraph::TOP | ezcGraph::BOTTOM) ? deg2rad(270) : deg2rad(90));
     // Ensure angle between 0 and 360 degrees
     $degTextAngle = rad2deg($textAngle);
     while ($degTextAngle < 0) {
         $degTextAngle += 360.0;
     }
     $this->offset = ($this->angle < 0 ? -1 : 1) * ($axis->position & (ezcGraph::TOP | ezcGraph::LEFT) ? 1 : -1) * (1 - cos(deg2rad($this->angle * 2)));
     $axisSpaceFactor = abs(($this->direction->x == 0 ? 0 : $this->direction->x * $renderer->yAxisSpace / $axisBoundings->width) + ($this->direction->y == 0 ? 0 : $this->direction->y * $renderer->xAxisSpace / $axisBoundings->height));
     $start = new ezcGraphCoordinate($start->x + max(0.0, $axisSpaceFactor * $this->offset) * ($end->x - $start->x), $start->y + max(0.0, $axisSpaceFactor * $this->offset) * ($end->y - $start->y));
     $end = new ezcGraphCoordinate($end->x + min(0.0, $axisSpaceFactor * $this->offset) * ($end->x - $start->x), $end->y + min(0.0, $axisSpaceFactor * $this->offset) * ($end->y - $start->y));
     $labelLength = sqrt(pow($renderer->xAxisSpace * $this->direction->y + $axisSpaceFactor * $this->offset * ($end->x - $start->x), 2) + pow($renderer->yAxisSpace * $this->direction->x + $axisSpaceFactor * $this->offset * ($end->y - $start->y), 2));
     $this->offset *= $axisSpaceFactor;
     // Draw steps and grid
     foreach ($steps as $nr => $step) {
         $position = new ezcGraphCoordinate($start->x + ($end->x - $start->x) * $step->position * abs($this->direction->x), $start->y + ($end->y - $start->y) * $step->position * abs($this->direction->y));
         $stepSize = new ezcGraphCoordinate(($end->x - $start->x) * $step->width, ($end->y - $start->y) * $step->width);
         // Calculate label boundings
         switch (true) {
             case $nr === 0:
                 $labelSize = min(abs($renderer->xAxisSpace * 2 * $this->direction->x + $renderer->yAxisSpace * 2 * $this->direction->y), abs($step->width * $axisBoundings->width * $this->direction->x + $step->width * $axisBoundings->height * $this->direction->y));
                 break;
             case $step->isLast:
                 $labelSize = min(abs($renderer->xAxisSpace * 2 * $this->direction->x + $renderer->yAxisSpace * 2 * $this->direction->y), abs($steps[$nr - 1]->width * $axisBoundings->width * $this->direction->x + $steps[$nr - 1]->width * $axisBoundings->height * $this->direction->y));
                 break;
             default:
                 $labelSize = min(abs($step->width * $axisBoundings->width * $this->direction->x + $step->width * $axisBoundings->height * $this->direction->y), abs($steps[$nr - 1]->width * $axisBoundings->width * $this->direction->x + $steps[$nr - 1]->width * $axisBoundings->height * $this->direction->y));
                 break;
         }
         $labelSize = $labelSize * cos(deg2rad($this->angle));
         $lengthReducement = min(abs(tan(deg2rad($this->angle)) * ($labelSize / 2)), abs($labelLength / 2));
         switch (true) {
             case $degTextAngle >= 0 && $degTextAngle < 90 && ($axis->position === ezcGraph::LEFT || $axis->position === ezcGraph::RIGHT) || $degTextAngle >= 270 && $degTextAngle < 360 && ($axis->position === ezcGraph::TOP || $axis->position === ezcGraph::BOTTOM):
                 $labelBoundings = new ezcGraphBoundings($position->x, $position->y, $position->x + abs($labelLength) - $lengthReducement, $position->y + $labelSize);
                 $labelAlignement = ezcGraph::LEFT | ezcGraph::TOP;
                 $labelRotation = $degTextAngle;
                 break;
             case $degTextAngle >= 90 && $degTextAngle < 180 && ($axis->position === ezcGraph::LEFT || $axis->position === ezcGraph::RIGHT) || $degTextAngle >= 180 && $degTextAngle < 270 && ($axis->position === ezcGraph::TOP || $axis->position === ezcGraph::BOTTOM):
                 $labelBoundings = new ezcGraphBoundings($position->x - abs($labelLength) + $lengthReducement, $position->y, $position->x, $position->y + $labelSize);
                 $labelAlignement = ezcGraph::RIGHT | ezcGraph::TOP;
                 $labelRotation = $degTextAngle - 180;
                 break;
             case $degTextAngle >= 180 && $degTextAngle < 270 && ($axis->position === ezcGraph::LEFT || $axis->position === ezcGraph::RIGHT) || $degTextAngle >= 90 && $degTextAngle < 180 && ($axis->position === ezcGraph::TOP || $axis->position === ezcGraph::BOTTOM):
                 $labelBoundings = new ezcGraphBoundings($position->x - abs($labelLength) + $lengthReducement, $position->y - $labelSize, $position->x, $position->y);
                 $labelAlignement = ezcGraph::RIGHT | ezcGraph::BOTTOM;
                 $labelRotation = $degTextAngle - 180;
                 break;
             case $degTextAngle >= 270 && $degTextAngle < 360 && ($axis->position === ezcGraph::LEFT || $axis->position === ezcGraph::RIGHT) || $degTextAngle >= 0 && $degTextAngle < 90 && ($axis->position === ezcGraph::TOP || $axis->position === ezcGraph::BOTTOM):
                 $labelBoundings = new ezcGraphBoundings($position->x, $position->y + $labelSize, $position->x + abs($labelLength) - $lengthReducement, $position->y);
                 $labelAlignement = ezcGraph::LEFT | ezcGraph::BOTTOM;
                 $labelRotation = $degTextAngle;
                 break;
         }
         $renderer->drawText($labelBoundings, $step->label, $labelAlignement, new ezcGraphRotation($labelRotation, $position));
         // major grid
         if ($axis->majorGrid) {
             $this->drawGrid($renderer, $gridBoundings, $position, $stepSize, $axis->majorGrid);
         }
         // major step
         $this->drawStep($renderer, $position, $this->direction, $axis->position, $this->majorStepSize, $axis->border);
     }
 }
Example #12
0
 /**
  * __set 
  * 
  * @param mixed $propertyName 
  * @param mixed $propertyValue 
  * @throws ezcBaseValueException
  *          If a submitted parameter was out of range or type.
  * @throws ezcBasePropertyNotFoundException
  *          If a the value for the property options is not an instance of
  * @return void
  * @ignore
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'startDate':
             $this->properties['startDate'] = (int) $propertyValue;
             break;
         case 'endDate':
             $this->properties['endDate'] = (int) $propertyValue;
             break;
         case 'interval':
             $this->properties['interval'] = (int) $propertyValue;
             $this->properties['initialized'] = true;
             break;
         case 'dateFormat':
             $this->properties['dateFormat'] = (string) $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
             break;
     }
 }