예제 #1
0
 /**
  * Get the point from the x-axis
  * @param array $value The value array
  * @param int $min The minimum pixel position possible
  * @param int $max The maximum pixel position possible
  * @return int The pixel position from the axis
  * @access private
  */
 function _axisPointY($value, $min, $max)
 {
     if (!isset($value['Y'])) {
         return false;
     }
     if ($value['Y'] === '#min_pos#' || $value['Y'] === '#max_nex#') {
         // return the minimum (bottom) position or if negative then zero
         // or the maxmum (top) position or if positive then zero
         if (isset($value['AXIS_Y']) && $value['AXIS_Y'] == IMAGE_GRAPH_AXIS_Y_SECONDARY && $this->_axisYSecondary !== null) {
             $axisY =& $this->_axisYSecondary;
         } else {
             $axisY =& $this->_axisY;
         }
         if ($value['Y'] === '#min_pos#') {
             return $axisY->_point(max(0, $axisY->_getMinimum()));
         } else {
             return $axisY->_point(min(0, $axisY->_getMaximum()));
         }
     }
     if ($value['Y'] === '#min#') {
         return $min;
     }
     if ($value['Y'] === '#max#') {
         return $max;
     }
     if (isset($value['AXIS_Y']) && $value['AXIS_Y'] == IMAGE_GRAPH_AXIS_Y_SECONDARY) {
         if ($this->_axisYSecondary !== null) {
             return $this->_axisYSecondary->_point($value['Y']);
         }
     } else {
         if ($this->_axisY !== null) {
             return $this->_axisY->_point($value['Y']);
         }
     }
     return false;
 }
예제 #2
0
    /**
     * 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();
    }