示例#1
0
 /**
  * Set the axis padding for a specified position.
  * 
  * The axis padding is padding "inside" the plotarea (i.e. to put some space
  * between the axis line and the actual plot).
  * 
  * This can be specified in a number of ways:
  * 
  * 1) Specify an associated array with 'left', 'top', 'right' and 'bottom'
  * indices with values for the paddings. Leave out 2nd parameter.
  * 
  * 2) Specify an overall padding as the first parameter
  * 
  * 3) Specify the padding and position with position values as mentioned
  * above
  * 
  * Normally you'd only consider applying axis padding to a category x-axis.
  * 
  * @param mixed $value The value/padding
  * @param mixed $position The "position" of the padding
  */
 function setAxisPadding($value, $position = false)
 {
     if ($position === false) {
         if (is_array($value)) {
             if ($this->_horizontal) {
                 if (isset($value['top']) && $this->_axisX !== null) {
                     $this->_axisX->_setAxisPadding('low', $value['top']);
                 }
                 if (isset($value['bottom']) && $this->_axisX !== null) {
                     $this->_axisX->_setAxisPadding('high', $value['bottom']);
                 }
                 if (isset($value['left']) && $this->_axisY !== null) {
                     $this->_axisY->_setAxisPadding('low', $value['left']);
                 }
                 if (isset($value['right']) && $this->_axisY !== null) {
                     $this->_axisY->_setAxisPadding('high', $value['right']);
                 }
                 if (isset($value['left']) && $this->_axisYSecondary !== null) {
                     $this->_axisYSecondary->_setAxisPadding('low', $value['left']);
                 }
                 if (isset($value['right']) && $this->_axisYSecondary !== null) {
                     $this->_axisYSecondary->_setAxisPadding('high', $value['right']);
                 }
             } else {
                 if (isset($value['left']) && $this->_axisX !== null) {
                     $this->_axisX->_setAxisPadding('low', $value['left']);
                 }
                 if (isset($value['right']) && $this->_axisX !== null) {
                     $this->_axisX->_setAxisPadding('high', $value['right']);
                 }
                 if (isset($value['bottom']) && $this->_axisY !== null) {
                     $this->_axisY->_setAxisPadding('low', $value['bottom']);
                 }
                 if (isset($value['top']) && $this->_axisY !== null) {
                     $this->_axisY->_setAxisPadding('high', $value['top']);
                 }
                 if (isset($value['bottom']) && $this->_axisYSecondary !== null) {
                     $this->_axisYSecondary->_setAxisPadding('low', $value['bottom']);
                 }
                 if (isset($value['top']) && $this->_axisYSecondary !== null) {
                     $this->_axisYSecondary->_setAxisPadding('high', $value['top']);
                 }
             }
         } else {
             if ($this->_axisX !== null) {
                 $this->_axisX->_setAxisPadding('low', $value);
                 $this->_axisX->_setAxisPadding('high', $value);
             }
             if ($this->_axisY !== null) {
                 $this->_axisY->_setAxisPadding('low', $value);
                 $this->_axisY->_setAxisPadding('high', $value);
             }
             if ($this->_axisYSecondary !== null) {
                 $this->_axisYSecondary->_setAxisPadding('low', $value);
                 $this->_axisYSecondary->_setAxisPadding('high', $value);
             }
         }
     } else {
         switch ($position) {
             case 'left':
                 if ($this->_horizontal) {
                     if ($this->_axisY !== null) {
                         $this->_axisY->_setAxisPadding('low', $value);
                     }
                     if ($this->_axisYSecondary !== null) {
                         $this->_axisYSecondary->_setAxisPadding('low', $value);
                     }
                 } else {
                     if ($this->_axisX !== null) {
                         $this->_axisX->_setAxisPadding('low', $value);
                     }
                 }
                 break;
             case 'right':
                 if ($this->_horizontal) {
                     if ($this->_axisY !== null) {
                         $this->_axisY->_setAxisPadding('high', $value);
                     }
                     if ($this->_axisYSecondary !== null) {
                         $this->_axisYSecondary->_setAxisPadding('high', $value);
                     }
                 } else {
                     if ($this->_axisX !== null) {
                         $this->_axisX->_setAxisPadding('high', $value);
                     }
                 }
                 break;
             case 'top':
                 if (!$this->_horizontal) {
                     if ($this->_axisY !== null) {
                         $this->_axisY->_setAxisPadding('high', $value);
                     }
                     if ($this->_axisYSecondary !== null) {
                         $this->_axisYSecondary->_setAxisPadding('high', $value);
                     }
                 } else {
                     if ($this->_axisX !== null) {
                         $this->_axisX->_setAxisPadding('high', $value);
                     }
                 }
                 break;
             case 'bottom':
                 if (!$this->_horizontal) {
                     if ($this->_axisY !== null) {
                         $this->_axisY->_setAxisPadding('low', $value);
                     }
                     if ($this->_axisYSecondary !== null) {
                         $this->_axisYSecondary->_setAxisPadding('low', $value);
                     }
                 } else {
                     if ($this->_axisX !== null) {
                         $this->_axisX->_setAxisPadding('low', $value);
                     }
                 }
                 break;
         }
     }
 }