Beispiel #1
0
 /**
  * Update coordinates
  * @access private
  */
 function _updateCoords()
 {
     $this->_setCoords($this->_parent->_plotLeft, $this->_parent->_plotTop, $this->_parent->_plotRight, $this->_parent->_plotBottom);
     parent::_updateCoords();
 }
Beispiel #2
0
 /**
  * Update coordinates
  *
  * @access private
  */
 function _updateCoords()
 {
     if (is_array($this->_elements)) {
         $keys = array_keys($this->_elements);
         foreach ($keys as $key) {
             $element =& $this->_elements[$key];
             if (is_a($element, 'Image_Graph_Plot')) {
                 $this->_setExtrema($element);
             }
         }
         unset($keys);
     }
     $this->_calcEdges();
     $centerX = (int) (($this->_left + $this->_right) / 2);
     $centerY = (int) (($this->_top + $this->_bottom) / 2);
     $radius = min($this->_plotHeight(), $this->_plotWidth()) / 2;
     if (is_object($this->_axisX)) {
         $this->_axisX->_setCoords($centerX - $radius, $centerY - $radius, $centerX + $radius, $centerY + $radius);
     }
     if (is_object($this->_axisY)) {
         $this->_axisY->_setCoords($centerX, $centerY, $centerX - $radius, $centerY - $radius);
     }
     $this->_plotLeft = $this->_fillLeft();
     $this->_plotTop = $this->_fillTop();
     $this->_plotRight = $this->_fillRight();
     $this->_plotBottom = $this->_fillBottom();
     Image_Graph_Element::_updateCoords();
     if (is_object($this->_axisX)) {
         $this->_axisX->_updateCoords();
     }
     if (is_object($this->_axisY)) {
         $this->_axisY->_updateCoords();
     }
 }
Beispiel #3
0
 /**
  * Update coordinates
  *
  * @access private
  */
 function _updateCoords()
 {
     if (is_array($this->_elements)) {
         $keys = array_keys($this->_elements);
         foreach ($keys as $key) {
             $element =& $this->_elements[$key];
             if (is_a($element, 'Image_Graph_Plot')) {
                 if ((is_a($element, 'Image_Graph_Plot_Bar') || is_a($element, 'Image_Graph_Plot_Step') || is_a($element, 'Image_Graph_Plot_Dot') || is_a($element, 'Image_Graph_Plot_CandleStick') || is_a($element, 'Image_Graph_Plot_BoxWhisker') || is_a($element, 'Image_Graph_Plot_Impulse')) && $this->_axisX != null) {
                     $this->_axisX->_pushValues();
                 }
                 $this->_setExtrema($element);
             }
         }
         unset($keys);
     }
     $this->_calcEdges();
     $pctWidth = (int) ($this->width() * 0.05);
     $pctHeight = (int) ($this->height() * 0.05);
     $left = $this->_left + $this->_padding;
     $top = $this->_top + $this->_padding;
     $right = $this->_right - $this->_padding;
     $bottom = $this->_bottom - $this->_padding;
     // temporary place holder for axis point calculations
     $axisPoints['x'] = array($left, $top, $right, $bottom);
     $axisPoints['y'] = $axisPoints['x'];
     $axisPoints['y2'] = $axisPoints['x'];
     if ($this->_axisX !== null) {
         $intersectX = $this->_axisX->_getAxisIntersection();
         $sizeX = $this->_axisX->_size();
         $this->_axisX->_setCoords($left, $top, $right, $bottom);
         $this->_axisX->_updateCoords();
     }
     if ($this->_axisY !== null) {
         $intersectY = $this->_axisY->_getAxisIntersection();
         $sizeY = $this->_axisY->_size();
         $this->_axisY->_setCoords($left, $top, $right, $bottom);
         $this->_axisY->_updateCoords();
     }
     if ($this->_axisYSecondary !== null) {
         $intersectYsec = $this->_axisYSecondary->_getAxisIntersection();
         $sizeYsec = $this->_axisYSecondary->_size();
         $this->_axisYSecondary->_setCoords($left, $top, $right, $bottom);
         $this->_axisYSecondary->_updateCoords();
     }
     $axisCoordAdd = array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0);
     if ($this->_axisY != null) {
         if ($this->_axisX != null) {
             $pos = $this->_axisX->_intersectPoint($intersectY['value']);
         } else {
             $pos = $this->_horizontal ? $bottom : $left;
         }
         if ($this->_horizontal) {
             if ($pos + $sizeY > $bottom) {
                 $axisCoordAdd['bottom'] = $pos + $sizeY - $bottom;
                 // the y-axis position needs to be recalculated!
             } else {
                 // top & bottom may need to be adjusted when the x-axis has been
                 // calculated!
                 $this->_axisY->_setCoords($left, $pos, $right, $pos + $sizeY);
                 $this->_axisY->_updateCoords();
             }
         } else {
             if ($pos - $sizeY < $left) {
                 $axisCoordAdd['left'] = $left - ($pos - $sizeY);
                 // the y-axis position needs to be recalculated!
             } else {
                 // top & bottom may need to be adjusted when the x-axis has been
                 // calculated!
                 $this->_axisY->_setCoords($pos - $sizeY, $top, $pos, $bottom);
                 $this->_axisY->_updateCoords();
             }
         }
     }
     if ($this->_axisYSecondary != null) {
         if ($this->_axisX != null) {
             $pos = $this->_axisX->_intersectPoint($intersectYsec['value']);
         } else {
             $pos = $this->_horizontal ? $top : $right;
         }
         if ($this->_horizontal) {
             if ($pos - $sizeYsec < $top) {
                 $axisCoordAdd['top'] = $top - ($pos - $sizeYsec);
                 // the secondary y-axis position need to be recalculated
             } else {
                 // top & bottom may need to be adjusted when the x-axis has been
                 // calculated!
                 $this->_axisYSecondary->_setCoords($left, $pos - $sizeY, $right, $pos);
                 $this->_axisYSecondary->_updateCoords();
             }
         } else {
             if ($pos + $sizeYsec > $right) {
                 $axisCoordAdd['right'] = $pos + $sizeYsec - $right;
                 // the secondary y-axis position need to be recalculated
             } else {
                 // top & bottom may need to be adjusted when the x-axis has been
                 // calculated!
                 $this->_axisYSecondary->_setCoords($pos, $top, $pos + $sizeY, $bottom);
                 $this->_axisYSecondary->_updateCoords();
             }
         }
     }
     if ($this->_axisX != null) {
         if ($intersectX['axis'] == IMAGE_GRAPH_AXIS_Y_SECONDARY && $this->_axisYSecondary !== null) {
             $axis =& $this->_axisYSecondary;
         } elseif ($this->_axisY !== null) {
             $axis =& $this->_axisY;
         } else {
             $axis = false;
         }
         if ($axis !== false) {
             $pos = $axis->_intersectPoint($intersectX['value']);
         } else {
             $pos = $this->_horizontal ? $left : $bottom;
         }
         if ($this->_horizontal) {
             if ($pos - $sizeX < $left) {
                 $axisCoordAdd['left'] = $left - ($pos - $sizeX);
                 $pos = $left + $sizeX;
             }
             $this->_axisX->_setCoords($pos - $sizeX, $top + $axisCoordAdd['top'], $pos, $bottom - $axisCoordAdd['bottom']);
             $this->_axisX->_updateCoords();
         } else {
             if ($pos + $sizeX > $bottom) {
                 $axisCoordAdd['bottom'] = $pos + $sizeX - $bottom;
                 $pos = $bottom - $sizeX;
             }
             $this->_axisX->_setCoords($left + $axisCoordAdd['left'], $pos, $right - $axisCoordAdd['right'], $pos + $sizeX);
             $this->_axisX->_updateCoords();
         }
     }
     if ($this->_horizontal) {
         if ($this->_axisX !== null && ($axisCoordAdd['top'] != 0 || $axisCoordAdd['bottom'] != 0)) {
             // readjust y-axis for better estimate of position
             if ($this->_axisY !== null) {
                 $pos = $this->_axisX->_intersectPoint($intersectY['value']);
                 $this->_axisY->_setCoords(false, $pos, false, $pos + $sizeY);
                 $this->_axisY->_updateCoords();
             }
             if ($this->_axisYSecondary !== null) {
                 $pos = $this->_axisX->_intersectPoint($intersectYsec['value']);
                 $this->_axisYSecondary->_setCoords(false, $pos - $sizeYsec, false, $pos);
                 $this->_axisYSecondary->_updateCoords();
             }
         }
         // adjust top and bottom of y-axis
         if ($this->_axisY !== null) {
             $this->_axisY->_setCoords($left + $axisCoordAdd['left'], false, $right - $axisCoordAdd['right'], false);
             $this->_axisY->_updateCoords();
         }
         // adjust top and bottom of y-axis
         if ($this->_axisYSecondary !== null) {
             $this->_axisYSecondary->_setCoords($left + $axisCoordAdd['left'], false, $right - $axisCoordAdd['right'], false);
             $this->_axisYSecondary->_updateCoords();
         }
         if ($this->_axisX !== null) {
             $this->_plotTop = $this->_axisX->_top;
             $this->_plotBottom = $this->_axisX->_bottom;
         } else {
             $this->_plotTop = $top;
             $this->_plotBottom = $bottom;
         }
         if ($this->_axisY !== null) {
             $this->_plotLeft = $this->_axisY->_left;
             $this->_plotRight = $this->_axisY->_right;
         } elseif ($this->_axisYSecondary !== null) {
             $this->_plotLeft = $this->_axisYSecondary->_left;
             $this->_plotRight = $this->_axisYSecondary->_right;
         } else {
             $this->_plotLeft = $this->_left;
             $this->_plotRight = $this->_right;
         }
     } else {
         if ($this->_axisX !== null && ($axisCoordAdd['left'] != 0 || $axisCoordAdd['right'] != 0)) {
             // readjust y-axis for better estimate of position
             if ($this->_axisY !== null) {
                 $pos = $this->_axisX->_intersectPoint($intersectY['value']);
                 $this->_axisY->_setCoords($pos - $sizeY, false, $pos, false);
                 $this->_axisY->_updateCoords();
             }
             if ($this->_axisYSecondary !== null) {
                 $pos = $this->_axisX->_intersectPoint($intersectYsec['value']);
                 $this->_axisYSecondary->_setCoords($pos, false, $pos + $sizeYsec, false);
                 $this->_axisYSecondary->_updateCoords();
             }
         }
         // adjust top and bottom of y-axis
         if ($this->_axisY !== null) {
             $this->_axisY->_setCoords(false, $top + $axisCoordAdd['top'], false, $bottom - $axisCoordAdd['bottom']);
             $this->_axisY->_updateCoords();
         }
         // adjust top and bottom of y-axis
         if ($this->_axisYSecondary !== null) {
             $this->_axisYSecondary->_setCoords(false, $top + $axisCoordAdd['top'], false, $bottom - $axisCoordAdd['bottom']);
             $this->_axisYSecondary->_updateCoords();
         }
         if ($this->_axisX !== null) {
             $this->_plotLeft = $this->_axisX->_left;
             $this->_plotRight = $this->_axisX->_right;
         } else {
             $this->_plotLeft = $left;
             $this->_plotRight = $right;
         }
         if ($this->_axisY !== null) {
             $this->_plotTop = $this->_axisY->_top;
             $this->_plotBottom = $this->_axisY->_bottom;
         } elseif ($this->_axisYSecondary !== null) {
             $this->_plotTop = $this->_axisYSecondary->_top;
             $this->_plotBottom = $this->_axisYSecondary->_bottom;
         } else {
             $this->_plotTop = $this->_top;
             $this->_plotBottom = $this->_bottom;
         }
     }
     Image_Graph_Element::_updateCoords();
     /*
             if ($this->_axisX != null) {
                 $this->_axisX->_updateCoords();
             }
             if ($this->_axisY != null) {
                 $this->_axisY->_updateCoords();
             }
             if ($this->_axisYSecondary != null) {
                 $this->_axisYSecondary->_updateCoords();
             }*/
 }
    /**
     * Update coordinates
     * @access private
     */
    function _updateCoords()
    {
        $this->_debug("Calculating and setting edges");
        $this->_calcEdges();

        $pctWidth = (int) ($this->width() * 0.05);
        $pctHeight = (int) ($this->height() * 0.05);
       
        $this->_debug("Adjusting axis");
        if (($this->_axisX != null) and ($this->_axisY != null)) {
            if (($this->_axisX->_minimum >= 0) and ($this->_axisY->_minimum >= 0)) {
                $this->_debug("Fairly standard situation (MinX>= 0, MinY>= 0), starting X axis");
                $this->_axisX->_setCoords(
                    $this->_left + $this->_axisY->_size() + $this->_padding, 
                    $this->_bottom - $this->_axisX->_size() - $this->_padding, 
                    $this->_right - $this->_padding, 
                    $this->_bottom - $this->_padding
                );                   
                $this->_debug("Done x axis, starting y axis");
                $this->_axisY->_setCoords(
                    $this->_left + $this->_padding, 
                    $this->_top + $this->_padding, 
                    $this->_left + $this->_axisY->_size() + $this->_padding, 
                    $this->_bottom - $this->_axisX->_size() - $this->_padding);
                $this->_debug("Done y axis");
            }
            elseif ($this->_axisX->_minimum >= 0) {
                $this->_axisY->_setCoords(
                    $this->_left, 
                    $this->_top, 
                    $this->_left + $this->_axisY->_size(), 
                    $this->_bottom
                );
                $this->_axisX->_setCoords(
                    $this->_axisY->_right, 
                    $this->_axisY->_point(0), 
                    $this->_right, 
                    $this->_axisY->_point(0) + $this->_axisX->_size()
                );
            }
            elseif ($this->_axisY->_minimum >= 0) {
                $this->_axisX->_setCoords(
                    $this->_left, 
                    $this->_bottom - $this->_axisX->_size(), 
                    $this->_right, 
                    $this->_bottom
                );
                $this->_axisY->_setCoords(
                    $this->_axisX->_point(0) - $this->_axisY->_size(), 
                    $this->_top, 
                    $this->_axisX->_point(0), 
                    $this->_axisX->_top
                );
            } else {
                $this->_axisY->_setCoords(
                    $this->_left + $this->_padding, 
                    $this->_top + $this->_padding, 
                    $this->_right - $this->_padding, 
                    $this->_bottom - $this->_padding
                );
                $this->_axisX->_setCoords(
                    $this->_left + $this->_padding, 
                    $this->_axisY->_point(0), 
                    $this->_right - $this->_padding, 
                    $this->_axisY->_point(0) + $this->_axisX->_size()
                );
                $this->_axisY->_setCoords(
                    $this->_axisX->_point(0) - $this->_axisY->_size(), 
                    $this->_top + $this->_padding, 
                    $this->_axisX->_point(0), 
                    $this->_bottom - $this->_padding);
            }

            //$this->_axisX->shrink($indent, $indent, $indent, $indent);
            //$this->_axisY->shrink($indent, $indent, $indent, $indent);

            $this->_plotLeft = $this->_axisX->_left;
            $this->_plotTop = $this->_axisY->_top;
            $this->_plotRight = $this->_axisX->_right;
            $this->_plotBottom = $this->_axisY->_bottom;
        } else {
            $this->_plotLeft = $this->_left;
            $this->_plotTop = $this->_top;
            $this->_plotRight = $this->_right;
            $this->_plotBottom = $this->_bottom;
        }

        $this->_debug("Updating child elements");
        Image_Graph_Element::_updateCoords();
    }
 /**
  * Update coordinates
  * @access private
  */
 function _updateCoords()
 {
     $this->_calcEdges();
     parent::_updateCoords();
 }
Beispiel #6
0
 /**
  * Causes the object to update all sub elements coordinates (Image_Graph_Common, does not itself have coordinates, this is basically an abstract method)
  * @access private
  */
 function _updateCoords()
 {
     $this->_setCoords($this->_parent->_fillLeft()-1, $this->_parent->_fillTop()-1, $this->_parent->_fillRight()+1, $this->_parent->_fillBottom()+1);
     parent::_updateCoords();
 }