TeeChartPHP
[ class tree: TeeChartPHP ] [ index: TeeChartPHP ] [ all elements ]

Source for file AxisDraw.php

Documentation is available at AxisDraw.php

  1. <?php
  2.  
  3.  /**
  4.  * AxisDraw class
  5.  *
  6.  * Description:
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage axis
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16.  class AxisDraw {
  17.  
  18.     private static $DIFFLOAT 0.0000001;
  19.     private static $MAXAXISTICKS 2000;
  20.     private $chart;
  21.     private $tmpNumTicks;
  22.     private $drawTicksAndGrid;
  23.     private $tmpLabelStyle;
  24.     private $iIncrement;
  25.     private $tmpWhichDatetime// DateTimeStep
  26.  
  27.     protected $axis;
  28.     protected $tmpValue=0;
  29.  
  30.     public $tmpAlternate;
  31.     public $ticks;
  32.  
  33.     // Interceptors
  34.     function __get$property {
  35.       $method ="get{$property}";
  36.       if method_exists$this$method ) ) {
  37.         return $this->$method();
  38.       }
  39.     }
  40.  
  41.     function __set $property,$value {
  42.       $method ="set{$property}";
  43.       if method_exists$this$method ) ) {
  44.         return $this->$method($value);
  45.       }
  46.     }
  47.  
  48.     /**
  49.     * The class constructor.
  50.     */
  51.     public function AxisDraw($a=null{
  52.  
  53.         if ($a != null{
  54.             $this->axis = $a;
  55.             $this->setChart($this->axis->getChart());
  56.         }
  57.  
  58.         $this->drawTicksAndGrid new TicksGridDraw($this->axis);
  59.     }
  60.  
  61.     public function getNumTicks({
  62.         return $this->tmpNumTicks;
  63.     }
  64.  
  65.     private function getDepthAxisPos({
  66.          $result;
  67.         if($this->axis->getOtherSide())
  68.             $result $this->chart->getChartRect()->getBottom($this->axis->calcZPos();
  69.         else
  70.             $result $this->chart->getChartRect()->getTop($this->axis->calcZPos();
  71.  
  72.         return $result;
  73.     }
  74.  
  75.     private function drawAxisTitle({
  76.         if (($this->axis->getTitle(!= null&& $this->axis->getTitle()->getVisible(&&
  77.             (strlen($this->axis->getTitle()->getCaption()) != 0)) {
  78.             $tmp=$this->axis->getChart()->getChartRect();
  79.             if ($this->axis->isDepthAxis{
  80.                 $this->axis->drawTitle($this->axis->posTitle,$tmp->getBottom());
  81.             else
  82.             if ($this->axis->getHorizontal()) {
  83.                 $this->axis->drawTitle($this->axis->iCenterPos$this->axis->posTitle);
  84.             else {
  85.                 $this->axis->drawTitle($this->axis->posTitle$this->axis->iCenterPos);
  86.             }
  87.         }
  88.     }
  89.  
  90.     private function addTick($aPos{
  91.         $this->ticks[$this->tmpNumTicks$aPos;
  92.         $this->tmpNumTicks++;
  93.     }
  94.  
  95.     private function internalDrawLabel($decValue{
  96.         $tmp $this->axis->calcPosValue($this->tmpValue);
  97.         $axislabels=$this->axis->getLabels();
  98.         if ($axislabels->getOnAxis(||
  99.             (($tmp $this->axis->iStartPos&& ($tmp $this->axis->iEndPos))) {
  100.             if (!$this->axis->getTickOnLabelsOnly()) {
  101.                 $this->addTick($tmp);
  102.             }
  103.             if ($axislabels->getVisible()) {
  104.                 $this->drawThisLabel($tmp,$axislabels->labelValue($this->tmpValue)null);
  105.             }
  106.         }
  107.         if ($decValue{
  108.             $this->tmpValue = $this->axis->incDecDateTime(false$this->tmpValue$this->iIncrement,
  109.                            $this->tmpWhichDatetime);
  110.         }
  111.     }
  112.  
  113.     private function drawThisLabel($labelPos$tmpSt$labelItem{
  114.  
  115.         $old_name TChart::$controlName;        
  116.         TChart::$controlName .= 'Axis_Label_';        
  117.         
  118.         if ($this->axis->getTickOnLabelsOnly()) {
  119.             $this->addTick($labelPos);
  120.         }
  121.  
  122.         $c $this->axis->chart;
  123.         $g $c->getGraphics3D();
  124.         $axisLabels $this->axis->getLabels();
  125.         $g->setFont(($labelItem == null$axisLabels->getFont(:
  126.                      $labelItem->getFont());
  127.  
  128.         $g->getBrush()->setVisible(false);
  129.  
  130.         if ($this->axis->isDepthAxis{
  131.             $g->setTextAlign($this->axis->getDepthAxisAlign());
  132.  
  133.             $tmpZ $labelPos;
  134.  
  135.             $aspect=$c->getAspect();
  136.             if (($aspect->getRotation(== 360||
  137.                 $aspect->getOrthogonal()) {
  138.                 $tmpZ += ($g->getFontHeight(2);
  139.             }
  140.  
  141.             if ($this->axis->getOtherSide()) {
  142.                 $tmpPos $axisLabels->position;
  143.             else {
  144.                 $tmpPos $axisLabels->position-2-($this->chart->getGraphics3D()->textWidth("W"2);
  145.             }
  146.  
  147.             $g->textOut($tmpPos,$this->getDepthAxisPos(),
  148.                       $tmpZ$tmpSt);
  149.         else {
  150.             if ($axisLabels->getAlternate()) {
  151.                 if ($this->tmpAlternate{
  152.                     $tmpPos $axisLabels->position;
  153.                 else {
  154.                     if ($this->axis->getHorizontal()) {
  155.                         if ($this->axis->getOtherSide()) {
  156.                             $tmpPos $axisLabels->position -
  157.                                      $g->getFontHeight();
  158.                         else {
  159.                             $tmpPos $axisLabels->position +
  160.                                      $g->getFontHeight();
  161.                         }
  162.                     else {
  163.                         if ($this->axis->getOtherSide()) {
  164.                             $tmpPos $axisLabels->position +
  165.                                      $this->axis->maxLabelsWidth();
  166.                         else {
  167.                             $tmpPos $axisLabels->position -
  168.                                      $this->axis->maxLabelsWidth();
  169.                         }
  170.                     }
  171.                 }
  172.                 $this->tmpAlternate = !$this->tmpAlternate;
  173.             else {
  174.                 $tmpPos $axisLabels->position;
  175.             }
  176.  
  177.             if ($this->axis->getHorizontal()) {
  178.                 $this->axis->_drawAxisLabel($labelPos,
  179.                                    $tmpPos,
  180.                                    $axisLabels->getAngle()$tmpSt$labelItem);
  181.             else {
  182.                $this->axis->_drawAxisLabel($tmpPos,
  183.                                    $labelPos$axisLabels->getAngle()$tmpSt,
  184.                                    $labelItem);
  185.             }
  186.         }
  187.         
  188.         TChart::$controlName=$old_name;   
  189.     }
  190.  
  191.     private function intPower($numBase$exponent{
  192.         return pow($numBase$exponent);
  193.     }
  194.  
  195.     private function logBaseN($numBase$x{
  196.         return log($x$numBase);
  197.     }
  198.  
  199.     private function roundDate($aDate$aStep{
  200.         $tmpDateTime new DateTime();
  201.         if ($aDate->toDouble(<= $tmpDateTime->MINVALUE{
  202.             return $aDate;
  203.         else {
  204.              $year $aDate->getYear();
  205.              $month $aDate->getMonth();
  206.              $day $aDate->getDay();
  207.  
  208.             switch ($aStep{
  209.             case DateTimeStep::$HALFMONTH:
  210.                 if ($day >= 15{
  211.                     $day 15;
  212.                 else {
  213.                     $day 1;
  214.                 }
  215.                 break;
  216.             case DateTimeStep::$ONEMONTH:
  217.             case DateTimeStep::$TWOMONTHS:
  218.             case DateTimeStep::$THREEMONTHS:
  219.             case DateTimeStep::$FOURMONTHS:
  220.             case DateTimeStep::$SIXMONTHS:
  221.                 $day 1;
  222.                 break;
  223.             case DateTimeStep::$ONEYEAR:
  224.                 $day 1;
  225.                 $month 1;
  226.                 break;
  227.             default:
  228.                 break;
  229.             }
  230.             return new $tmpDateTime($year$month$day);
  231.         }
  232.     }
  233.  
  234.     private function doDefaultLabels({
  235.         $tmp 0;
  236.  
  237.         $this->tmpValue = MathUtils::round($this->axis->iMaximum $this->iIncrement);
  238.         if (abs($this->axis->iRange $this->iIncrement10000{
  239.             /* if less than 10000 labels... */
  240.             /* calculate the maximum value... */
  241.  
  242.             if ($this->axis->iAxisDateTime &&
  243.                 $this->axis->getLabels()->getExactDateTime(&&
  244.                 ($this->tmpWhichDatetime != DateTimeStep::$NONE&&
  245.                 ($this->tmpWhichDatetime DateTimeStep::$ONEDAY)) {
  246.                 $this->tmpValue = $this->roundDate(new DateTime($this->axis->iMaximum),
  247.                                      $this->tmpWhichDatetime)->toDouble();
  248.             else
  249.             if (((string)$this->axis->iMinimum==(string)$this->axis->iMaximum)
  250.                 || (!$this->axis->getLabels()->getRoundFirstLabel())) {
  251.                 $this->tmpValue = $this->axis->iMaximum;
  252.             else {
  253.                 $this->tmpValue = $this->iIncrement $this->tmpValue;
  254.             }
  255.  
  256.             /* adjust the maximum value to be inside "IMinimum" and "IMaximum" */
  257.             while ($this->tmpValue > $this->axis->iMaximum{
  258.                 $this->tmpValue = $this->axis->incDecDateTime(false$this->tmpValue,
  259.                                                $this->iIncrement$this->tmpWhichDatetime);
  260.             }
  261.  
  262.             /* Draw the labels... */
  263.             if ($this->axis->iRangezero{
  264.                 $this->internalDrawLabel(false);
  265.             }
  266.             /* Maximum is equal to Minimum. Draw one label */
  267.             else {
  268.                 /* do the loop and draw labels... */
  269.                 //if ((Math.abs(axis.iMaximum-axis.iMinimum)<1e-10) || (tmpValue.ToString()==(tmpValue-iIncrement).ToString()))
  270.                 if ((abs($this->axis->iMaximum $this->axis->iMinimum<
  271.                      $this->axis->iMinAxisIncrement||
  272.                     ((string)$this->tmpValue==(string)($this->tmpValue - $this->iIncrement))) {
  273.                     /* fix zooming when axis Max=Min */
  274.                     $this->internalDrawLabel(false);
  275.                 else {
  276.                     /* draw labels until "tmpVale" is less than minimum */
  277.                     $tmp ($this->axis->iMinimum -
  278.                            $this->axis->iMinAxisIncrement/
  279.                           (1.0 $this->axis->iMinAxisIncrement);
  280.  
  281.                     while ($this->tmpValue >= $tmp{
  282.                         $this->internalDrawLabel(true);
  283.                     }
  284.                 }
  285.             }
  286.         }
  287.     }
  288.  
  289.     private function doDefaultLogLabels({
  290.  
  291.         if ($this->axis->iMinimum != $this->axis->iMaximum{
  292.             if ($this->axis->iMinimum <= 0{
  293.                 if ($this->axis->iMinimum == 0{
  294.                     $this->axis->iMinimum 0.1;
  295.                 else {
  296.                     $this->axis->iMinimum Axis::$MINAXISRANGE;
  297.                 }
  298.                 $this->tmpValue = $this->axis->iMinimum;
  299.             else {
  300.                 $this->tmpValue = $this->intPower($this->axis->getLogarithmicBase(),
  301.                                     MathUtils::round($this->logBaseN($this->axis->
  302.                         $this->getLogarithmicBase(),
  303.                         $this->axis->iMinimum)));
  304.             }
  305.  
  306.             // speed optimization
  307.             $showMinorGrid ($this->axis->minorGrid != null&&
  308.                                     ($this->axis->minorGrid->getVisible());
  309.  
  310.             if ($showMinorGrid{
  311.  
  312.                 $tmpValue2 $this->tmpValue;
  313.  
  314.                 if ($tmpValue2 >= $this->axis->iMinimum{
  315.                     $tmpValue2 $this->intPower($this->axis->getLogarithmicBase(),
  316.                                          MathUtils::round($this->logBaseN($this->axis->
  317.                             $this->getLogarithmicBase(),
  318.                             $this->axis->iMinimum)) 1);
  319.                 }
  320.  
  321.                 if ($tmpValue2 $this->axis->iMinimum{
  322.                     $this->addTick($this->axis->calcPosValue($tmpValue2));
  323.                 }
  324.             }
  325.  
  326.             if ($this->axis->getLogarithmicBase(1{
  327.                 while ($this->tmpValue <= $this->axis->iMaximum{
  328.                     if ($this->tmpValue >= $this->axis->iMinimum{
  329.                         $this->internalDrawLabel(false);
  330.                     }
  331.                     $this->tmpValue *= $this->axis->getLogarithmicBase();
  332.                 }
  333.             }
  334.  
  335.             // For minor grids only...
  336.             if ($showMinorGrid && ($this->tmpValue > $this->axis->iMaximum)) {
  337.                 $this->addTick($this->axis->calcPosValue($this->tmpValue));
  338.             }
  339.         }
  340.     }
  341.  
  342.     private function doNotCustomLabels({
  343.         if ($this->axis->getLogarithmic(&& ($this->axis->getIncrement(== 0)) {
  344.             $this->doDefaultLogLabels();
  345.         else {
  346.             $this->doDefaultLabels();
  347.         }
  348.     }
  349.  
  350.     private function doCustomLabels({
  351.         $labelInside false;
  352.  
  353.         $this->tmpValue = $this->axis->iMinimum;
  354.  
  355.         $labelIndex 0;
  356.         $r new NextAxisLabelValue();
  357.         $r->setStop(true);
  358.  
  359.         // maximum 2000 labels...
  360.         do {
  361.             if ($this->axis->chart->getParent(!= null{
  362.                 /* Add this check ?? TODO 
  363.                    $this->labelText = $tmpResult;  
  364.                    // Args  : Axis, valueindex display order, label
  365.                      $parent->TriggerEvent('OnGetAxisLabel', array($this->axis,$this->axis->labelIndex, $this->labelText));
  366.             
  367.                    if ($this->labelText != $tmpResult)
  368.                       $tmpResult = $this->labelText;                
  369.                 */
  370.             }
  371.  
  372.             if ($r->getStop()) {
  373.                 if ($labelIndex == 0{
  374.                     $this->doNotCustomLabels();
  375.                 }
  376.                 return;
  377.             else {
  378.                 $labelInside (($this->tmpValue >=
  379.                                 ($this->axis->iMinimum self::$DIFFLOAT)) &&
  380.                                ($this->tmpValue <=
  381.                                 ($this->axis->iMaximum self::$DIFFLOAT)));
  382.                 if ($labelInside{
  383.                     $this->internalDrawLabel(false);
  384.                 }
  385.                 $labelIndex++;
  386.             }
  387.         while ($labelInside || ($labelIndex 2000|| (!$r->getStop()));
  388.     }
  389.  
  390.  
  391.     private function calcFirstLastAllSeries($rect{
  392.         $tmp new IntRange(intval('1000000000000')-1);  // MAX_VALUE
  393.  
  394.         for $t 0$t sizeof($this->axis->iSeriesList)$t++{
  395.             $s $this->axis->iSeriesList->getSeries($t);
  396.             if (isset($s))
  397.             {
  398.               $s->calcFirstLastVisibleIndex();
  399.  
  400.               if (($s->getFirstVisible($tmp->first&&
  401.                   ($s->getFirstVisible(!= -1)) {
  402.                   $tmp->first $s->getFirstVisible();
  403.               }
  404.  
  405.               if ($s->getLastVisible($tmp->last{
  406.                   $tmp->last $s->getLastVisible();
  407.               }
  408.             }
  409.         }
  410.  
  411.         return $tmp;
  412.     }
  413.  
  414.     private function calcAllSeries({
  415.         if ($this->axis->iSeriesList == null{
  416.             $this->axis->iSeriesList new SeriesCollection($this->chart);
  417.         }
  418.         else
  419.         {
  420.           $this->axis->iSeriesList->clear();
  421.         }
  422.  
  423.         for $t 0$t $this->axis->chart->getSeriesCount()$t++{
  424.             $s $this->axis->chart->getSeries($t);
  425.             if ($s->getActive(&& $s->associatedToAxis($this->axis)) {
  426.                 $this->axis->iSeriesList->internalAdd($s);
  427.             }
  428.         }
  429.     }
  430.  
  431.     private function getAxisSeriesLabel($aIndex{
  432.         $result new GetAxisSeriesLabelResults();
  433.         $result->result false;
  434.  
  435.         for $t 0$t sizeof($this->axis->iSeriesList)$t++{
  436.  
  437.             $tmpSeries $this->axis->iSeriesList->getSeries($t);
  438.  
  439.             if (($aIndex >= $tmpSeries->getFirstVisible()) &&
  440.                 ($this->aIndex <= $tmpSeries->getLastVisible())) {
  441.  
  442.                 // even if the series has no text labels
  443.                 if ($this->tmpLabelStyle == AxisLabelStyle::$MARK{
  444.                     $result->label $tmpSeries->getValueMarkText($aIndex);
  445.                 else
  446.                 if ($this->tmpLabelStyle == AxisLabelStyle::$TEXT{
  447.                     $labels $tmpSeries->getLabels();
  448.                     $result->label $labels[$aIndex];
  449.                 }
  450.  
  451.                 /* TODO remove
  452.                 if ($this->axis->chart->getParent() != null) {
  453.                     $result->label = $this->axis->chart->getParent()->getAxisLabelResolver()->
  454.                                    $this->getLabel(
  455.                                            $this->axis,
  456.                                            $tmpSeries,
  457.                                            $aIndex,
  458.                                            $result->label);
  459.                 }
  460.                 */
  461.  
  462.                 if (strlen($result->label!= 0{
  463.                     $result->result true;
  464.  
  465.                     if ($this->axis->getHorizontal()) {
  466.                         $result->value $tmpSeries->getXValues()->value[$aIndex];
  467.                     else {
  468.                         $result->value $tmpSeries->getYValues()->value[$aIndex];
  469.                     }
  470.                 }
  471.             }
  472.         }
  473.  
  474.         return $result;
  475.     }
  476.  
  477.     private function depthAxisLabels({
  478.  
  479.         if ($this->axis->chart->countActiveSeries(0{
  480.             $axisLabels $this->axis->getLabels();
  481.             for $t = (int) $this->axis->iMinimum$t <= $this->axis->iMaximum$t++{
  482.  
  483.                 $tmp $this->axis->calcYPosValue($this->axis->iMaximum $t 0.5);
  484.  
  485.                 if (!$this->axis->getTickOnLabelsOnly()) {
  486.                     $this->addTick($tmp);
  487.                 }
  488.                 if ($axisLabels->getVisible()) {
  489.                     $tmpSt $this->axis->chart->getSeriesTitleLegend($ttrue);
  490.  
  491.                     if ($this->axis->chart->getParent(!= null{
  492.                         // Args  : Axis, valueindex display order, label
  493.                         $this->labelText $tmpSt;  
  494.                         $this->axis->chart->getParent()->TriggerEvent('OnGetAxisLabel'
  495.                                     array($this->axis$t$this->labelText));
  496.             
  497.                         if ($this->labelText != $tmpSt)
  498.                             $tmpSt $this->labelText;                        
  499.                     }
  500.  
  501.                     $this->drawThisLabel($tmp$tmpStnull);
  502.                 }
  503.             }
  504.         }
  505.     }
  506.  
  507.     private function axisLabelsSeries($rect{
  508.         /* Select all active Series that have "Labels" */
  509.         $tmpNum 0;
  510.         $tmpSt "";
  511.         $tmpValue 0;
  512.  
  513.         $this->calcAllSeries();
  514.         $tmpRange $this->calcFirstLastAllSeries($rect);
  515.  
  516.         if ($tmpRange->first != intval('1000000000000')) {  // MAX_VALUE
  517.              $oldPosLabel = -1;
  518.              $oldSizeLabel 0;
  519.              $tmpLabelW $this->axis->getHorizontal();
  520.             switch ($this->axis->getLabels()->iAngle{
  521.             case 90:
  522.             case 270:
  523.                 $tmpLabelW !$tmpLabelW;
  524.                 break;
  525.             default:
  526.                 break;
  527.             }
  528.  
  529.             $axisLabels $this->axis->getLabels();
  530.             for $t $tmpRange->first$t <= $tmpRange->last$t++{
  531.                 $r $this->getAxisSeriesLabel($t);
  532.                 if ($r->result{
  533.                     $tmpValue $r->value;
  534.                     $tmpSt $r->label;
  535.  
  536.                     if (($tmpValue >= $this->axis->iMinimum&&
  537.                         ($this->tmpValue <= $this->axis->iMaximum)) {
  538.                         $tmp $this->axis->calcPosValue($tmpValue);
  539.                         if (!$this->axis->getTickOnLabelsOnly()) {
  540.                             $this->addTick($tmp);
  541.                         }
  542.  
  543.                         if ($axisLabels->getVisible(&&
  544.                             (strlen($tmpSt!= 0)) {
  545.  
  546.                             $tmpMulti $this->axis->chart->multiLineTextWidth(
  547.                                     $tmpSt);
  548.  
  549.                             $tmpLabelSize $tmpMulti->width;
  550.                             $tmpNum $tmpMulti->count;
  551.  
  552.                             if (!$tmpLabelW{
  553.                                 $tmpLabelSize $this->chart->getGraphics3D()->getFontHeight($tmpNum;
  554.                             }
  555.                             if (($axisLabels->iSeparation != 0&&
  556.                                 ($this->oldPosLabel != -1)) {
  557.                                 $tmpLabelSize += (int) (0.02 $tmpLabelSize *
  558.                                         $axisLabels->iSeparation);
  559.                                 $tmpLabelSize *= 0.5;
  560.  
  561.                                 if ($tmp >= $oldPosLabel{
  562.                                     $tmpDraw (($tmp -
  563.                                                 $tmpLabelSize>=
  564.                                                ($this->oldPosLabel +
  565.                                                 $oldSizeLabel));
  566.                                 else {
  567.                                     $tmpDraw (($tmp +
  568.                                                 $tmpLabelSize<=
  569.                                                ($this->oldPosLabel -
  570.                                                 $oldSizeLabel));
  571.                                 }
  572.  
  573.                                 if ($tmpDraw{
  574.                                     $this->drawThisLabel($tmp$tmpStnull);
  575.                                     $oldPosLabel $tmp;
  576.                                     $oldSizeLabel $tmpLabelSize;
  577.                                 }
  578.                             else {
  579.                                 $this->drawThisLabel($tmp$tmpStnull);
  580.                                 $oldPosLabel $tmp;
  581.                                 $oldSizeLabel $tmpLabelSize 2;
  582.                             }
  583.                         }
  584.                     }
  585.                 }
  586.             }
  587.  
  588.             $this->axis->iSeriesList->clear(false);
  589.         }
  590.     }
  591.  
  592.     private function drawCustomLabels({
  593.  
  594.         $axisLabels $this->axis->getLabels();
  595.         for $t 0$t sizeof($axisLabels->getItems())$t++{
  596.  
  597.             $tmpItem $axisLabels->getItems()->getItem($t);
  598.  
  599.             if ($tmpItem->getValue(>= $this->axis->getMinimum(&&
  600.                 $tmpItem->getValue(<= $this->axis->getMaximum()) {
  601.  
  602.                 $tmp $this->axis->calcPosValue($tmpItem->getValue());
  603.  
  604.                 if (!$this->axis->getTickOnLabelsOnly()) {
  605.                     $this->addTick($tmp);
  606.                 }
  607.                 if ($tmpItem->getVisible()) {
  608.                     $tmpSt $tmpItem->getText();
  609.                     if ($tmpSt==""{
  610.                         $tmpSt $axisLabels->labelValue($tmpItem->getValue());
  611.                     }
  612.  
  613.                     $this->drawThisLabel($tmp$tmpSt$tmpItem);
  614.                 }
  615.             }
  616.         }
  617.     }
  618.  
  619.     public function draw($calcPosAxis{
  620.         $this->axis->iAxisDateTime $this->axis->isDateTime();
  621.  
  622.         if ($calcPosAxis{
  623.             $this->axis->posAxis $this->axis->applyPosition($this->axis->
  624.                     getRectangleEdge($this->axis->chart->getChartRect()),
  625.                                               $this->axis->chart->getChartRect());
  626.         }
  627.  
  628.         $this->drawAxisTitle();
  629.  
  630.         $this->tmpNumTicks 0;
  631.         $this->ticks = Array();  // [self::$MAXAXISTICKS];
  632.  
  633.         $this->tmpAlternate = $this->axis->getHorizontal();
  634.  
  635.         $axisLabels $this->axis->getLabels();
  636.         if ($axisLabels->getItems()->count(== 0{
  637.             $this->tmpLabelStyle $this->axis->calcLabelStyle();
  638.  
  639.             if ($this->tmpLabelStyle != AxisLabelStyle::$NONE{
  640.                 // Assign font before CalcIncrement !
  641.                 $this->chart->getGraphics3D()->setFont($axisLabels->getFont());
  642.                 $this->iIncrement $this->axis->getCalcIncrement();
  643.  
  644.                 if ($this->axis->iAxisDateTime &&
  645.                     $axisLabels->getExactDateTime(&&
  646.                     ($this->axis->getIncrement(!= 0)) {
  647.                     $this->tmpWhichDatetime Axis::findDateTimeStep(
  648.                             $this->axis->getIncrement());
  649.  
  650.                     $tmpDateTimeStep new DateTimeStep();
  651.  
  652.                     if ($this->tmpWhichDatetime != DateTimeStep::$NONE{
  653.                         while (($this->iIncrement >
  654.                                 ($tmpDateTimeStep->STEP[$this->tmpWhichDatetime])) &&
  655.                                ($this->tmpWhichDatetime !=
  656.                                 DateTimeStep::$ONEYEAR)) {
  657.                             $this->tmpWhichDatetime += 1;
  658.                         }
  659.                     }
  660.                 else {
  661.                     $this->tmpWhichDatetime DateTimeStep::$NONE;
  662.                 }
  663.  
  664.                 if ((($this->iIncrement 0||
  665.                      (($this->tmpWhichDatetime >=
  666.                        DateTimeStep::$HALFMONTH&&
  667.                       ($this->tmpWhichDatetime <=
  668.                        DateTimeStep::$ONEYEAR)))
  669.                     && ($this->axis->iMaximum >= $this->axis->iMinimum)) {
  670.  
  671.                     if ($this->tmpLabelStyle == AxisLabelStyle::$VALUE{
  672.                         $this->doCustomLabels();
  673.                         /*if ((axis.chart.getParent() != null) && --> doNotCustomLabels is called from doCustomLabels
  674.                             (axis.chart.getParent().
  675.                              checkGetAxisLabelAssigned())) {
  676.                             doCustomLabels();
  677.                                                  } else {
  678.                             doNotCustomLabels();
  679.                                                  }*/
  680.                     else
  681.                     if ($this->tmpLabelStyle == AxisLabelStyle::$MARK{
  682.                         $this->axisLabelsSeries($this->axis->chart->getChartRect());
  683.                     else
  684.                     if ($this->tmpLabelStyle == AxisLabelStyle::$TEXT{
  685.                         if ($this->axis->isDepthAxis{
  686.                             $this->depthAxisLabels();
  687.                         else {
  688.                             $this->axisLabelsSeries($this->axis->chart->getChartRect());
  689.                         }
  690.                     }
  691.                 }
  692.             }
  693.         else {
  694.             $this->drawCustomLabels();
  695.         }
  696.  
  697.         $this->drawTicksAndGrid->drawTicksGrid($this->ticks$this->tmpNumTicks$this->tmpValue);
  698.     }
  699.  
  700.         function setChart($chart{
  701.                 $this->chart $chart;
  702.  
  703.                 if ($this->drawTicksAndGrid != null{
  704.                         $this->drawTicksAndGrid->setChart($chart);
  705.                 }
  706.         }
  707. }
  708.  
  709.  
  710.  
  711.  /**
  712.  * TicksGridDraw class
  713.  *
  714.  * Description:
  715.  *
  716.  * @author
  717.  * @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  718.  * @version 1.0
  719.  * @package TeeChartPHP
  720.  * @subpackage Axis
  721.  * @link http://www.steema.com
  722.  */
  723.  
  724.      class TicksGridDraw {
  725.         private $axis;
  726.         private $tmpNumTicks;
  727.         private $tmpTicks;
  728.         private $tmpWallSize;
  729.         private $c;
  730.         private $g;
  731.         private $a;
  732.         private $is3D;
  733.         private $r;
  734.  
  735.         /**
  736.         * The class constructor.
  737.         */
  738.         public function TicksGridDraw($a=null{
  739.  
  740.             if ($a != null{
  741.                 $this->axis $a;
  742.                 $this->setChart($this->axis->chart);
  743.             }
  744.         }
  745.  
  746.         public function setChart($chart{
  747.             $this->$chart;
  748.         }
  749.  
  750.         private function getZGridPosition({
  751.             return (int) ($this->a->getWidth3D($this->axis->getGrid()->getZPosition(0.01)// 6.0
  752.         }
  753.  
  754.         private function drawGridLine($tmp{
  755.             if (($tmp $this->axis->iStartPos&& ($tmp $this->axis->iEndPos)) {
  756.                 if ($this->axis->isDepthAxis{
  757.                     $this->g->verticalLine($this->r->x$this->r->y$this->r->getBottom()$tmp);
  758.                     $this->g->horizontalLine($this->r->x$this->r->getRight()$this->r->getBottom(),
  759.                                      $tmp);
  760.                 else if ($this->axis->getHorizontal()) {
  761.                     if ($this->is3D{
  762.                         if ($this->axis->getOtherSide()) {
  763.                             $this->g->verticalLine($tmp$this->r->y$this->r->getBottom(),
  764.                                            $this->a->getWidth3D());
  765.                         else {
  766.                             if ($this->c->getAxes()->getDrawBehind()) {
  767.  
  768.                                 $this->g->zLine($tmp$this->axis->posAxis$this->getZGridPosition(),
  769.                                         $this->a->getWidth3D());
  770.  
  771.                                 $this->g->verticalLine($tmp$this->r->y,
  772.                                                $this->r->getBottom()$this->a->getWidth3D());
  773.                             else {
  774.                                 $this->g->verticalLine($tmp$this->r->y,
  775.                                                $this->r->getBottom()0);
  776.                             }
  777.                         }
  778.                     else {
  779.                         $this->g->verticalLine($tmp$this->r->1$this->r->getBottom(),0);
  780.                     }
  781.                 else
  782.                 if ($this->is3D{
  783.                     if ($this->axis->getOtherSide()) {
  784.                         $this->g->horizontalLine($this->r->x$this->r->getRight()$tmp$this->a->getWidth3D());
  785.                     else {
  786.                         if ($this->c->getAxes()->getDrawBehind()) {
  787.  
  788.                             $this->g->zLine($this->axis->posAxis$tmp$this->getZGridPosition(),
  789.                                     $this->a->getWidth3D());
  790.  
  791.                             if (!$this->axis->hideBackGrid{
  792.                                 if ($this->axis->getHorizontal()) {
  793.                                     $this->g->verticalLine($tmp$this->r->getTop()$this->r->getBottom(),
  794.                                             $this->a->getWidth3D());
  795.                                 else {
  796.                                     $this->g->horizontalLine($this->r->x$this->r->getRight()$tmp,
  797.                                             $this->a->getWidth3D());
  798.                                 }
  799.                             }
  800.                         }
  801.                     }
  802.                 else {
  803.                     $this->g->horizontalLine($this->r->1$this->r->getRight()$tmp,0);
  804.                 }
  805.             }
  806.         }
  807.  
  808.         private function drawGrids({
  809.             $old_name=TChart::$controlName;               
  810.             TChart::$controlName .='Axis_Grid_';
  811.             
  812.             $this->g->setPen($this->axis->getGrid());
  813.             // TODO if ($this->g->getPen()->getColor()->isEmpty()) {
  814.                 $this->g->getPen()->setColor(new Color(128,128,128));
  815.             //}
  816.  
  817.             for $t 0$t $this->tmpNumTicks$t++{
  818.                 if ($this->axis->getGrid()->getCentered()) {
  819.                     if ($t 0{
  820.                         $this->drawGridLine((int) (0.5 *
  821.                            ($this->tmpTicks[$t$this->tmpTicks[$t 1])));
  822.                     }
  823.                 else {
  824.                     $this->drawGridLine($this->tmpTicks[$t]);
  825.                 }
  826.             }
  827.             TChart::$controlName=$old_name;   
  828.         }
  829.  
  830.         private function internalDrawTick($tmp$delta$tmpTickLength{
  831.             if ($this->axis->isDepthAxis{
  832.                 if ($this->axis->getOtherSide()) {
  833.                     if ($this->is3D{
  834.                         $this->g->horizontalLine($this->axis->posAxis $delta,
  835.                                 $this->axis->posAxis $delta $tmpTickLength,
  836.                                 $this->getDepthAxisPos()$tmp);
  837.                     else {
  838.                         $this->g->horizontalLine($this->axis->posAxis $delta,
  839.                                 $this->axis->posAxis $delta $tmpTickLength,
  840.                                 $this->getDepthAxisPos(),0);
  841.                     }
  842.                 else {
  843.                     if ($this->is3D{
  844.                         $this->g->horizontalLine($this->axis->posAxis $delta,
  845.                                 $this->axis->posAxis $delta $tmpTickLength,
  846.                                 $this->getDepthAxisPos()$tmp);
  847.                     else {
  848.                         $this->g->horizontalLine($this->axis->posAxis $delta,
  849.                                 $this->axis->posAxis $delta $tmpTickLength,
  850.                                 $this->getDepthAxisPos(),0);
  851.                     }
  852.  
  853.                 }
  854.             else
  855.             if ($this->axis->getOtherSide()) {
  856.                 if ($this->axis->getHorizontal()) {
  857.                     if ($this->is3D{
  858.                         $this->g->verticalLine($tmp,
  859.                                        $this->axis->posAxis $delta,
  860.                                        $this->axis->posAxis $delta -
  861.                                        $tmpTickLength$this->axis->iZPos);
  862.                     else {
  863.                         $this->g->verticalLine($tmp,
  864.                                        $this->axis->posAxis $delta,
  865.                                        $this->axis->posAxis $delta -
  866.                                        $tmpTickLength,0);
  867.                     }
  868.                 else
  869.                 if ($this->is3D{
  870.                     $this->g->horizontalLine($this->axis->posAxis $delta,
  871.                                      $this->axis->posAxis $delta +
  872.                                      $tmpTickLength$tmp$this->axis->iZPos);
  873.                 else {
  874.                     $this->g->horizontalLine($this->axis->posAxis $delta,
  875.                                      $this->axis->posAxis $delta +
  876.                                      $tmpTickLength$tmp,0);
  877.                 }
  878.             else {
  879.                 $delta += $this->tmpWallSize;
  880.                 if ($this->axis->getHorizontal()) {
  881.                     if ($this->is3D{
  882.                         $this->g->verticalLine($tmp,
  883.                                        $this->axis->posAxis $delta,
  884.                                        $this->axis->posAxis $delta +
  885.                                        $tmpTickLength$this->axis->iZPos);
  886.                     else {
  887.                         $this->g->verticalLine($tmp,
  888.                                        $this->axis->posAxis $delta,
  889.                                        $this->axis->posAxis $delta +
  890.                                        $tmpTickLength,0);
  891.                     }
  892.                 else
  893.                 if ($this->is3D{
  894.                     $this->g->horizontalLine($this->axis->posAxis $delta,
  895.                                      $this->axis->posAxis $delta -
  896.                                      $tmpTickLength$tmp$this->axis->iZPos);
  897.                 else {
  898.                     $this->g->horizontalLine($this->axis->posAxis $delta,
  899.                                      $this->axis->posAxis $delta -
  900.                                      $tmpTickLength$tmp0);
  901.                 }
  902.             }
  903.         }
  904.  
  905.         private function drawAxisLine({
  906.             $old_name=TChart::$controlName;                           
  907.             TChart::$controlName .='Axis_';            
  908.             
  909.             if ($this->axis->isDepthAxis{
  910.                 $tmp;
  911.                if ($this->axis->getOtherSide()) {
  912.                    $tmp $this->r->getBottom(+
  913.                          $this->c->getWalls()->calcWallSize($this->c->getAxes()->getBottom()) -
  914.                          $this->axis->iZPos;
  915.                else {
  916.                    $tmp $this->r->getTop($this->axis->iZPos;
  917.                }
  918.                $this->g->line($this->axis->posAxis$tmp$this->axis->iStartPos,
  919.                       $this->axis->posAxis$tmp$this->axis->iEndPos);
  920.             else
  921.             if ($this->axis->getHorizontal()) {
  922.                 if ($this->axis->getOtherSide()) {
  923.                     $this->g->horizontalLine($this->axis->iStartPos,
  924.                                      $this->axis->iEndPos$this->axis->posAxis,
  925.                                      $this->axis->iZPos);
  926.                 else {
  927.                     $this->g->horizontalLine($this->axis->iStartPos -
  928.                             $this->c->getWalls()->calcWallSize($this->c->getAxes()->getLeft()),
  929.                                      $this->axis->iEndPos,
  930.                                      $this->axis->posAxis $this->tmpWallSize,
  931.                                      $this->axis->iZPos);
  932.                 }
  933.             else {
  934.                  $tmp $this->axis->getOtherSide($this->tmpWallSize :
  935.                           -$this->tmpWallSize;
  936.                 $this->g->verticalLine($this->axis->posAxis $tmp,
  937.                                $this->axis->iStartPos,
  938.                                $this->axis->iEndPos +
  939.                                $this->c->getWalls()->calcWallSize($this->c->getAxes()->getBottom()),
  940.                                $this->axis->iZPos);
  941.             }
  942.             TChart::$controlName=$old_name;
  943.         }
  944.  
  945.         private function aProc($aPos$isGrid{
  946.             if (($aPos $this->axis->iStartPos&& ($aPos $this->axis->iEndPos)) {
  947.                 if ($isGrid{
  948.                     $pen $this->axis->getMinorGrid();
  949.                     $this->drawGridLine($aPos);
  950.                 else {
  951.                     $this->internalDrawTick($aPos1,
  952.                                      $this->axis->getMinorTicks()->length);
  953.                 }
  954.             }
  955.         }
  956.  
  957.         private function processMinorTicks($isGrid{
  958.              $tmpInvCount 1.0 ($this->axis->getMinorTickCount(1);
  959.  
  960.             if ($this->tmpNumTicks 1{
  961.                 if (!$this->axis->getLogarithmic()) {
  962.                     $tmpDelta 1.0 ($this->tmpTicks[1$this->tmpTicks[0]*
  963.                                $tmpInvCount;
  964.                     for $t 1$t <= $this->axis->getMinorTickCount()$t++{
  965.                         $this->aProc($this->tmpTicks[0- (int) ($t $tmpDelta),
  966.                               $isGrid);
  967.                         $this->aProc($this->tmpTicks[$this->tmpNumTicks 1+
  968.                               (int) ($t $tmpDelta)$isGrid);
  969.                     }
  970.                 }
  971.  
  972.                 for $t 1$t <= $this->tmpNumTicks 1$t++{
  973.                     if ($this->axis->getLogarithmic()) {
  974.  
  975.                          $tmpValue $this->axis->calcPosPoint($this->tmpTicks[$t 1]);
  976.                          $tmpDelta (($tmpValue *
  977.                                      $this->axis->getLogarithmicBase()) -
  978.                                     $tmpValue$tmpInvCount;
  979.  
  980.                         for $tt 1$tt $this->axis->getMinorTickCount()$tt++{
  981.                             $tmpValue += $tmpDelta;
  982.                             if ($tmpValue <= $this->axis->iMaximum{
  983.                                 $this->aProc($this->axis->calcPosValue($tmpValue)$isGrid);
  984.                             else {
  985.                                 break;
  986.                             }
  987.                         }
  988.                     else {
  989.                         $tmpDelta 1.0 *
  990.                                    ($this->tmpTicks[$t$this->tmpTicks[$t 1]*
  991.                                    $tmpInvCount;
  992.                         for $tt 1$tt <= $this->axis->getMinorTickCount()$tt++{
  993.                             $this->aProc($this->tmpTicks[$t-
  994.                                   (int) ($tt $tmpDelta)$isGrid);
  995.                         }
  996.                     }
  997.                 }
  998.             }
  999.         }
  1000.  
  1001.         private function processTicks($aPen$aOffset$aLength{
  1002.             if ($aPen->getVisible(&& ($aLength != 0)) {
  1003.                 $old_name=TChart::$controlName;                                           
  1004.                 TChart::$controlName .='Axis_Ticks_';                
  1005.                 $this->g->setPen($aPen);
  1006.                 for $t 0$t $this->tmpNumTicks$t++{
  1007.                     $this->internalDrawTick($this->tmpTicks[$t]$aOffset,
  1008.                                      $aLength);
  1009.                 }
  1010.                 TChart::$controlName=$old_name;
  1011.             }
  1012.         }
  1013.  
  1014.         private function processMinor($aPen$isGrid{
  1015.             if (($this->tmpNumTicks 0&& $aPen->getVisible()) {
  1016.                 $this->g->setPen($aPen);
  1017.                 $this->processMinorTicks($isGrid);
  1018.             }
  1019.         }
  1020.  
  1021.         public function drawTicksGrid($tempTicks$tempNumTicks$tempValue{
  1022.             $this->$this->axis->chart;
  1023.             $this->$this->c->getGraphics3D();
  1024.             $this->$this->c->getAspect();
  1025.             $this->is3D $this->a->getView3D();
  1026.             $this->tmpTicks $tempTicks;
  1027.             $this->tmpNumTicks $tempNumTicks;
  1028.             $this->$this->c->getChartRect();
  1029.  
  1030.             $this->g->getBrush()->setVisible(false);
  1031.  
  1032.             $this->tmpWallSize $this->c->getWalls()->calcWallSize($this->axis);
  1033.             if ($this->axis->getAxisPen()->getVisible()) {
  1034.                 $this->g->setPen($this->axis->getAxisPen());
  1035.  
  1036.                 $this->drawAxisLine();
  1037.             }
  1038.             $this->processTicks($this->axis->getTicks()1$this->axis->getTicks()->length);
  1039.  
  1040.             if ($this->axis->getGrid()->getVisible()) {
  1041.                 $this->drawGrids();
  1042.             }
  1043.  
  1044.             $this->processTicks($this->axis->getTicksInner()-1-$this->axis->getTicksInner()->length);
  1045.             $this->processMinor($this->axis->getMinorTicks()false);
  1046.  
  1047.             // speed optimization
  1048.             if ($this->axis->getMinorGrid(!= null{
  1049.                 $this->processMinor($this->axis->getMinorGrid()true);
  1050.             }
  1051.         }
  1052.     }
  1053.  
  1054.  
  1055.  
  1056.     class IntRange {
  1057.         public $first;
  1058.         public $last;
  1059.  
  1060.         /**
  1061.         * The class constructor.
  1062.         */
  1063.         public function IntRange($first=0$last=0{
  1064.             $this->first = $first;
  1065.             $this->last = $last;
  1066.         }
  1067.     }
  1068.  
  1069.  
  1070.  
  1071.     class GetAxisSeriesLabelResults {
  1072.         public $result;
  1073.         public $value;
  1074.         public $label;
  1075.  
  1076.         /**
  1077.         * The class constructor.
  1078.         */
  1079.         public function GetAxisSeriesLabelResults({
  1080.         }
  1081.     }
  1082.  
  1083. ?>

Documentation generated on Wed, 16 Jun 2010 12:03:09 +0200 by phpDocumentor 1.4.1